plugins: migrate usage of deprecated IdentityApi methods
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user