Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/29588.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: MFA methods now display the namespace path instead of the namespace id.
```
2 changes: 1 addition & 1 deletion ui/app/models/mfa-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default class MfaMethod extends Model {
@attr('string', {
label: 'Namespace',
})
namespace_id;
namespace_path;
@attr('string') mount_accessor;

// PING ID
Expand Down
14 changes: 8 additions & 6 deletions ui/app/templates/components/mfa/method-list-item.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion ui/mirage/factories/mfa-duo-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ui/mirage/factories/mfa-okta-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ui/mirage/factories/mfa-pingid-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export default Factory.extend({
org_alias: 'foobarbaz',
type: 'pingid',
username_template: '',
namespace_id: 'root',
namespace_path: 'admin/',
});
2 changes: 1 addition & 1 deletion ui/mirage/factories/mfa-totp-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ui/tests/acceptance/mfa-login-enforcement-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]');
Expand Down
13 changes: 12 additions & 1 deletion ui/tests/acceptance/mfa-method-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);

Expand All @@ -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', () => {
Expand Down
Loading