diff --git a/lib/auth/auth_with_roles_test.go b/lib/auth/auth_with_roles_test.go index 09d6390e52134..18feca778c1c7 100644 --- a/lib/auth/auth_with_roles_test.go +++ b/lib/auth/auth_with_roles_test.go @@ -3826,7 +3826,10 @@ 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 { // RoleMDM services don't create events by themselves, instead they rely on // Auth to issue events. if role == types.RoleAuth || role == types.RoleMDM { @@ -3835,7 +3838,22 @@ func TestLocalServiceRolesHavePermissionsForUploaderService(t *testing.T) { 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: authz.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(authz.ContextWithUser(ctx, identity.I)) require.NoError(t, err)