mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
Merge pull request #10982 from keithjgrant/json-deterministic-order
Ensure deterministic order of JSON serializing for misc auth settings
This commit is contained in:
commit
30cf483357
@ -91,7 +91,7 @@ describe('<LDAPDetail />', () => {
|
||||
assertVariableDetail(
|
||||
wrapper,
|
||||
'LDAP Group Type Parameters',
|
||||
'{\n "name_attr": "cn",\n "member_attr": "member"\n}'
|
||||
'{\n "member_attr": "member",\n "name_attr": "cn"\n}'
|
||||
);
|
||||
assertVariableDetail(wrapper, 'LDAP User Flags By Group', '{}');
|
||||
assertVariableDetail(wrapper, 'LDAP Organization Map', '{}');
|
||||
|
||||
@ -68,7 +68,7 @@ describe('<MiscAuthenticationDetail />', () => {
|
||||
assertVariableDetail(
|
||||
wrapper,
|
||||
'OAuth 2 Timeout Settings',
|
||||
'{\n "ACCESS_TOKEN_EXPIRE_SECONDS": 31536000000,\n "REFRESH_TOKEN_EXPIRE_SECONDS": 2628000,\n "AUTHORIZATION_CODE_EXPIRE_SECONDS": 600\n}'
|
||||
'{\n "ACCESS_TOKEN_EXPIRE_SECONDS": 31536000000,\n "AUTHORIZATION_CODE_EXPIRE_SECONDS": 600,\n "REFRESH_TOKEN_EXPIRE_SECONDS": 2628000\n}'
|
||||
);
|
||||
assertDetail(wrapper, 'Login redirect override URL', 'https://foohost');
|
||||
assertVariableDetail(
|
||||
|
||||
@ -4,6 +4,19 @@ import { t } from '@lingui/macro';
|
||||
import { Detail } from 'components/DetailList';
|
||||
import CodeDetail from 'components/DetailList/CodeDetail';
|
||||
|
||||
function sortObj(obj) {
|
||||
if (typeof obj !== 'object' || Array.isArray(obj)) {
|
||||
return obj;
|
||||
}
|
||||
const sorted = {};
|
||||
Object.keys(obj)
|
||||
.sort()
|
||||
.forEach((key) => {
|
||||
sorted[key] = sortObj(obj[key]);
|
||||
});
|
||||
return sorted;
|
||||
}
|
||||
|
||||
export default ({ helpText, id, label, type, unit = '', value }) => {
|
||||
const dataType = value === '$encrypted$' ? 'encrypted' : type;
|
||||
let detail = null;
|
||||
@ -17,7 +30,7 @@ export default ({ helpText, id, label, type, unit = '', value }) => {
|
||||
label={label}
|
||||
mode="javascript"
|
||||
rows={4}
|
||||
value={JSON.stringify(value || {}, undefined, 2)}
|
||||
value={JSON.stringify(sortObj(value || {}), undefined, 2)}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user