Skip to content

Commit

Permalink
Do not perform any RBAC calls on openshift bundle (#952)
Browse files Browse the repository at this point in the history
  • Loading branch information
karelhala authored Sep 8, 2020
1 parent eaef592 commit 1029aea
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ global.window.insights = {
}
}))
},
getUserPermissions: () => Promise.resolve([])
getUserPermissions: () => Promise.resolve([]),
getBundle: () => ''
}
};
2 changes: 1 addition & 1 deletion src/js/App/RootApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ RootApp.propTypes = {
activeLocation: PropTypes.string,
pageAction: PropTypes.string,
pageObjectId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
globalFilterHidden: PropTypes.boolean
globalFilterHidden: PropTypes.bool
};

function stateToProps({ chrome: { activeApp, activeLocation, appId, pageAction, pageObjectId, globalFilterHidden } }) {
Expand Down
3 changes: 3 additions & 0 deletions src/js/rbac/fetchPermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const log = logger('fetchPermissions.js');
const perPage = 25;

export const fetchPermissions = (userToken, app = '') => {
if (insights.chrome.getBundle() === 'openshift') {
return Promise.resolve([]);
}
const rbacApi = createRbacAPI(userToken);
return rbacApi.getPrincipalAccess(app, undefined, perPage).then(({ data, meta }) => {
if (meta.count > perPage) {
Expand Down
8 changes: 8 additions & 0 deletions src/js/rbac/fetchPermissions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ it('should send the data as array', async () => {
expect.assertions(1);
return data.then(permissions => expect(permissions).toEqual(mockedRbac.data));
});

it('should not call any rbac', async () => {
const previousGetBundle = global.insights.chrome.getBundle;
global.window.insights.chrome.getBundle = () => 'openshift';
const data = await fetchPermissions('uSeRtOkEn');
expect(data).not.toEqual(mockedRbac.data);
global.window.insights.chrome.getBundle = previousGetBundle;
});

0 comments on commit 1029aea

Please sign in to comment.