Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathis Marcotte committed Apr 9, 2024
1 parent ae23412 commit e5c874e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions components/centraldashboard/app/api_workgroup_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('Workgroup API', () => {
mockK8sService = jasmine.createSpyObj<KubernetesService>([
'getPlatformInfo',
'getNamespaces',
'getAllowlistConfigMap'
]);
mockK8sService.getPlatformInfo.and.returnValue(Promise.resolve({
provider: 'onprem',
Expand Down Expand Up @@ -203,6 +204,9 @@ describe('Workgroup API', () => {
beforeEach(() => {
mockProfilesService = jasmine.createSpyObj<DefaultApi>(
['readBindings', 'v1RoleClusteradminGet']);
mockK8sService = jasmine.createSpyObj<KubernetesService>([
'getAllowlistConfigMap'
]);

testApp = express();
testApp.use(express.json());
Expand All @@ -225,6 +229,10 @@ describe('Workgroup API', () => {
bindings: []
},
}));
mockK8sService.getAllowlistConfigMap.and.returnValue(Promise.resolve({
data: {
allowlist: '{"users": []}'
}}));
const expectedResponse = {hasAuth: false, hasWorkgroup: false,
user: 'anonymous', email: '[email protected]', registrationFlowAllowed: true,
isAllowed: true};
Expand All @@ -251,6 +259,10 @@ describe('Workgroup API', () => {
}]
},
}));
mockK8sService.getAllowlistConfigMap.and.returnValue(Promise.resolve({
data: {
allowlist: '{"users": []}'
}}));

const expectedResponse = {hasAuth: true, hasWorkgroup: true,
user: 'test', email: '[email protected]', registrationFlowAllowed: true,
Expand All @@ -276,6 +288,10 @@ describe('Workgroup API', () => {
response: null,
body: {bindings: []},
}));
mockK8sService.getAllowlistConfigMap.and.returnValue(Promise.resolve({
data: {
allowlist: '{"users": []}'
}}));

const expectedResponse = {hasAuth: true, hasWorkgroup: false,
user: 'test', email: '[email protected]', registrationFlowAllowed: true,
Expand Down

0 comments on commit e5c874e

Please sign in to comment.