Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions lib/auth/auth_with_roles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4130,14 +4130,33 @@ func TestLocalServiceRolesHavePermissionsForUploaderService(t *testing.T) {
srv, err := NewTestAuthServer(TestAuthServerConfig{Dir: t.TempDir()})
require.NoError(t, err)

for _, role := range types.LocalServiceMappings() {
// Test all local service roles, plus RoleInstance.
// The latter may also be used to run the uploader.
roles := append(types.LocalServiceMappings(), types.RoleInstance)
for _, role := range roles {
if role == types.RoleAuth {
continue
}
t.Run(role.String(), func(t *testing.T) {
ctx := context.Background()

identity := TestBuiltin(role)
var identity TestIdentity
if role == types.RoleInstance {
// RoleInstance needs AdditionalSystemRoles, otherwise the setup is the
// same.
identity = TestIdentity{
I: BuiltinRole{
Role: role,
AdditionalSystemRoles: []types.SystemRole{
types.RoleNode, // Arbitrary, could be any role.
},
Username: string(role),
},
}
} else {
identity = TestBuiltin(role)
}

authContext, err := srv.Authorizer.Authorize(context.WithValue(ctx, ContextUser, identity.I))
require.NoError(t, err)

Expand Down