diff --git a/lib/auth/auth_with_roles_test.go b/lib/auth/auth_with_roles_test.go index 0644187f017bc..4a6c9484ea477 100644 --- a/lib/auth/auth_with_roles_test.go +++ b/lib/auth/auth_with_roles_test.go @@ -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)