From ee6605024dd092137c99d2ed80cb3c294b8d1264 Mon Sep 17 00:00:00 2001 From: guillaume-peoch-sonarsource Date: Wed, 1 Nov 2023 17:37:14 +0100 Subject: [PATCH] SONAR-20923 Unclear message in case GitHub OAuth App is used for Authentication --- .../GithubAuthenticationTab.tsx | 4 ++-- .../__tests__/Authentication-it.tsx | 8 +++++-- .../main/js/helpers/mocks/definitions-list.ts | 21 +++++++++++++++++++ .../resources/org/sonar/l10n/core.properties | 3 ++- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/settings/components/authentication/GithubAuthenticationTab.tsx b/server/sonar-web/src/main/js/apps/settings/components/authentication/GithubAuthenticationTab.tsx index 7843eec2a5f..665e5c027e6 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/authentication/GithubAuthenticationTab.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/authentication/GithubAuthenticationTab.tsx @@ -124,7 +124,7 @@ export default function GithubAuthenticationTab(props: GithubAuthenticationProps )} - {enabled && ( + {enabled && !hasLegacyConfiguration && ( - {translate('documentation')} + {translate('settings.authentication.github.form.legacy_configured.link')} ), }} diff --git a/server/sonar-web/src/main/js/apps/settings/components/authentication/__tests__/Authentication-it.tsx b/server/sonar-web/src/main/js/apps/settings/components/authentication/__tests__/Authentication-it.tsx index 450e66cddc2..18c872bacdd 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/authentication/__tests__/Authentication-it.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/authentication/__tests__/Authentication-it.tsx @@ -134,6 +134,8 @@ const ui = { noGithubConfiguration: byText('settings.authentication.github.form.not_configured'), createConfigButton: byRole('button', { name: 'settings.authentication.form.create' }), clientId: byRole('textbox', { name: 'property.sonar.auth.github.clientId.secured.name' }), + appId: byRole('textbox', { name: 'property.sonar.auth.github.appId.name' }), + privateKey: byRole('textbox', { name: 'property.sonar.auth.github.privateKey.secured.name' }), clientSecret: byRole('textbox', { name: 'property.sonar.auth.github.clientSecret.secured.name', }), @@ -235,6 +237,8 @@ const ui = { await act(async () => { await user.type(await github.clientId.find(), 'Awsome GITHUB config'); await user.type(github.clientSecret.get(), 'Client shut'); + await user.type(github.appId.get(), 'App id'); + await user.type(github.privateKey.get(), 'Private Key'); await user.type(github.githubApiUrl.get(), 'API Url'); await user.type(github.githubWebUrl.get(), 'WEb Url'); await user.type(github.organizations.get(), 'organization1'); @@ -356,7 +360,7 @@ describe('SAML tab', () => { await user.click(saml.scimProvisioningButton.get()); expect(saml.saveScim.get()).toBeEnabled(); await user.click(saml.saveScim.get()); - await user.click(saml.confirmProvisioningButton.get()); + await act(() => user.click(saml.confirmProvisioningButton.get())); expect(await saml.scimProvisioningButton.find()).toBeChecked(); expect(await saml.saveScim.find()).toBeDisabled(); @@ -480,7 +484,7 @@ describe('Github tab', () => { expect(github.saveGithubProvisioning.get()).toBeEnabled(); await user.click(github.saveGithubProvisioning.get()); - await user.click(github.confirmProvisioningButton.get()); + await act(() => user.click(github.confirmProvisioningButton.get())); expect(await github.githubProvisioningButton.find()).toBeChecked(); expect(github.disableConfigButton.get()).toBeDisabled(); diff --git a/server/sonar-web/src/main/js/helpers/mocks/definitions-list.ts b/server/sonar-web/src/main/js/helpers/mocks/definitions-list.ts index bb61f1e9f36..b981aeb97ac 100644 --- a/server/sonar-web/src/main/js/helpers/mocks/definitions-list.ts +++ b/server/sonar-web/src/main/js/helpers/mocks/definitions-list.ts @@ -147,6 +147,27 @@ export const definitions: ExtendedSettingDefinition[] = [ options: [], fields: [], }, + { + key: 'sonar.auth.github.appId', + name: 'App ID', + description: + 'The App ID is found on your GitHub App\u0027s page on GitHub at Settings \u003e Developer Settings \u003e GitHub Apps.', + category: 'authentication', + subCategory: 'github', + options: [], + fields: [], + }, + { + key: 'sonar.auth.github.privateKey.secured', + name: 'Private Key', + description: + 'Your GitHub App\u0027s private key. You can generate a .pem file from your GitHub App\u0027s page under Private keys.\nCopy and paste the whole contents of the file here.', + type: SettingType.TEXT, + category: 'authentication', + subCategory: 'github', + options: [], + fields: [], + }, { key: 'sonar.auth.github.clientSecret.secured', name: 'Client Secret', diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 5199d1d23a6..580d9e76bcd 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1511,7 +1511,8 @@ settings.authentication.github.confirm_auto_provisioning.switch_jit=Just-in-Time settings.authentication.github.provisioning_change.confirm_changes=Confirm Changes settings.authentication.github.configuration=GitHub Configuration settings.authentication.github.form.not_configured=GitHub App is not configured -settings.authentication.github.form.legacy_configured=Compatibility with GitHub OAuth App is deprecated and will be removed in a future release. Your configuration will continue to work but with limited support. We recommend using GitHub Apps. Check out the {documentation} for more information. +settings.authentication.github.form.legacy_configured=Compatibility with GitHub OAuth Apps is deprecated and will be removed in a future release. As such, your current configuration will continue to work but some features will no longer be available. We recommend that you create a new GitHub App configuration. This will automatically replace your current GitHub OAuth App configuration. {documentation} +settings.authentication.github.form.legacy_configured.link=Learn more about how to create a GitHub App configuration settings.authentication.github.enable_first=Enable your GitHub configuration for more provisioning options. settings.authentication.github.form.provisioning_with_github=Automatic user, group, and permission provisioning settings.authentication.github.form.provisioning_with_github_short.autoProvisioning=Automatic provisioning -- 2.39.5