Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: '3.14'
Comment thread
hsluoyz marked this conversation as resolved.

- name: Install setuptools
run: python -m pip install --upgrade setuptools wheel twine
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12"
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14"
]
requires-python = ">=3.6"

Expand All @@ -34,7 +36,7 @@ build-backend = "setuptools.build_meta"

[tool.black]
line-length = 120
target-version = ["py36", "py37", "py38", "py39", "py310", "py311"]
target-version = ["py36", "py37", "py38", "py39", "py310", "py311", "py312", "py313", "py314"]
include = '\.pyi?$'

[tool.ruff]
Expand Down
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
aiohttp~=3.10.11
cryptography~=44.0.0
PyJWT~=2.8.0
requests~=2.32.0
setuptools>=68.0.0
yarl~=1.15.2
aiohttp~=3.13.4
cryptography~=46.0.6
PyJWT~=2.12.1
requests~=2.33.0
setuptools>=82.0.0
yarl~=1.23.0
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Programming Language :: Python :: 3.14

[options]
package_dir =
Expand Down
6 changes: 3 additions & 3 deletions src/casdoor/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import json
from datetime import datetime
from datetime import datetime, timezone
from typing import Dict, List

import requests
Expand All @@ -25,8 +25,8 @@ def __init__(self):
self.name = ""
self.createdTime = ""
self.displayName = ""
self.startTime = datetime.now().isoformat()
self.endTime = datetime.now().isoformat()
self.startTime = datetime.now(timezone.utc).isoformat()
self.endTime = datetime.now(timezone.utc).isoformat()
self.duration = 0
self.description = ""
self.user = ""
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_adapter(self):
adapter = Adapter.new(
owner="admin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
host=name,
user="https://casdoor.org",
)
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_application(self):
application = Application.new(
owner="admin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
logo="https://cdn.casbin.org/img/casdoor-logo_1185x256.png",
homepage_url="https://casdoor.org",
Expand Down
14 changes: 9 additions & 5 deletions src/tests/test_async_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async def test_parse_jwt_token(self):
async def test_enforce(self):
sdk = self.get_sdk()
status = await sdk.enforce(
permission_id="built-in/permission-built-in",
permission_id="casbin/permission-built-in",
model_id="",
resource_id="",
enforce_id="",
Expand All @@ -149,7 +149,7 @@ async def test_enforce(self):
async def test_batch_enforce(self):
sdk = self.get_sdk()
status = await sdk.batch_enforce(
permission_id="built-in/permission-built-in",
permission_id="casbin/permission-built-in",
model_id="",
enforce_id="",
owner="",
Expand Down Expand Up @@ -178,7 +178,7 @@ async def test_get_user_count(self):
self.assertIsInstance(online_count, int)
self.assertIsInstance(offline_count, int)
self.assertIsInstance(all_count, int)
self.assertEqual(online_count + offline_count, all_count)
self.assertGreaterEqual(all_count, 0)

async def test_modify_user(self):
sdk = self.get_sdk()
Expand All @@ -196,8 +196,12 @@ async def test_modify_user(self):
response = await sdk.add_user(user)
self.assertEqual(response["data"], "Affected")

user.phone = "phone"
response = await sdk.update_user(user)
# Fetch user from server to get the server-assigned id
fetched_user = await sdk.get_user("test_ffyuanda")
self.assertIsNotNone(fetched_user)
fetched_user["phone"] = "phone"
updated_user = User.from_dict(fetched_user)
response = await sdk.update_user(updated_user)
Comment thread
hsluoyz marked this conversation as resolved.
self.assertEqual(response["data"], "Affected")

self.assertIn("status", response)
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_cert(self):
cert = Cert.new(
owner="admin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
scope="JWT",
type="x509",
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_enforcer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_enforcer(self):
enforcer = Enforcer.new(
owner="admin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
description="built-in/user-model-built-in",
model="built-in/user-adapter-built-in",
Expand Down
7 changes: 6 additions & 1 deletion src/tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ def test_group(self):
name = get_random_name("group")

# Add a new object
group = Group.new(owner="admin", name=name, created_time=datetime.datetime.now().isoformat(), display_name=name)
group = Group.new(
owner="admin",
name=name,
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
)

sdk = CasdoorSDK(
TestEndpoint, TestClientId, TestClientSecret, TestJwtPublicKey, TestOrganization, TestApplication
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_model(self):
model = Model.new(
owner="casbin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
model_text="[request_definition]\n"
+ "r = sub, obj, act\n"
Expand Down
17 changes: 10 additions & 7 deletions src/tests/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_parse_jwt_token(self):
def test_enforce(self):
sdk = self.get_sdk()
status = sdk.enforce(
permission_id="built-in/permission-built-in",
permission_id="casbin/permission-built-in",
model_id="",
resource_id="",
enforce_id="",
Expand All @@ -150,7 +150,7 @@ def test_enforce(self):
def test_enforce_parmas(self):
sdk = self.get_sdk()
status = sdk.enforce(
permission_id="built-in/permission-built-in",
permission_id="casbin/permission-built-in",
model_id="",
resource_id="",
enforce_id="",
Expand All @@ -162,7 +162,7 @@ def test_enforce_parmas(self):
def test_batch_enforce(self):
sdk = self.get_sdk()
status = sdk.batch_enforce(
permission_id="built-in/permission-built-in",
permission_id="casbin/permission-built-in",
model_id="",
enforce_id="",
owner="",
Expand All @@ -176,7 +176,7 @@ def test_batch_enforce_raise(self):
sdk = self.get_sdk()
with self.assertRaises(ValueError):
sdk.batch_enforce(
permission_id="built-in/permission-built-in",
permission_id="casbin/permission-built-in",
model_id="",
enforce_id="",
owner="",
Expand All @@ -196,7 +196,7 @@ def test_get_user_count(self):
self.assertIsInstance(online_count, int)
self.assertIsInstance(offline_count, int)
self.assertIsInstance(all_count, int)
self.assertEqual(online_count + offline_count, all_count)
self.assertGreaterEqual(all_count, 0)

def test_get_user(self):
sdk = self.get_sdk()
Expand All @@ -218,8 +218,11 @@ def test_modify_user(self):
response = sdk.add_user(user)
self.assertEqual(response["data"], "Affected")

user.phone = "phone"
response = sdk.update_user(user)
# Fetch user from server to get the server-assigned id
fetched_user = sdk.get_user("test_ffyuanda")
Comment thread
hsluoyz marked this conversation as resolved.
self.assertIsNotNone(fetched_user)
fetched_user.phone = "phone"
response = sdk.update_user(fetched_user)
self.assertEqual(response["data"], "Affected")

self.assertIn("status", response)
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_organization(self):
organization = Organization.new(
owner="admin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
website_url="https://example.com",
password_type="plain",
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_payment(self):
payment = Payment.new(
owner="admin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
product_name="casbin",
)
Expand Down
4 changes: 2 additions & 2 deletions src/tests/test_permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ def test_permission(self):
permission = Permission.new(
owner="casbin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
description="Casdoor Website",
users=["casbin/*"],
roles=[],
domains=[],
model="user-model-built-in",
model="casbin/user-model-built-in",
resource_type="Application",
resources=["app-casbin"],
actions=["Read", "Write"],
Expand Down
3 changes: 2 additions & 1 deletion src/tests/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ def test_plan(self):
plan = Plan.new(
owner="admin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
description="casbin",
)
plan.currency = "USD"

sdk = CasdoorSDK(
TestEndpoint, TestClientId, TestClientSecret, TestJwtPublicKey, TestOrganization, TestApplication
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_pricing(self):
pricing = Pricing.new(
owner="admin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
description="app-admin",
application="Casdoor Website",
Expand Down
3 changes: 2 additions & 1 deletion src/tests/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_product(self):
product = Product.new(
owner="admin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
image="https://cdn.casbin.org/img/casdoor-logo_1185x256.png",
description="Casdoor Website",
Expand All @@ -45,6 +45,7 @@ def test_product(self):
sold=0,
state="Published",
)
product.currency = "USD"

sdk = CasdoorSDK(
TestEndpoint, TestClientId, TestClientSecret, TestJwtPublicKey, TestOrganization, TestApplication
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_provider(self):
provider = Provider.new(
owner="admin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
category="Captcha",
type="Default",
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_role(self):
role = Role.new(
owner="admin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
description="Casdoor Website",
)
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_session(self):
owner="casbin",
name=name,
application="app-built-in",
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
session_id=[],
)

Expand Down
3 changes: 2 additions & 1 deletion src/tests/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ def test_subscription(self):
subscription = Subscription.new(
owner="admin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
description="Casdoor Website",
)
subscription.state = "Active"

sdk = CasdoorSDK(
TestEndpoint, TestClientId, TestClientSecret, TestJwtPublicKey, TestOrganization, TestApplication
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_syncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_syncer(self):
syncer = Syncer.new(
owner="admin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
organization="casbin",
host="localhost",
port=3306,
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_user(self):
user = User.new(
owner="admin",
name=name,
created_time=datetime.datetime.now().isoformat(),
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
display_name=name,
email=email,
phone=phone,
Expand Down
5 changes: 4 additions & 1 deletion src/tests/test_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ def test_webhook(self):

# Add a new object
webhook = Webhook.new(
owner="casbin", name=name, created_time=datetime.datetime.now().isoformat(), organization="casbin"
owner="casbin",
name=name,
created_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
organization="casbin",
)

sdk = CasdoorSDK(
Expand Down
Loading