|
| 1 | +"""Mock fixture for AuthorizationResource used in testing new FGA APIs. |
| 2 | +
|
| 3 | +This fixture represents the new organization-scoped authorization resource model |
| 4 | +used in the Advanced FGA APIs, distinct from the legacy warrant-based resources. |
| 5 | +""" |
| 6 | + |
| 7 | +from typing import Optional |
| 8 | + |
| 9 | + |
| 10 | +class MockAuthorizationResource: |
| 11 | + """Mock authorization resource for testing the new FGA resource-based APIs. |
| 12 | +
|
| 13 | + Attributes: |
| 14 | + id: Internal WorkOS resource ID. |
| 15 | + external_id: Customer-provided external identifier for the resource. |
| 16 | + name: Human-readable name for the resource. |
| 17 | + description: Optional description of the resource. |
| 18 | + resource_type_slug: The type of resource (e.g., "document", "folder"). |
| 19 | + organization_id: The organization this resource belongs to. |
| 20 | + parent_resource_id: Optional parent resource ID for hierarchical resources. |
| 21 | + """ |
| 22 | + |
| 23 | + def __init__( |
| 24 | + self, |
| 25 | + id: str = "authz_resource_01HXYZ123ABC456DEF789ABC", |
| 26 | + external_id: str = "doc-456", |
| 27 | + name: str = "Q4 Budget Report", |
| 28 | + description: Optional[str] = "Financial report for Q4 2025", |
| 29 | + resource_type_slug: str = "document", |
| 30 | + organization_id: str = "org_01HXYZ123ABC456DEF789ABC", |
| 31 | + parent_resource_id: Optional[str] = None, |
| 32 | + ): |
| 33 | + self.id = id |
| 34 | + self.external_id = external_id |
| 35 | + self.name = name |
| 36 | + self.description = description |
| 37 | + self.resource_type_slug = resource_type_slug |
| 38 | + self.organization_id = organization_id |
| 39 | + self.parent_resource_id = parent_resource_id |
| 40 | + |
| 41 | + def dict(self) -> dict: |
| 42 | + """Return the resource as a dictionary matching API response format.""" |
| 43 | + return { |
| 44 | + "object": "authorization_resource", |
| 45 | + "id": self.id, |
| 46 | + "external_id": self.external_id, |
| 47 | + "name": self.name, |
| 48 | + "description": self.description, |
| 49 | + "resource_type_slug": self.resource_type_slug, |
| 50 | + "organization_id": self.organization_id, |
| 51 | + "parent_resource_id": self.parent_resource_id, |
| 52 | + "created_at": "2024-01-15T09:30:00.000Z", |
| 53 | + "updated_at": "2024-01-15T09:30:00.000Z", |
| 54 | + } |
0 commit comments