signIn.resolver made mandatory + test fix

Signed-off-by: Filip Swiatczak <filip.swiatczak@gmail.com>
This commit is contained in:
Filip Swiatczak
2021-09-29 20:24:34 +01:00
parent 114fbb8e4a
commit 96658c576d
2 changed files with 13 additions and 7 deletions
@@ -14,9 +14,8 @@
* limitations under the License.
*/
import { BitbucketAuthProvider } from './provider';
import { BitbucketAuthProvider, BitbucketOAuthResult } from './provider';
import * as helpers from '../../lib/passport/PassportStrategyHelper';
import { OAuthResult } from '../../lib/oauth';
import { getVoidLogger } from '@backstage/backend-common';
import { TokenIssuer } from '../../identity/types';
import { CatalogIdentityClient } from '../../lib/catalog';
@@ -25,7 +24,7 @@ const mockFrameHandler = jest.spyOn(
helpers,
'executeFrameHandlerStrategy',
) as unknown as jest.MockedFunction<
() => Promise<{ result: OAuthResult; privateInfo: any }>
() => Promise<{ result: BitbucketOAuthResult; privateInfo: any }>
>;
describe('createBitbucketProvider', () => {
@@ -58,6 +57,13 @@ describe('createBitbucketProvider', () => {
mockFrameHandler.mockResolvedValueOnce({
result: {
fullProfile: {
_json: {
links: {
avatar: {
href: 'https://a1cf74336522e87f135f-2f21ace9a6cf0052456644b80fa06d4f.ssl.cf2.rackcdn.com/images/characters_opt/p-mystic-river-sean-penn.jpg',
},
},
},
emails: [{ value: 'conrad@example.com' }],
displayName: 'Conrad',
id: 'conrad',
@@ -53,7 +53,7 @@ type PrivateInfo = {
type Options = OAuthProviderOptions & {
signInResolver?: SignInResolver<OAuthResult>;
authHandler: AuthHandler<OAuthResult>;
authHandler: AuthHandler<BitbucketOAuthResult>;
tokenIssuer: TokenIssuer;
catalogIdentityClient: CatalogIdentityClient;
logger: Logger;
@@ -213,7 +213,7 @@ export const bitbucketEmailSignInResolver: SignInResolver<OAuthResult> = async (
const entity = await ctx.catalogIdentityClient.findUser({
annotations: {
'bitbucket/email': profile.email,
'bitbucket.org/email': profile.email,
},
});
@@ -248,11 +248,11 @@ export type BitbucketProviderOptions = {
/**
* Configure sign-in for this provider, without it the provider can not be used to sign users in.
*/
signIn?: {
signIn: {
/**
* Maps an auth result to a Backstage identity for the user.
*/
resolver?: SignInResolver<OAuthResult>;
resolver: SignInResolver<OAuthResult>;
};
};