plugins: migrate usage of deprecated IdentityApi methods

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-01-04 23:08:05 +01:00
parent 2916a83b9c
commit 51fbedc445
38 changed files with 221 additions and 195 deletions
@@ -25,38 +25,16 @@ import { IdentityApi } from '@backstage/core-plugin-api';
const server = setupServer();
const identityApiAuthenticated: IdentityApi = {
getUserId() {
return 'jane-fonda';
},
getProfile() {
return { email: 'jane-fonda@spotify.com' };
},
async getIdToken() {
return Promise.resolve('fake-id-token');
},
async signOut() {
return Promise.resolve();
},
signOut: jest.fn(),
getProfileInfo: jest.fn(),
getBackstageIdentity: jest.fn(),
getCredentials: jest.fn(),
getCredentials: jest.fn().mockResolvedValue({ token: 'fake-id-token' }),
};
const identityApiGuest: IdentityApi = {
getUserId() {
return 'guest';
},
getProfile() {
return {};
},
async getIdToken() {
return Promise.resolve(undefined);
},
async signOut() {
return Promise.resolve();
},
signOut: jest.fn(),
getProfileInfo: jest.fn(),
getBackstageIdentity: jest.fn(),
getCredentials: jest.fn(),
getCredentials: jest.fn().mockResolvedValue({ token: undefined }),
};
describe('SonarQubeClient', () => {
+1 -1
View File
@@ -42,7 +42,7 @@ export class SonarQubeClient implements SonarQubeApi {
path: string,
query: { [key in string]: any },
): Promise<T | undefined> {
const idToken = await this.identityApi.getIdToken();
const { token: idToken } = await this.identityApi.getCredentials();
const apiUrl = `${await this.discoveryApi.getBaseUrl('proxy')}/sonarqube`;
const response = await fetch(