UNPKG

@backstage/backend-test-utils

Version:

Test helpers library for Backstage backends

27 lines (23 loc) 668 B
'use strict'; var errors = require('@backstage/errors'); class MockUserInfoService { customInfo; constructor(customInfo) { this.customInfo = customInfo ?? {}; } async getUserInfo(credentials) { const principal = credentials.principal; if (principal.type !== "user") { throw new errors.InputError( `User info not available for principal type '${principal.type}'` ); } return { userEntityRef: principal.userEntityRef, ownershipEntityRefs: [principal.userEntityRef], ...this.customInfo }; } } exports.MockUserInfoService = MockUserInfoService; //# sourceMappingURL=MockUserInfoService.cjs.js.map