backend-*-api: updates auth APIs for BEP changes
Co-authored-by: Fredrik Adelöw <freben@gmail.com> Co-authored-by: Camila Belo <camilaibs@gmail.com> Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -44,7 +44,7 @@ export class MockAuthService implements AuthService {
|
||||
throw new AuthenticationError('Invalid token');
|
||||
}
|
||||
|
||||
async getOwnCredentials(): Promise<
|
||||
async getOwnServiceCredentials(): Promise<
|
||||
BackstageCredentials<BackstageServicePrincipal>
|
||||
> {
|
||||
return {
|
||||
@@ -68,10 +68,11 @@ export class MockAuthService implements AuthService {
|
||||
return true;
|
||||
}
|
||||
|
||||
async issueServiceToken(options: {
|
||||
forward: BackstageCredentials;
|
||||
async getPluginRequestToken(options: {
|
||||
onBehalfOf: BackstageCredentials;
|
||||
targetPluginId: string;
|
||||
}): Promise<{ token: string }> {
|
||||
const principal = options.forward.principal as
|
||||
const principal = options.onBehalfOf.principal as
|
||||
| BackstageUserPrincipal
|
||||
| BackstageServicePrincipal
|
||||
| BackstageNonePrincipal;
|
||||
@@ -80,7 +81,7 @@ export class MockAuthService implements AuthService {
|
||||
case 'user':
|
||||
return { token: 'mock-user-token' };
|
||||
case 'service':
|
||||
return { token: 'mock-service-token' };
|
||||
return { token: `mock-service-token-for-${options.targetPluginId}` };
|
||||
default:
|
||||
throw new AuthenticationError(
|
||||
`Refused to issue service token for credential type '${principal.type}'`,
|
||||
|
||||
@@ -180,9 +180,9 @@ export namespace mockServices {
|
||||
});
|
||||
export const mock = simpleMock(coreServices.auth, () => ({
|
||||
authenticate: jest.fn(),
|
||||
getOwnCredentials: jest.fn(),
|
||||
getOwnServiceCredentials: jest.fn(),
|
||||
isPrincipal: jest.fn() as any,
|
||||
issueServiceToken: jest.fn(),
|
||||
getPluginRequestToken: jest.fn(),
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -217,7 +217,6 @@ export namespace mockServices {
|
||||
export const mock = simpleMock(coreServices.httpAuth, () => ({
|
||||
credentials: jest.fn(),
|
||||
issueUserCookie: jest.fn(),
|
||||
requestHeaders: jest.fn(),
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user