Skip to content

Commit

Permalink
Include policy in warrant deserialization (#1125)
Browse files Browse the repository at this point in the history
## Description

- Updates `Warrant` deserializer to include policy from
`WarrantResponse`

## Documentation

Does this require changes to the WorkOS Docs? E.g. the [API
Reference](https://workos.com/docs/reference) or code snippets need
updates.

```
[ ] Yes
```

If yes, link a related docs PR and add a docs maintainer as a reviewer.
Their approval is required.
  • Loading branch information
stanleyphu committed Sep 13, 2024
1 parent 926c88d commit 7c92eba
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/fga/fga-live-test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ describe.skip('FGA Live Test', () => {
resource: newPermission,
relation: 'member',
subject: user2,
policy: 'region == "us"',
});
expect(warrant2.warrantToken).toBeDefined();

Expand All @@ -684,6 +685,7 @@ describe.skip('FGA Live Test', () => {
expect(warrants1.data[0].relation).toEqual('member');
expect(warrants1.data[0].subject.resourceType).toEqual('user');
expect(warrants1.data[0].subject.resourceId).toEqual(user2.resourceId);
expect(warrants1.data[0].policy).toEqual('region == "us"');

const warrants2 = await workos.fga.listWarrants(
{ limit: 1, after: warrants1.listMetadata.after },
Expand Down
2 changes: 2 additions & 0 deletions src/fga/fga.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ describe('FGA', () => {
resource_type: 'user',
resource_id: 'user_124',
},
policy: 'region == "us"',
},
],
list_metadata: {
Expand Down Expand Up @@ -533,6 +534,7 @@ describe('FGA', () => {
resourceType: 'user',
resourceId: 'user_124',
},
policy: 'region == "us"',
},
]);
});
Expand Down
1 change: 1 addition & 0 deletions src/fga/interfaces/warrant.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ export interface WarrantResponse {
resource_id: string;
relation: string;
subject: SerializedSubject;
policy?: string;
}
1 change: 1 addition & 0 deletions src/fga/serializers/warrant.serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export const deserializeWarrant = (warrant: WarrantResponse): Warrant => ({
resourceId: warrant.subject.resource_id,
relation: warrant.subject.relation,
},
policy: warrant.policy,
});

0 comments on commit 7c92eba

Please sign in to comment.