mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-06 22:57:02 +02:00
UI: Fix login settings list view if names include an underscore (#31150)
* revert api service use in login settings list view * add changelog * update list view * update error text assertion * restart tests
This commit is contained in:
parent
571786f425
commit
ab830995b2
3
changelog/31150.txt
Normal file
3
changelog/31150.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
```release-note:bug
|
||||||
|
ui: Fixes UI login settings list page which was not rendering rules with an underscore in the name.
|
||||||
|
```
|
@ -24,6 +24,7 @@ export default class App extends Application {
|
|||||||
'version',
|
'version',
|
||||||
'custom-messages',
|
'custom-messages',
|
||||||
'api',
|
'api',
|
||||||
|
'store',
|
||||||
'capabilities',
|
'capabilities',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -29,9 +29,9 @@
|
|||||||
{{rule.name}}
|
{{rule.name}}
|
||||||
</Hds::Text::Display>
|
</Hds::Text::Display>
|
||||||
<div class="has-top-margin-m">
|
<div class="has-top-margin-m">
|
||||||
{{rule.namespacePath}}
|
{{rule.namespace_path}}
|
||||||
<Hds::Badge
|
<Hds::Badge
|
||||||
@text="Inheritance {{if rule.disableInheritance 'disabled' 'enabled'}}"
|
@text="Inheritance {{if rule.disable_inheritance 'disabled' 'enabled'}}"
|
||||||
class="has-left-margin-xxs"
|
class="has-left-margin-xxs"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -25,6 +25,7 @@ export default class ConfigUiEngine extends Engine {
|
|||||||
'version',
|
'version',
|
||||||
'custom-messages',
|
'custom-messages',
|
||||||
'api',
|
'api',
|
||||||
|
'store',
|
||||||
'capabilities',
|
'capabilities',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
@ -8,20 +8,23 @@ import { service } from '@ember/service';
|
|||||||
|
|
||||||
export default class LoginSettingsRoute extends Route {
|
export default class LoginSettingsRoute extends Route {
|
||||||
@service api;
|
@service api;
|
||||||
|
@service store;
|
||||||
|
|
||||||
async model() {
|
async model() {
|
||||||
|
const adapter = this.store.adapterFor('application');
|
||||||
try {
|
try {
|
||||||
const res = await this.api.sys.uiLoginDefaultAuthList(true);
|
const { data } = await adapter.ajax('/v1/sys/config/ui/login/default-auth', 'GET', {
|
||||||
const loginRules = this.api.keyInfoToArray({ keyInfo: res.keyInfo, keys: res.keys });
|
data: { list: true },
|
||||||
|
});
|
||||||
|
const loginRules = this.api.keyInfoToArray({ keyInfo: data.key_info, keys: data.keys });
|
||||||
return { loginRules };
|
return { loginRules };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const error = await this.api.parseError(e);
|
if (e.httpStatus === 404) {
|
||||||
if (error.status === 404) {
|
|
||||||
// If no login settings exist, return an empty array to render the empty state
|
// If no login settings exist, return an empty array to render the empty state
|
||||||
return { loginRules: [] };
|
return { loginRules: [] };
|
||||||
}
|
}
|
||||||
// Otherwise fallback to the standard error template
|
// Otherwise fallback to the standard error template
|
||||||
throw error;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,11 @@ module('Acceptance | Enterprise | config-ui/login-settings', function (hooks) {
|
|||||||
test('it falls back error template if no permission', async function (assert) {
|
test('it falls back error template if no permission', async function (assert) {
|
||||||
this.server.get('/sys/config/ui/login/default-auth', () => overrideResponse(403));
|
this.server.get('/sys/config/ui/login/default-auth', () => overrideResponse(403));
|
||||||
await visit('vault/config-ui/login-settings');
|
await visit('vault/config-ui/login-settings');
|
||||||
assert.dom(GENERAL.pageError.error).hasText('Error permission denied');
|
assert
|
||||||
|
.dom(GENERAL.pageError.error)
|
||||||
|
.hasText(
|
||||||
|
'Not authorized You are not authorized to access content at /v1/sys/config/ui/login/default-auth.'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
module('list, read and delete', function (hooks) {
|
module('list, read and delete', function (hooks) {
|
||||||
|
Loading…
Reference in New Issue
Block a user