chore: 🤖 vault ldap feature flag
This commit is contained in:
1 parent
ff087738fc
commit
df8bfc42bb
5 files changed
+77
-34
No files matched your search
@@ -7,6 +7,7 @@ import Component from '@glimmer/component';
|
||||
import {
|
||||
TYPES_CREDENTIAL_LIBRARY,
|
||||
TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE,
|
||||
TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP,
|
||||
} from 'api/models/credential-library';
|
||||
import { service } from '@ember/service';
|
||||
|
||||
@@ -19,11 +20,20 @@ export default class FormCredentialLibraryRadioComponent extends Component {
|
||||
* @returns {Array.<string>}
|
||||
*/
|
||||
get credentialTypes() {
|
||||
let types = TYPES_CREDENTIAL_LIBRARY;
|
||||
return this.features.isEnabled('ssh-target')
|
||||
? types
|
||||
: types.filter(
|
||||
let types = [...TYPES_CREDENTIAL_LIBRARY];
|
||||
|
||||
if (!this.features.isEnabled('ssh-target')) {
|
||||
types = types.filter(
|
||||
(type) => type !== TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE,
|
||||
);
|
||||
}
|
||||
|
||||
if (!this.features.isEnabled('vault-ldap-credential')) {
|
||||
types = types.filter(
|
||||
(type) => type !== TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP,
|
||||
);
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
}
|
||||
+37
-30
@@ -40,38 +40,45 @@
|
||||
@valign='middle'
|
||||
>
|
||||
<:body as |B|>
|
||||
<B.Tr>
|
||||
<B.Td>
|
||||
{{#if (can 'read credential-library' B.data)}}
|
||||
<LinkTo
|
||||
@route='scopes.scope.credential-stores.credential-store.credential-libraries.credential-library'
|
||||
@model={{B.data.id}}
|
||||
>
|
||||
{{B.data.displayName}}
|
||||
</LinkTo>
|
||||
{{else}}
|
||||
{{#if
|
||||
(or
|
||||
(not-eq B.data.type 'vault-ldap')
|
||||
(feature-flag 'vault-ldap-credential')
|
||||
)
|
||||
}}
|
||||
<B.Tr>
|
||||
<B.Td>
|
||||
{{#if (can 'read credential-library' B.data)}}
|
||||
<LinkTo
|
||||
@route='scopes.scope.credential-stores.credential-store.credential-libraries.credential-library'
|
||||
@model={{B.data.id}}
|
||||
>
|
||||
{{B.data.displayName}}
|
||||
</LinkTo>
|
||||
{{else}}
|
||||
<Hds::Text::Body @tag='p'>
|
||||
{{B.data.displayName}}
|
||||
</Hds::Text::Body>
|
||||
{{/if}}
|
||||
<Hds::Text::Body @tag='p'>
|
||||
{{B.data.displayName}}
|
||||
{{B.data.description}}
|
||||
</Hds::Text::Body>
|
||||
{{/if}}
|
||||
<Hds::Text::Body @tag='p'>
|
||||
{{B.data.description}}
|
||||
</Hds::Text::Body>
|
||||
</B.Td>
|
||||
<B.Td>
|
||||
<Hds::Badge
|
||||
@text={{t
|
||||
(concat 'resources.credential-library.types.' B.data.type)
|
||||
}}
|
||||
/>
|
||||
</B.Td>
|
||||
<B.Td>
|
||||
<Hds::Copy::Snippet
|
||||
@textToCopy={{B.data.id}}
|
||||
@color='secondary'
|
||||
/>
|
||||
</B.Td>
|
||||
</B.Tr>
|
||||
</B.Td>
|
||||
<B.Td>
|
||||
<Hds::Badge
|
||||
@text={{t
|
||||
(concat 'resources.credential-library.types.' B.data.type)
|
||||
}}
|
||||
/>
|
||||
</B.Td>
|
||||
<B.Td>
|
||||
<Hds::Copy::Snippet
|
||||
@textToCopy={{B.data.id}}
|
||||
@color='secondary'
|
||||
/>
|
||||
</B.Td>
|
||||
</B.Tr>
|
||||
{{/if}}
|
||||
</:body>
|
||||
</Hds::Table>
|
||||
{{else}}
|
||||
|
||||
@@ -28,6 +28,8 @@ const baseEdition = {
|
||||
'ldap-auth-methods': false,
|
||||
'worker-filter': false,
|
||||
'worker-filter-hcp': false,
|
||||
// TODO: Remove this flag when Vault-ldap credential library is supported
|
||||
'vault-ldap-credential': false,
|
||||
};
|
||||
// Editions maps edition keys to their associated featuresets.
|
||||
const featureEditions = {};
|
||||
|
||||
@@ -450,6 +450,8 @@ module('Acceptance | credential-libraries | create', function (hooks) {
|
||||
},
|
||||
});
|
||||
|
||||
featuresService.enable('vault-ldap-credential');
|
||||
|
||||
await visit(urls.newCredentialLibrary);
|
||||
|
||||
await click(selectors.TYPE_VAULT_LDAP);
|
||||
@@ -483,6 +485,13 @@ module('Acceptance | credential-libraries | create', function (hooks) {
|
||||
);
|
||||
});
|
||||
|
||||
test('cannot select vault ldap when feature is disabled', async function (assert) {
|
||||
await visit(urls.newCredentialLibrary);
|
||||
|
||||
assert.false(featuresService.isEnabled('vault-ldap-credential'));
|
||||
assert.dom(selectors.TYPE_VAULT_LDAP).doesNotExist();
|
||||
});
|
||||
|
||||
test('can create a new credential library with username, password and domain type for vault ldap', async function (assert) {
|
||||
setRunOptions({
|
||||
rules: {
|
||||
@@ -493,6 +502,8 @@ module('Acceptance | credential-libraries | create', function (hooks) {
|
||||
},
|
||||
});
|
||||
|
||||
featuresService.enable('vault-ldap-credential');
|
||||
|
||||
const credentialLibraryCount = getCredentialLibraryCount();
|
||||
const usernamePasswordDomainCredentialLibraryCount =
|
||||
getUsernamePasswordDomainCredentialLibraryCount();
|
||||
@@ -545,6 +556,8 @@ module('Acceptance | credential-libraries | create', function (hooks) {
|
||||
},
|
||||
});
|
||||
|
||||
featuresService.enable('vault-ldap-credential');
|
||||
|
||||
await visit(`${urls.newCredentialLibrary}?type=vault-ssh-certificate`);
|
||||
|
||||
assert.dom(selectors.TYPE_VAULT_SSH_CERT).isNotVisible();
|
||||
|
||||
@@ -18,6 +18,7 @@ module('Acceptance | credential-libraries | list', function (hooks) {
|
||||
setupMirage(hooks);
|
||||
setupSqlite(hooks);
|
||||
|
||||
let featuresService;
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
@@ -64,6 +65,7 @@ module('Acceptance | credential-libraries | list', function (hooks) {
|
||||
urls.credentialLibraries = `${urls.credentialStore}/credential-libraries`;
|
||||
urls.vaultLDAPCredentialLibrary = `${urls.credentialLibraries}/${instances.vaultLDAPCredentialLibrary.id}`;
|
||||
await authenticateSession({});
|
||||
featuresService = this.owner.lookup('service:features');
|
||||
});
|
||||
|
||||
test('Users can navigate to credential libraries with proper authorization', async function (assert) {
|
||||
@@ -112,10 +114,19 @@ module('Acceptance | credential-libraries | list', function (hooks) {
|
||||
},
|
||||
});
|
||||
|
||||
featuresService.enable('vault-ldap-credential');
|
||||
await visit(urls.credentialLibraries);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_RESOURCE_LINK(urls.vaultLDAPCredentialLibrary))
|
||||
.isVisible();
|
||||
});
|
||||
|
||||
test('User cannot navigate to vault ldap credential library details when feature is not enabled', async function (assert) {
|
||||
await visit(urls.credentialLibraries);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_RESOURCE_LINK(urls.vaultLDAPCredentialLibrary))
|
||||
.doesNotExist();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user