mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
UI: Fix kubernetes auth method role management (#25999)
Co-authored-by: Chelsea Shaw <cshaw@hashicorp.com> Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com>
This commit is contained in:
3
changelog/25999.txt
Normal file
3
changelog/25999.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:bug
|
||||||
|
ui: Fix kubernetes auth method roles tab
|
||||||
|
```
|
||||||
@@ -29,5 +29,10 @@
|
|||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
||||||
<div class="field is-grouped box is-fullwidth is-bottomless">
|
<div class="field is-grouped box is-fullwidth is-bottomless">
|
||||||
<Hds::Button @text="Cancel" @color="secondary" @route="vault.cluster.secrets.backends" />
|
<Hds::Button
|
||||||
|
@text="Cancel"
|
||||||
|
@color="secondary"
|
||||||
|
@route={{if (eq @mountType "secret") "vault.cluster.secrets.backends" "vault.cluster.access.methods"}}
|
||||||
|
data-test-cancel
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -5,6 +5,12 @@
|
|||||||
|
|
||||||
import { helper as buildHelper } from '@ember/component/helper';
|
import { helper as buildHelper } from '@ember/component/helper';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These are all the auth methods that can be mounted.
|
||||||
|
* Some methods may not be available for login via the UI,
|
||||||
|
* which are in the `supported-auth-backends` helper.
|
||||||
|
*/
|
||||||
|
|
||||||
const ENTERPRISE_AUTH_METHODS = [
|
const ENTERPRISE_AUTH_METHODS = [
|
||||||
{
|
{
|
||||||
displayName: 'SAML',
|
displayName: 'SAML',
|
||||||
|
|||||||
@@ -5,6 +5,12 @@
|
|||||||
|
|
||||||
import { helper as buildHelper } from '@ember/component/helper';
|
import { helper as buildHelper } from '@ember/component/helper';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These are all the auth methods with which a user can log into the UI.
|
||||||
|
* This is a subset of the methods found in the `mountable-auth-methods` helper,
|
||||||
|
* which lists all the methods that can be mounted.
|
||||||
|
*/
|
||||||
|
|
||||||
const SUPPORTED_AUTH_BACKENDS = [
|
const SUPPORTED_AUTH_BACKENDS = [
|
||||||
{
|
{
|
||||||
type: 'token',
|
type: 'token',
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
import { helper as buildHelper } from '@ember/component/helper';
|
import { helper as buildHelper } from '@ember/component/helper';
|
||||||
|
|
||||||
const MANAGED_AUTH_BACKENDS = ['cert', 'userpass', 'ldap', 'okta', 'radius'];
|
// The UI supports management of these auth methods (i.e. configuring roles or users)
|
||||||
|
// otherwise only configuration of the method is supported.
|
||||||
|
const MANAGED_AUTH_BACKENDS = ['cert', 'kubernetes', 'ldap', 'okta', 'radius', 'userpass'];
|
||||||
|
|
||||||
export function supportedManagedAuthBackends() {
|
export function supportedManagedAuthBackends() {
|
||||||
return MANAGED_AUTH_BACKENDS;
|
return MANAGED_AUTH_BACKENDS;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
* SPDX-License-Identifier: BUSL-1.1
|
* SPDX-License-Identifier: BUSL-1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* eslint qunit/no-conditional-assertions: "warn" */
|
|
||||||
import { click, fillIn, settled, visit, currentURL } from '@ember/test-helpers';
|
import { click, fillIn, settled, visit, currentURL } from '@ember/test-helpers';
|
||||||
import { module, test } from 'qunit';
|
import { module, test } from 'qunit';
|
||||||
import { setupApplicationTest } from 'ember-qunit';
|
import { setupApplicationTest } from 'ember-qunit';
|
||||||
@@ -11,9 +10,9 @@ import { v4 as uuidv4 } from 'uuid';
|
|||||||
|
|
||||||
import authPage from 'vault/tests/pages/auth';
|
import authPage from 'vault/tests/pages/auth';
|
||||||
import enablePage from 'vault/tests/pages/settings/auth/enable';
|
import enablePage from 'vault/tests/pages/settings/auth/enable';
|
||||||
import { allSupportedAuthBackends, supportedAuthBackends } from 'vault/helpers/supported-auth-backends';
|
|
||||||
import { supportedManagedAuthBackends } from 'vault/helpers/supported-managed-auth-backends';
|
import { supportedManagedAuthBackends } from 'vault/helpers/supported-managed-auth-backends';
|
||||||
import { deleteAuthCmd, mountAuthCmd, runCmd, createNS } from 'vault/tests/helpers/commands';
|
import { deleteAuthCmd, mountAuthCmd, runCmd, createNS } from 'vault/tests/helpers/commands';
|
||||||
|
import { methods } from 'vault/helpers/mountable-auth-methods';
|
||||||
|
|
||||||
const SELECTORS = {
|
const SELECTORS = {
|
||||||
backendLink: (path) => `[data-test-auth-backend-link="${path}"]`,
|
backendLink: (path) => `[data-test-auth-backend-link="${path}"]`,
|
||||||
@@ -75,14 +74,34 @@ module('Acceptance | auth backend list', function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('auth methods are linkable and link to correct view', async function (assert) {
|
test('auth methods are linkable and link to correct view', async function (assert) {
|
||||||
assert.expect(24);
|
assert.expect(45);
|
||||||
const uid = uuidv4();
|
const uid = uuidv4();
|
||||||
await visit('/vault/access');
|
await visit('/vault/access');
|
||||||
|
|
||||||
const supportManaged = supportedManagedAuthBackends();
|
const supportManaged = supportedManagedAuthBackends();
|
||||||
const backends = supportedAuthBackends();
|
// Test all auth methods, not just those you can log in with
|
||||||
for (const backend of backends) {
|
const backends = methods().map((backend) => backend.type);
|
||||||
const { type } = backend;
|
assert.deepEqual(
|
||||||
|
backends,
|
||||||
|
[
|
||||||
|
'alicloud',
|
||||||
|
'approle',
|
||||||
|
'aws',
|
||||||
|
'azure',
|
||||||
|
'gcp',
|
||||||
|
'github',
|
||||||
|
'jwt',
|
||||||
|
'oidc',
|
||||||
|
'kubernetes',
|
||||||
|
'ldap',
|
||||||
|
'okta',
|
||||||
|
'radius',
|
||||||
|
'cert',
|
||||||
|
'userpass',
|
||||||
|
],
|
||||||
|
'non-enterprise auth methods are available'
|
||||||
|
);
|
||||||
|
for (const type of backends) {
|
||||||
const path = type === 'token' ? 'token' : `auth-list-${type}-${uid}`;
|
const path = type === 'token' ? 'token' : `auth-list-${type}-${uid}`;
|
||||||
if (type !== 'token') {
|
if (type !== 'token') {
|
||||||
await enablePage.enable(type, path);
|
await enablePage.enable(type, path);
|
||||||
@@ -122,41 +141,25 @@ module('Acceptance | auth backend list', function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('enterprise: auth methods are linkable and link to correct view', async function (assert) {
|
test('enterprise: auth methods are linkable and link to correct view', async function (assert) {
|
||||||
assert.expect(19);
|
assert.expect(3);
|
||||||
const uid = uuidv4();
|
const uid = uuidv4();
|
||||||
await visit('/vault/access');
|
await visit('/vault/access');
|
||||||
|
|
||||||
const supportManaged = supportedManagedAuthBackends();
|
// Only SAML is enterprise-only for now
|
||||||
const backends = allSupportedAuthBackends();
|
const type = 'saml';
|
||||||
for (const backend of backends) {
|
|
||||||
const { type } = backend;
|
|
||||||
const path = `auth-list-${type}-${uid}`;
|
const path = `auth-list-${type}-${uid}`;
|
||||||
if (type !== 'token') {
|
|
||||||
await enablePage.enable(type, path);
|
await enablePage.enable(type, path);
|
||||||
}
|
|
||||||
await settled();
|
await settled();
|
||||||
await visit('/vault/access');
|
await visit('/vault/access');
|
||||||
|
|
||||||
// all auth methods should be linkable
|
// all auth methods should be linkable
|
||||||
await click(`[data-test-auth-backend-link="${type === 'token' ? type : path}"]`);
|
await click(`[data-test-auth-backend-link="${path}"]`);
|
||||||
if (!supportManaged.includes(type)) {
|
|
||||||
assert.dom('[data-test-auth-section-tab]').exists({ count: 1 });
|
assert.dom('[data-test-auth-section-tab]').exists({ count: 1 });
|
||||||
assert
|
assert
|
||||||
.dom('[data-test-auth-section-tab]')
|
.dom('[data-test-auth-section-tab]')
|
||||||
.hasText('Configuration', `only shows configuration tab for ${type} auth method`);
|
.hasText('Configuration', `only shows configuration tab for ${type} auth method`);
|
||||||
assert.dom('[data-test-doc-link] .doc-link').exists(`includes doc link for ${type} auth method`);
|
assert.dom('[data-test-doc-link] .doc-link').exists(`includes doc link for ${type} auth method`);
|
||||||
} else {
|
|
||||||
let expectedTabs = 2;
|
|
||||||
if (type == 'ldap' || type === 'okta') {
|
|
||||||
expectedTabs = 3;
|
|
||||||
}
|
|
||||||
assert
|
|
||||||
.dom('[data-test-auth-section-tab]')
|
|
||||||
.exists({ count: expectedTabs }, `has management tabs for ${type} auth method`);
|
|
||||||
// cleanup method
|
|
||||||
await runCmd(deleteAuthCmd(path));
|
await runCmd(deleteAuthCmd(path));
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('enterprise: token config within namespace', async function (assert) {
|
test('enterprise: token config within namespace', async function (assert) {
|
||||||
|
|||||||
Reference in New Issue
Block a user