UI: MFA methods now display namespace_path instead of namespace_id (#29588)

* update mfa methods to use namespace_path instead of namespace_id

* add test for empty namespace path and add namespace path to factories

* add changelog entry

* fix name

* hide namespace label when path is empty and test updates
This commit is contained in:
lane-wetmore
2025-02-13 15:16:34 -06:00
committed by GitHub
parent db0d911683
commit 4b05b590f5
9 changed files with 29 additions and 13 deletions

3
changelog/29588.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
ui: MFA methods now display the namespace path instead of the namespace id.
```

View File

@@ -58,7 +58,7 @@ export default class MfaMethod extends Model {
@attr('string', {
label: 'Namespace',
})
namespace_id;
namespace_path;
@attr('string') mount_accessor;
// PING ID

View File

@@ -17,12 +17,14 @@
{{@model.name}}
</span>
<Hds::Badge @text={{@model.id}} class="has-left-margin-xs" />
<div class="has-top-margin-xs">
<code class="is-size-9">
Namespace:
{{@model.namespace_id}}
</code>
</div>
{{#if @model.namespace_path}}
<div class="has-top-margin-xs">
<code class="is-size-9">
Namespace:
{{@model.namespace_path}}
</code>
</div>
{{/if}}
</div>
</div>
</div>

View File

@@ -9,7 +9,7 @@ export default Factory.extend({
api_hostname: 'api-foobar.duosecurity.com',
mount_accessor: '',
name: '', // returned but cannot be set at this time
namespace_id: 'root',
namespace_path: '', // the root namespace returns an empty string for the path
pushinfo: '',
type: 'duo',
use_passcode: false,

View File

@@ -9,7 +9,7 @@ export default Factory.extend({
base_url: 'okta.com',
mount_accessor: '',
name: '', // returned but cannot be set at this time
namespace_id: 'root',
namespace_path: 'admin/',
org_name: 'dev-foobar',
type: 'okta',
username_template: '', // returned but cannot be set at this time

View File

@@ -13,5 +13,5 @@ export default Factory.extend({
org_alias: 'foobarbaz',
type: 'pingid',
username_template: '',
namespace_id: 'root',
namespace_path: 'admin/',
});

View File

@@ -12,7 +12,7 @@ export default Factory.extend({
key_size: 20,
max_validation_attempts: 5,
name: '', // returned but cannot be set at this time
namespace_id: 'root',
namespace_path: 'admin/',
period: 30,
qr_size: 200,
skew: 1,

View File

@@ -171,7 +171,7 @@ module('Acceptance | mfa-login-enforcement', function (hooks) {
assert
.dom(`[data-test-mfa-method-list-item="${method.id}"]`)
.includesText(
`${method.name} ${method.id} Namespace: ${method.namespace_id}`,
`${method.name} ${method.id} Namespace: ${method.namespace_path}`,
'Method list item renders'
);
await click('[data-test-popup-menu-trigger]');

View File

@@ -66,7 +66,7 @@ module('Acceptance | mfa-method', function (hooks) {
assert
.dom(`[data-test-mfa-method-list-item="${model.id}"]`)
.includesText(
`${model.name} ${model.id} Namespace: ${model.namespace_id}`,
`${model.name} ${model.id} Namespace: ${model.namespace_path}`,
'Copy renders for list item'
);
@@ -87,6 +87,17 @@ module('Acceptance | mfa-method', function (hooks) {
);
});
test('it should not display for the root namespace', async function (assert) {
await visit('/vault/access/mfa');
const methods = this.getMethods();
const duoModel = this.store.peekRecord('mfa-method', methods[1].id);
assert.strictEqual(duoModel.namespace_path, '', 'Namespace path is unset');
assert
.dom(`[data-test-mfa-method-list-item="${duoModel.id}"]`)
.includesText(`${duoModel.name} ${duoModel.id}`, 'Copy renders for list item without namespace path')
.doesNotContainText('Namespace:', 'Does not include the namespace label');
});
test('it should display method details', async function (assert) {
// ensure methods are tied to an enforcement
this.server.get('/identity/mfa/login-enforcement', () => {