Create default roles in scopes to allow authentication and listing scopes/auth methods (#502)
This commit is contained in:
1 parent
67c7b82fbe
commit
a38f40606e
31 files changed
+616
-188
No files matched your search
@@ -127,8 +127,14 @@ var inputStructs = []*structInfo{
|
||||
pathArgs: []string{"scope"},
|
||||
extraOptions: []fieldInfo{
|
||||
{
|
||||
Name: "SkipRoleCreation",
|
||||
ProtoName: "skip_role_creation",
|
||||
Name: "SkipAdminRoleCreation",
|
||||
ProtoName: "skip_admin_role_creation",
|
||||
FieldType: "bool",
|
||||
Query: true,
|
||||
},
|
||||
{
|
||||
Name: "SkipDefaultRoleCreation",
|
||||
ProtoName: "skip_default_role_creation",
|
||||
FieldType: "bool",
|
||||
Query: true,
|
||||
},
|
||||
|
||||
@@ -143,22 +143,22 @@ func TestList(t *testing.T) {
|
||||
roleClient := roles.NewClient(client)
|
||||
p1, err := roleClient.List(tc.Context(), tt.scopeId)
|
||||
require.NoError(err)
|
||||
require.Len(p1.Items, 1)
|
||||
expected = append(expected, p1.Items[0])
|
||||
require.Len(p1.Items, 2)
|
||||
expected = append(expected, p1.Items[0:2]...)
|
||||
|
||||
for i := 1; i < 11; i++ {
|
||||
for i := 2; i < 12; i++ {
|
||||
expected = append(expected, &roles.Role{Name: fmt.Sprint(i)})
|
||||
}
|
||||
|
||||
rcr, err := roleClient.Create(tc.Context(), tt.scopeId, roles.WithName(expected[1].Name))
|
||||
rcr, err := roleClient.Create(tc.Context(), tt.scopeId, roles.WithName(expected[2].Name))
|
||||
require.NoError(err)
|
||||
expected[1] = rcr.Item
|
||||
expected[2] = rcr.Item
|
||||
|
||||
p2, err := roleClient.List(tc.Context(), tt.scopeId)
|
||||
require.NoError(err)
|
||||
assert.ElementsMatch(comparableSlice(expected[0:2]), comparableSlice(p2.Items))
|
||||
assert.ElementsMatch(comparableSlice(expected[0:3]), comparableSlice(p2.Items))
|
||||
|
||||
for i := 2; i < 11; i++ {
|
||||
for i := 3; i < 12; i++ {
|
||||
rcr, err = roleClient.Create(tc.Context(), tt.scopeId, roles.WithName(expected[i].Name))
|
||||
assert.NoError(err)
|
||||
expected[i] = rcr.Item
|
||||
|
||||
@@ -71,14 +71,26 @@ func DefaultName() Option {
|
||||
}
|
||||
}
|
||||
|
||||
func WithSkipRoleCreation(inSkipRoleCreation bool) Option {
|
||||
func WithSkipAdminRoleCreation(inSkipAdminRoleCreation bool) Option {
|
||||
return func(o *options) {
|
||||
o.queryMap["skip_role_creation"] = fmt.Sprintf("%v", inSkipRoleCreation)
|
||||
o.queryMap["skip_admin_role_creation"] = fmt.Sprintf("%v", inSkipAdminRoleCreation)
|
||||
}
|
||||
}
|
||||
|
||||
func DefaultSkipRoleCreation() Option {
|
||||
func DefaultSkipAdminRoleCreation() Option {
|
||||
return func(o *options) {
|
||||
o.postMap["skip_role_creation"] = nil
|
||||
o.postMap["skip_admin_role_creation"] = nil
|
||||
}
|
||||
}
|
||||
|
||||
func WithSkipDefaultRoleCreation(inSkipDefaultRoleCreation bool) Option {
|
||||
return func(o *options) {
|
||||
o.queryMap["skip_default_role_creation"] = fmt.Sprintf("%v", inSkipDefaultRoleCreation)
|
||||
}
|
||||
}
|
||||
|
||||
func DefaultSkipDefaultRoleCreation() Option {
|
||||
return func(o *options) {
|
||||
o.postMap["skip_default_role_creation"] = nil
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user