feat: add cmshopee authorization shadow routes
This commit is contained in:
@@ -26,6 +26,7 @@ from apps.licensing.services import (
|
||||
confirm_migration_request,
|
||||
create_legacy_migration_grant,
|
||||
create_migration_request,
|
||||
evaluate_device_authorization,
|
||||
grant_software_entitlement,
|
||||
record_device_heartbeat,
|
||||
release_license_seat,
|
||||
@@ -625,3 +626,50 @@ class LegacyMigrationFlowTests(TestCase):
|
||||
now=timezone.now(),
|
||||
)
|
||||
self.assertFalse(DeviceCredential.objects.exists())
|
||||
|
||||
def test_authorization_decision_handles_missing_mismatched_and_expired_credentials(self):
|
||||
self.grant_migration()
|
||||
migration_request, raw_token = create_migration_request(
|
||||
user=self.user,
|
||||
device=self.device,
|
||||
)
|
||||
_request, credential, created = confirm_migration_request(
|
||||
request_id=migration_request.request_id,
|
||||
user=self.user,
|
||||
)
|
||||
self.assertTrue(created)
|
||||
self.assertEqual(
|
||||
evaluate_device_authorization(
|
||||
user=self.user,
|
||||
product_code="cmshopee",
|
||||
).code,
|
||||
"device_not_bound",
|
||||
)
|
||||
self.assertEqual(
|
||||
evaluate_device_authorization(
|
||||
user=self.user,
|
||||
product_code="cmshopee",
|
||||
device=self.device,
|
||||
).code,
|
||||
"license_required",
|
||||
)
|
||||
allowed = evaluate_device_authorization(
|
||||
user=self.user,
|
||||
product_code="cmshopee",
|
||||
device=self.device,
|
||||
raw_credential_token=raw_token,
|
||||
)
|
||||
self.assertTrue(allowed.allowed)
|
||||
self.assertEqual(allowed.credential_id, credential.id)
|
||||
|
||||
DeviceCredential.objects.filter(pk=credential.pk).update(
|
||||
expires_at=timezone.now() - timedelta(seconds=1)
|
||||
)
|
||||
expired = evaluate_device_authorization(
|
||||
user=self.user,
|
||||
product_code="cmshopee",
|
||||
device=self.device,
|
||||
raw_credential_token=raw_token,
|
||||
)
|
||||
self.assertTrue(expired.would_reject)
|
||||
self.assertEqual(expired.code, "license_expired")
|
||||
|
||||
Reference in New Issue
Block a user