From 813a7625a5195daf1bf01ea5effbcac1cf864efd Mon Sep 17 00:00:00 2001 From: Eric Leijonmarck Date: Tue, 24 Oct 2023 13:52:55 +0100 Subject: [PATCH] RBAC: Default to None role on SA creation if accesscontrol enabled (#77035) * Check accesscontrol enabled on service account creation * fix test * linting --- .../features/serviceaccounts/ServiceAccountCreatePage.test.tsx | 2 +- .../app/features/serviceaccounts/ServiceAccountCreatePage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/features/serviceaccounts/ServiceAccountCreatePage.test.tsx b/public/app/features/serviceaccounts/ServiceAccountCreatePage.test.tsx index ccb200df8f4..7d53a87ffa2 100644 --- a/public/app/features/serviceaccounts/ServiceAccountCreatePage.test.tsx +++ b/public/app/features/serviceaccounts/ServiceAccountCreatePage.test.tsx @@ -83,7 +83,7 @@ describe('ServiceAccountCreatePage tests', () => { await waitFor(() => expect(postMock).toHaveBeenCalledWith('/api/serviceaccounts/', { name: 'Data source scavenger', - role: 'None', + role: 'Viewer', }) ); }); diff --git a/public/app/features/serviceaccounts/ServiceAccountCreatePage.tsx b/public/app/features/serviceaccounts/ServiceAccountCreatePage.tsx index 70425722dca..725969145f0 100644 --- a/public/app/features/serviceaccounts/ServiceAccountCreatePage.tsx +++ b/public/app/features/serviceaccounts/ServiceAccountCreatePage.tsx @@ -29,7 +29,7 @@ export const ServiceAccountCreatePage = ({}: Props): JSX.Element => { const [serviceAccount, setServiceAccount] = useState({ id: 0, orgId: contextSrv.user.orgId, - role: OrgRole.None, + role: contextSrv.licensedAccessControlEnabled() ? OrgRole.None : OrgRole.Viewer, tokens: 0, name: '', login: '',