mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-22 15:11:07 +02:00
* move sync activation and capabilities from flag service to version service and components * cleanup unnecessary args * remove permissions service * un-nest (some) modules * simplify overview test so logic is easier to follow * modal test * update service tests * change back to 403 because maybe it is permissions related? * fix tests running on CE * small cleanup * fix logic based on feedback * add logic for hvd specifically, update cluster tests
46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { allFeatures } from 'vault/helpers/all-features';
|
|
import sinon from 'sinon';
|
|
|
|
/**
|
|
* Sets up the necessary shared test context for testing sidebar nav components
|
|
* @param {TestContext.owner} owner eg this.owner from within a test
|
|
* @param {boolean} isEnterprise [default false]
|
|
* @param {boolean} setCluster [default false] if true, will set the current cluster to one with replication & raft
|
|
* @param {string[]} features if not passed, defaults to all features
|
|
* @returns {hasNavPermission: sinon.SinonStub, features: string[]}
|
|
*/
|
|
export const stubFeaturesAndPermissions = (
|
|
owner,
|
|
isEnterprise = false,
|
|
setCluster = false,
|
|
features,
|
|
hasPermission = true
|
|
) => {
|
|
const permissions = owner.lookup('service:permissions');
|
|
const hasNavPermission = sinon.stub(permissions, 'hasNavPermission');
|
|
hasNavPermission.returns(hasPermission);
|
|
sinon.stub(permissions, 'navPathParams');
|
|
|
|
const version = owner.lookup('service:version');
|
|
version.type = isEnterprise ? 'enterprise' : 'community';
|
|
version.features = features || allFeatures();
|
|
|
|
const auth = owner.lookup('service:auth');
|
|
sinon.stub(auth, 'authData').value({});
|
|
|
|
if (setCluster) {
|
|
owner.lookup('service:currentCluster').setCluster({
|
|
id: 'foo',
|
|
anyReplicationEnabled: true,
|
|
usingRaft: true,
|
|
});
|
|
}
|
|
|
|
return { hasNavPermission, features };
|
|
};
|