Skip to content

Commit

Permalink
Add constants for Warrant create/delete operations + add constants fo…
Browse files Browse the repository at this point in the history
…r check operations ('any_of', 'all_of', etc).
  • Loading branch information
kkajla12 committed Jul 22, 2024
1 parent 496472d commit 42d9c81
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 8 additions & 3 deletions pkg/fga/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ type Order string

// Constants that enumerate the available orders.
const (
CheckResultAuthorized = "authorized"
CheckResultNotAuthorized = "not_authorized"
Asc Order = "asc"
Desc Order = "desc"
CheckOpAllOf = "all_of"
CheckOpAnyOf = "any_of"
CheckOpBatch = "batch"
CheckResultAuthorized = "authorized"
CheckResultNotAuthorized = "not_authorized"
WarrantOpCreate = "create"
WarrantOpDelete = "delete"
)

// Client represents a client that performs FGA requests to the WorkOS API.
Expand Down Expand Up @@ -817,7 +822,7 @@ func (c *Client) CheckBatch(ctx context.Context, opts CheckBatchOpts) ([]CheckRe
c.once.Do(c.init)

checkOpts := CheckOpts{
Op: "batch",
Op: CheckOpBatch,
Checks: opts.Checks,
Debug: opts.Debug,
WarrantToken: opts.WarrantToken,
Expand Down
8 changes: 4 additions & 4 deletions pkg/fga/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ func TestWriteWarrant(t *testing.T) {
APIKey: "test",
},
options: WriteWarrantOpts{
Op: "create",
Op: WarrantOpCreate,
ResourceType: "report",
ResourceId: "sso_1710",
Relation: "member",
Expand All @@ -885,7 +885,7 @@ func TestWriteWarrant(t *testing.T) {
APIKey: "test",
},
options: WriteWarrantOpts{
Op: "delete",
Op: WarrantOpDelete,
ResourceType: "report",
ResourceId: "sso_1710",
Relation: "member",
Expand Down Expand Up @@ -940,7 +940,7 @@ func TestBatchWriteWarrants(t *testing.T) {
},
options: []WriteWarrantOpts{
{
Op: "delete",
Op: WarrantOpDelete,
ResourceType: "report",
ResourceId: "sso_1710",
Relation: "viewer",
Expand All @@ -950,7 +950,7 @@ func TestBatchWriteWarrants(t *testing.T) {
},
},
{
Op: "create",
Op: WarrantOpCreate,
ResourceType: "report",
ResourceId: "sso_1710",
Relation: "editor",
Expand Down

0 comments on commit 42d9c81

Please sign in to comment.