From 63a6a3d44ba2e61094778a7ff4dfcd5e78141a6c Mon Sep 17 00:00:00 2001 From: headphonejames Date: Mon, 27 Feb 2023 17:32:00 -0800 Subject: [PATCH] rebase and fix bitbucket server Signed-off-by: headphonejames --- packages/app-defaults/src/defaults/apis.ts | 4 +++- .../auth/bitbucketServer/BitbucketServerAuth.test.ts | 7 +++++++ .../auth/bitbucketServer/BitbucketServerAuth.ts | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/app-defaults/src/defaults/apis.ts b/packages/app-defaults/src/defaults/apis.ts index f8464adaff..3a552c25c7 100644 --- a/packages/app-defaults/src/defaults/apis.ts +++ b/packages/app-defaults/src/defaults/apis.ts @@ -233,9 +233,11 @@ export const apis = [ deps: { discoveryApi: discoveryApiRef, oauthRequestApi: oauthRequestApiRef, + configApi: configApiRef, }, - factory: ({ discoveryApi, oauthRequestApi }) => + factory: ({ discoveryApi, oauthRequestApi, configApi }) => BitbucketServerAuth.create({ + configApi, discoveryApi, oauthRequestApi, defaultScopes: ['REPO_READ'], diff --git a/packages/core-app-api/src/apis/implementations/auth/bitbucketServer/BitbucketServerAuth.test.ts b/packages/core-app-api/src/apis/implementations/auth/bitbucketServer/BitbucketServerAuth.test.ts index 32e7755a00..e1625c7687 100644 --- a/packages/core-app-api/src/apis/implementations/auth/bitbucketServer/BitbucketServerAuth.test.ts +++ b/packages/core-app-api/src/apis/implementations/auth/bitbucketServer/BitbucketServerAuth.test.ts @@ -17,6 +17,8 @@ import MockOAuthApi from '../../OAuthRequestApi/MockOAuthApi'; import { UrlPatternDiscovery } from '../../DiscoveryApi'; import BitbucketServerAuth from './BitbucketServerAuth'; +import { ConfigReader } from '@backstage/config'; +import { ConfigApi } from '@backstage/core-plugin-api'; const getSession = jest.fn(); @@ -40,7 +42,12 @@ describe('BitbucketServerAuth', () => { ['PROJECT_ADMIN', 'REPO_READ', 'ACCOUNT_WRITE'], ], ])(`should normalize scopes correctly - %p`, (scope, scopes) => { + const configApi: ConfigApi = new ConfigReader({ + enableExperimentalRedirectFlow: false, + }); + const bitbucketServerAuth = BitbucketServerAuth.create({ + configApi: configApi, oauthRequestApi: new MockOAuthApi(), discoveryApi: UrlPatternDiscovery.compile('http://example.com'), }); diff --git a/packages/core-app-api/src/apis/implementations/auth/bitbucketServer/BitbucketServerAuth.ts b/packages/core-app-api/src/apis/implementations/auth/bitbucketServer/BitbucketServerAuth.ts index dc50eff6ab..b25deffb93 100644 --- a/packages/core-app-api/src/apis/implementations/auth/bitbucketServer/BitbucketServerAuth.ts +++ b/packages/core-app-api/src/apis/implementations/auth/bitbucketServer/BitbucketServerAuth.ts @@ -48,6 +48,7 @@ export default class BitbucketServerAuth { options: OAuthApiCreateOptions, ): typeof bitbucketServerAuthApiRef.T { const { + configApi, discoveryApi, environment = 'development', provider = DEFAULT_PROVIDER, @@ -56,6 +57,7 @@ export default class BitbucketServerAuth { } = options; return OAuth2.create({ + configApi, discoveryApi, oauthRequestApi, provider,