-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1489 from authzed/multiple-slashes
all: support multiple slashes in object and caveat names
- Loading branch information
Showing
19 changed files
with
275 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
internal/services/integrationtesting/testconfigs/multipleslashes.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
schema: |+ | ||
definition org/identity_team/user {} | ||
definition org/identity_team/group { | ||
relation member: org/identity_team/user | org/identity_team/group#member | ||
} | ||
definition org/docs_team/resource { | ||
relation host: org/infra_team/resource | ||
relation viewer: org/identity_team/group#member | org/identity_team/group#member with foo/bar/only_on_tuesday | ||
} | ||
definition org/infra_team/resource { | ||
relation viewer: org/identity_team/group#member | org/identity_team/group#member with foo/bar/only_on_tuesday | ||
} | ||
caveat foo/bar/only_on_tuesday(day_of_week string) { | ||
day_of_week == 'tuesday' | ||
} | ||
relationships: >- | ||
org/identity_team/group:ultragroup#member@org/identity_team/user:someguy#... | ||
org/identity_team/group:megagroup#member@org/identity_team/group:ultragroup#member | ||
org/identity_team/group:supergroup#member@org/identity_team/group:megagroup#member | ||
org/identity_team/group:subgroup#member@org/identity_team/group:supergroup#member | ||
org/docs_team/resource:someresource#viewer@org/identity_team/group:subgroup#member | ||
org/docs_team/resource:someresource#host@org/infra_team/resource:prod-box | ||
assertions: | ||
assertTrue: [] | ||
assertFalse: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package compiler | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestPrefixedPath(t *testing.T) { | ||
fooPrefix := "foo" | ||
barPrefix := "bar" | ||
noPrefix := "" | ||
|
||
testCases := []struct { | ||
input string | ||
prefix *string | ||
expectedError bool | ||
expected string | ||
}{ | ||
{"bar", &fooPrefix, false, "foo/bar"}, | ||
{"bar", &barPrefix, false, "bar/bar"}, | ||
{"bar", &noPrefix, false, "bar"}, | ||
{"foo/bar", &fooPrefix, false, "foo/bar"}, | ||
{"foo/bar", &barPrefix, false, "foo/bar"}, | ||
{"foo/bar", &noPrefix, false, "foo/bar"}, | ||
{"bar", nil, true, ""}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.input, func(t *testing.T) { | ||
require := require.New(t) | ||
|
||
tctx := translationContext{ | ||
objectTypePrefix: tc.prefix, | ||
} | ||
output, err := tctx.prefixedPath(tc.input) | ||
if tc.expectedError { | ||
require.Error(err) | ||
} else { | ||
require.NoError(err) | ||
require.Equal(tc.expected, output) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.