refactor: apply review suggestion

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2024-05-17 15:01:07 +02:00
parent 8472011064
commit 2418224eb2
7 changed files with 53 additions and 31 deletions
+2 -28
View File
@@ -15,35 +15,9 @@
*/
import { createBackend } from '@backstage/backend-defaults';
import {
coreServices,
createServiceFactory,
} from '@backstage/backend-plugin-api';
import { IdentityApi } from '@backstage/plugin-auth-node';
const identityMock: IdentityApi = {
async getIdentity({ request }) {
const token = request.headers.authorization?.split(' ')[1];
return {
identity: {
type: 'user',
ownershipEntityRefs: [],
userEntityRef: token || 'user:default/john_doe',
},
token: token || 'no-token',
};
},
};
import { mockServices } from '@backstage/backend-test-utils';
const backend = createBackend();
backend.add(
createServiceFactory(() => ({
service: coreServices.identity,
deps: {},
async factory() {
return identityMock;
},
})),
);
backend.add(mockServices.identity.factory());
backend.add(import('../src/alpha'));
backend.start();