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
@@ -185,8 +185,8 @@ func TestList(t *testing.T) {
|
||||
repoFn := func() (*iam.Repository, error) {
|
||||
return iamRepo, nil
|
||||
}
|
||||
oNoRoles, pWithRoles := iam.TestScopes(t, iamRepo)
|
||||
oWithRoles, pNoRoles := iam.TestScopes(t, iamRepo)
|
||||
oNoRoles, pWithRoles := iam.TestScopes(t, iamRepo, iam.WithSkipDefaultRoleCreation(true))
|
||||
oWithRoles, pNoRoles := iam.TestScopes(t, iamRepo, iam.WithSkipDefaultRoleCreation(true))
|
||||
var wantOrgRoles []*pb.Role
|
||||
var wantProjRoles []*pb.Role
|
||||
for i := 0; i < 10; i++ {
|
||||
|
||||
@@ -162,7 +162,8 @@ func (s Service) createInRepo(ctx context.Context, authResults auth.VerifyResult
|
||||
if item.GetDescription() != nil {
|
||||
opts = append(opts, iam.WithDescription(item.GetDescription().GetValue()))
|
||||
}
|
||||
opts = append(opts, iam.WithSkipRoleCreation(req.GetSkipRoleCreation()))
|
||||
opts = append(opts, iam.WithSkipAdminRoleCreation(req.GetSkipAdminRoleCreation()))
|
||||
opts = append(opts, iam.WithSkipDefaultRoleCreation(req.GetSkipDefaultRoleCreation()))
|
||||
|
||||
parentScope := authResults.Scope
|
||||
var iamScope *iam.Scope
|
||||
|
||||
@@ -609,10 +609,17 @@ func TestCreate(t *testing.T) {
|
||||
require.NoError(err)
|
||||
roles, err := repo.ListRoles(ctx, got.GetItem().GetId())
|
||||
require.NoError(err)
|
||||
require.Len(roles, 1)
|
||||
role := roles[0]
|
||||
assert.Equal("on-scope-creation", role.GetName())
|
||||
assert.Equal(fmt.Sprintf("Role created for administration of scope %s by user %s at its creation time", got.GetItem().GetId(), userId), role.GetDescription())
|
||||
require.Len(roles, 2)
|
||||
for _, role := range roles {
|
||||
switch role.GetName() {
|
||||
case "Administration":
|
||||
assert.Equal(fmt.Sprintf("Role created for administration of scope %s by user %s at its creation time", got.GetItem().GetId(), userId), role.GetDescription())
|
||||
case "Default Grants":
|
||||
assert.Equal(fmt.Sprintf("Role created for authentication to and listing of some resources of scope %s at its creation time", got.GetItem().GetId()), role.GetDescription())
|
||||
default:
|
||||
t.Fatal("unexpected role name", role.GetName())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear all values which are hard to compare against.
|
||||
|
||||
Reference in new issue
Block a user