diff --git a/README.md b/README.md index 2caebef..1459f91 100644 --- a/README.md +++ b/README.md @@ -1100,14 +1100,6 @@ fga query **list-users** --object --relation --user-filter < ```json5 { { - "excluded_users": [ - { - "object": { - "type": "user", - "id": "beth" - } - } - ], "users": [ { "object": { diff --git a/example/model.fga.yaml b/example/model.fga.yaml index a92ecf7..a7cfaaa 100644 --- a/example/model.fga.yaml +++ b/example/model.fga.yaml @@ -78,8 +78,6 @@ tests: users: - user:anne - user:beth - excluded_users: [] can_write: users: - user:anne - excluded_users: [] diff --git a/go.mod b/go.mod index 7707d79..6ee835a 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/nwidger/jsoncolor v0.3.2 github.com/oklog/ulid/v2 v2.1.0 github.com/openfga/api/proto v0.0.0-20240529190005-394820dfc109 - github.com/openfga/go-sdk v0.4.0 + github.com/openfga/go-sdk v0.5.0 github.com/openfga/language/pkg/go v0.0.0-20240530090832-1ae482acc202 github.com/openfga/openfga v1.5.4 github.com/spf13/cobra v1.8.0 diff --git a/go.sum b/go.sum index 22c3341..4f68937 100644 --- a/go.sum +++ b/go.sum @@ -185,8 +185,8 @@ github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQ github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= github.com/openfga/api/proto v0.0.0-20240529190005-394820dfc109 h1:V92DXyx43GBjLCv4Ky/u2jT8Lr1Hc3g8wNbnDHBfdBM= github.com/openfga/api/proto v0.0.0-20240529190005-394820dfc109/go.mod h1:gil5LBD8tSdFQbUkCQdnXsoeU9kDJdJgbGdHkgJfcd0= -github.com/openfga/go-sdk v0.4.0 h1:C7h/x7Yq3NjxThHE4YGz+rwfawmyo8d9SVScer8fB9w= -github.com/openfga/go-sdk v0.4.0/go.mod h1:AoMnFlPw65sU/7O4xOPpCb2vXA8ZD9K9xp2hZjcvt4g= +github.com/openfga/go-sdk v0.5.0 h1:1IuAu6Xf4eBxgc2AyMfosK7QzApxuZ5yi7jmFaftnl0= +github.com/openfga/go-sdk v0.5.0/go.mod h1:AoMnFlPw65sU/7O4xOPpCb2vXA8ZD9K9xp2hZjcvt4g= github.com/openfga/language/pkg/go v0.0.0-20240530090832-1ae482acc202 h1:DkW3VX6wOMckk2VIeaafdKW1WOt5Se6d/7L9239tt6I= github.com/openfga/language/pkg/go v0.0.0-20240530090832-1ae482acc202/go.mod h1:mCwEY2IQvyNgfEwbfH0C0ERUwtL8z6UjSAF8zgn5Xbg= github.com/openfga/openfga v1.5.4 h1:mVrp0uB9jNWX/5+OtZLM6YOx5Y9Y4r/D/O+LNBF/FGQ= diff --git a/internal/storetest/conversion.go b/internal/storetest/conversion.go index d5336df..9e131fd 100644 --- a/internal/storetest/conversion.go +++ b/internal/storetest/conversion.go @@ -106,18 +106,3 @@ func convertOpenfgaUsers(users []openfga.User) []string { return simpleUsers } - -func convertOpenfgaObjectOrUserset(users []openfga.ObjectOrUserset) []string { - simpleUsers := []string{} - - for _, user := range users { - switch { - case user.Object != nil: - simpleUsers = append(simpleUsers, user.Object.Type+":"+user.Object.Id) - case user.Userset != nil: - simpleUsers = append(simpleUsers, user.Userset.Type+":"+user.Userset.Id+"#"+user.Userset.Relation) - } - } - - return simpleUsers -} diff --git a/internal/storetest/conversion_test.go b/internal/storetest/conversion_test.go index 82b664e..d846559 100644 --- a/internal/storetest/conversion_test.go +++ b/internal/storetest/conversion_test.go @@ -172,31 +172,3 @@ func TestConvertPbObjectOrUsersetToStrings(t *testing.T) { }) } } - -func TestConvertObjectOrUsersetToStrings(t *testing.T) { - t.Parallel() - - tests := map[string]struct { - input openfga.ObjectOrUserset - expected string - }{ - "User_Object": { - input: openfga.ObjectOrUserset{Object: &openfga.FgaObject{Type: "user", Id: "anne"}}, - expected: "user:anne", - }, - "User_Userset": { - input: openfga.ObjectOrUserset{Userset: &openfga.UsersetUser{Type: "group", Id: "fga", Relation: "member"}}, - expected: "group:fga#member", - }, - } - - for name, testcase := range tests { - t.Run(name, func(t *testing.T) { - t.Parallel() - - got := convertOpenfgaObjectOrUserset([]openfga.ObjectOrUserset{testcase.input}) - - assert.Equal(t, []string{testcase.expected}, got) - }) - } -} diff --git a/internal/storetest/localtest.go b/internal/storetest/localtest.go index 723e2a5..466bfb8 100644 --- a/internal/storetest/localtest.go +++ b/internal/storetest/localtest.go @@ -205,8 +205,7 @@ func RunLocalListUsersTest( if response != nil { result.Got = ModelTestListUsersAssertion{ - Users: convertPbUsersToStrings(response.GetUsers()), - ExcludedUsers: convertPbObjectOrUsersetToStrings(response.GetExcludedUsers()), + Users: convertPbUsersToStrings(response.GetUsers()), } result.TestResult = result.IsPassing() } diff --git a/internal/storetest/remotetest.go b/internal/storetest/remotetest.go index 02ac13e..864673a 100644 --- a/internal/storetest/remotetest.go +++ b/internal/storetest/remotetest.go @@ -112,8 +112,7 @@ func RunSingleRemoteListUsersTest( if response != nil { result.Got = ModelTestListUsersAssertion{ - Users: convertOpenfgaUsers(response.GetUsers()), - ExcludedUsers: convertOpenfgaObjectOrUserset(response.GetExcludedUsers()), + Users: convertOpenfgaUsers(response.GetUsers()), } result.TestResult = result.IsPassing() } diff --git a/internal/storetest/storedata.go b/internal/storetest/storedata.go index 7668b8f..737ca18 100644 --- a/internal/storetest/storedata.go +++ b/internal/storetest/storedata.go @@ -51,8 +51,7 @@ type ModelTestListUsers struct { } type ModelTestListUsersAssertion struct { - Users []string `json:"users" yaml:"users"` - ExcludedUsers []string `json:"excluded_users" yaml:"excluded_users"` //nolint:tagliatelle + Users []string `json:"users" yaml:"users"` } type ModelTest struct { diff --git a/internal/storetest/testresult.go b/internal/storetest/testresult.go index 42ce282..d4e95cb 100644 --- a/internal/storetest/testresult.go +++ b/internal/storetest/testresult.go @@ -46,8 +46,7 @@ type ModelTestListUsersSingleResult struct { func (result ModelTestListUsersSingleResult) IsPassing() bool { return result.Error == nil && - comparison.CheckStringArraysEqual(result.Got.Users, result.Expected.Users) && - comparison.CheckStringArraysEqual(result.Got.ExcludedUsers, result.Expected.ExcludedUsers) + comparison.CheckStringArraysEqual(result.Got.Users, result.Expected.Users) } type TestResult struct { @@ -199,9 +198,6 @@ func buildListUsersTestResults( failedListUsersCount++ got := NoValueString - if listUsersResult.Got.Users != nil || listUsersResult.Got.ExcludedUsers != nil { - got = fmt.Sprintf("%+v", listUsersResult.Got) - } userFilter := listUsersResult.Request.UserFilters[0]