From 9726f3f0b82a43b505869c3fa66b797335897eb3 Mon Sep 17 00:00:00 2001 From: Gustaf Lundh Date: Tue, 22 Aug 2023 12:57:37 +0200 Subject: [PATCH] Log-entry should be a thrown error Signed-off-by: Gustaf Lundh --- .changeset/grumpy-papayas-tie.md | 2 +- packages/integration/src/gerrit/core.test.ts | 12 +++++++++++- packages/integration/src/gerrit/core.ts | 4 +--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.changeset/grumpy-papayas-tie.md b/.changeset/grumpy-papayas-tie.md index a5635afc67..48580673d8 100644 --- a/.changeset/grumpy-papayas-tie.md +++ b/.changeset/grumpy-papayas-tie.md @@ -2,4 +2,4 @@ '@backstage/integration': patch --- -Gerrit: Gitiles auth-links could still be broken +Additional fix for Gitiles auth links diff --git a/packages/integration/src/gerrit/core.test.ts b/packages/integration/src/gerrit/core.test.ts index 19bddcf518..5fbb41763a 100644 --- a/packages/integration/src/gerrit/core.test.ts +++ b/packages/integration/src/gerrit/core.test.ts @@ -90,12 +90,22 @@ describe('gerrit core', () => { 'https://gerrit.com/gerrit/a/plugins/gitiles/repo/+archive/refs/heads/dev/docs.tar.gz', ); }); - it('can create an authenticated url when auth is enabled and an url-path + slash is used', () => { + it('Cannot build an authenticated url when a dedicated Gitiles server is used', () => { const authConfig = { ...configWithDedicatedGitiles, username: 'username', password: 'password', }; + expect(() => + buildGerritGitilesArchiveUrl(authConfig, 'repo', 'dev', 'docs'), + ).toThrow( + 'Since the baseUrl (Gerrit) is not part of the gitilesBaseUrl, an authentication URL could not be constructed.', + ); + }); + it('Build a non-authenticated url when a dedicated Gitiles server is used', () => { + const authConfig = { + ...configWithDedicatedGitiles, + }; expect( buildGerritGitilesArchiveUrl(authConfig, 'repo', 'dev', 'docs'), ).toEqual( diff --git a/packages/integration/src/gerrit/core.ts b/packages/integration/src/gerrit/core.ts index 4b7242730e..b3bdbc30e4 100644 --- a/packages/integration/src/gerrit/core.ts +++ b/packages/integration/src/gerrit/core.ts @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import { logger } from '@azure/identity'; import { trimStart } from 'lodash'; import { GerritIntegrationConfig } from './config'; @@ -169,7 +167,7 @@ export function getGitilesAuthenticationUrl( ); } if (config.password) { - logger.warning( + throw new Error( 'Since the baseUrl (Gerrit) is not part of the gitilesBaseUrl, an authentication URL could not be constructed.', ); }