From 496472d5899e37ba9940c08dd0b71a75d12de21a Mon Sep 17 00:00:00 2001 From: Karan Kajla Date: Mon, 22 Jul 2024 09:20:07 -0700 Subject: [PATCH] Update CheckResultAuthorized constant to be lowercase and add new CheckResultNotAuthorized constant --- pkg/fga/client.go | 8 ++++---- pkg/fga/client_test.go | 18 ++++++------------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/pkg/fga/client.go b/pkg/fga/client.go index 79746958..1327e304 100644 --- a/pkg/fga/client.go +++ b/pkg/fga/client.go @@ -23,9 +23,10 @@ type Order string // Constants that enumerate the available orders. const ( - CheckResultAuthorized = "Authorized" - Asc Order = "asc" - Desc Order = "desc" + CheckResultAuthorized = "authorized" + CheckResultNotAuthorized = "not_authorized" + Asc Order = "asc" + Desc Order = "desc" ) // Client represents a client that performs FGA requests to the WorkOS API. @@ -316,7 +317,6 @@ type CheckBatchOpts struct { } type CheckResponse struct { - Code int64 `json:"code"` Result string `json:"result"` IsImplicit bool `json:"is_implicit"` DebugInfo DebugInfo `json:"debug_info,omitempty"` diff --git a/pkg/fga/client_test.go b/pkg/fga/client_test.go index 4a165078..9943126e 100644 --- a/pkg/fga/client_test.go +++ b/pkg/fga/client_test.go @@ -1044,8 +1044,7 @@ func TestCheck(t *testing.T) { }, }, expected: CheckResponse{ - Code: 200, - Result: "Authorized", + Result: CheckResultAuthorized, IsImplicit: false, }, }, @@ -1085,8 +1084,7 @@ func checkTestHandler(w http.ResponseWriter, r *http.Request) { body, err := json.Marshal( CheckResponse{ - Code: 200, - Result: "Authorized", + Result: CheckResultAuthorized, IsImplicit: false, }) @@ -1141,13 +1139,11 @@ func TestCheckBatch(t *testing.T) { }, expected: []CheckResponse{ { - Code: 200, - Result: "Authorized", + Result: CheckResultAuthorized, IsImplicit: false, }, { - Code: 403, - Result: "Not Authorized", + Result: CheckResultNotAuthorized, IsImplicit: false, }, }, @@ -1189,13 +1185,11 @@ func checkBatchTestHandler(w http.ResponseWriter, r *http.Request) { body, err := json.Marshal( []CheckResponse{ { - Code: 200, - Result: "Authorized", + Result: CheckResultAuthorized, IsImplicit: false, }, { - Code: 403, - Result: "Not Authorized", + Result: CheckResultNotAuthorized, IsImplicit: false, }, })