mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-06 06:37: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',
|
||||
'custom-messages',
|
||||
'api',
|
||||
'store',
|
||||
'capabilities',
|
||||
],
|
||||
},
|
||||
|
@ -29,9 +29,9 @@
|
||||
{{rule.name}}
|
||||
</Hds::Text::Display>
|
||||
<div class="has-top-margin-m">
|
||||
{{rule.namespacePath}}
|
||||
{{rule.namespace_path}}
|
||||
<Hds::Badge
|
||||
@text="Inheritance {{if rule.disableInheritance 'disabled' 'enabled'}}"
|
||||
@text="Inheritance {{if rule.disable_inheritance 'disabled' 'enabled'}}"
|
||||
class="has-left-margin-xxs"
|
||||
/>
|
||||
</div>
|
||||
|
@ -25,6 +25,7 @@ export default class ConfigUiEngine extends Engine {
|
||||
'version',
|
||||
'custom-messages',
|
||||
'api',
|
||||
'store',
|
||||
'capabilities',
|
||||
],
|
||||
};
|
||||
|
@ -8,20 +8,23 @@ import { service } from '@ember/service';
|
||||
|
||||
export default class LoginSettingsRoute extends Route {
|
||||
@service api;
|
||||
@service store;
|
||||
|
||||
async model() {
|
||||
const adapter = this.store.adapterFor('application');
|
||||
try {
|
||||
const res = await this.api.sys.uiLoginDefaultAuthList(true);
|
||||
const loginRules = this.api.keyInfoToArray({ keyInfo: res.keyInfo, keys: res.keys });
|
||||
const { data } = await adapter.ajax('/v1/sys/config/ui/login/default-auth', 'GET', {
|
||||
data: { list: true },
|
||||
});
|
||||
const loginRules = this.api.keyInfoToArray({ keyInfo: data.key_info, keys: data.keys });
|
||||
return { loginRules };
|
||||
} catch (e) {
|
||||
const error = await this.api.parseError(e);
|
||||
if (error.status === 404) {
|
||||
if (e.httpStatus === 404) {
|
||||
// If no login settings exist, return an empty array to render the empty state
|
||||
return { loginRules: [] };
|
||||
}
|
||||
// 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) {
|
||||
this.server.get('/sys/config/ui/login/default-auth', () => overrideResponse(403));
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user