Improve ordering to minimize diff

This commit is contained in:
Joseph Garrone 2024-12-15 12:28:09 +01:00
parent 295994d02a
commit df338ed6a0

View File

@ -49,6 +49,8 @@ export function prepareRealmConfig(params: {
} }
parsedRealmJson.eventsListeners.push(name); parsedRealmJson.eventsListeners.push(name);
parsedRealmJson.eventsListeners.sort();
} }
return { return {
@ -146,6 +148,10 @@ function addOrEditTestUser(params: {
(newUser.clientRoles[clientName] ??= []).push(clientRole.name); (newUser.clientRoles[clientName] ??= []).push(clientRole.name);
} }
for (const clientName of Object.keys(newUser.clientRoles)) {
newUser.clientRoles[clientName].sort().reverse();
}
} }
if (defaultUser_preexisting === undefined) { if (defaultUser_preexisting === undefined) {
@ -228,39 +234,40 @@ function addOrEditClient(params: {
parsedRealmJson.clients.push(testClient); parsedRealmJson.clients.push(testClient);
} }
{ for (const redirectUri of [
for (const redirectUri of [ `${TEST_APP_URL}/*`,
`${TEST_APP_URL}/*`, "http://localhost*",
"http://localhost*", "http://127.0.0.1*"
"http://127.0.0.1*" ]) {
]) { for (const propertyName of ["webOrigins", "redirectUris"] as const) {
for (const propertyName of ["webOrigins", "redirectUris"] as const) { const arr = (testClient[propertyName] ??= []);
const arr = (testClient[propertyName] ??= []);
if (arr.includes(redirectUri)) { if (arr.includes(redirectUri)) {
continue; continue;
}
arr.push(redirectUri);
} }
{ arr.push(redirectUri);
if (testClient.attributes === undefined) { }
testClient.attributes = {};
}
const arr = (testClient.attributes["post.logout.redirect.uris"] ?? "") {
.split("##") if (testClient.attributes === undefined) {
.map(s => s.trim()); testClient.attributes = {};
}
if (!arr.includes(redirectUri)) { const arr = (testClient.attributes["post.logout.redirect.uris"] ?? "")
arr.push(redirectUri); .split("##")
testClient.attributes["post.logout.redirect.uris"] = arr.join("##"); .map(s => s.trim());
}
if (!arr.includes(redirectUri)) {
arr.push(redirectUri);
testClient.attributes["post.logout.redirect.uris"] = arr.join("##");
} }
} }
} }
testClient.webOrigins?.sort().reverse();
testClient.redirectUris?.sort().reverse();
return { clientId: testClient.clientId }; return { clientId: testClient.clientId };
} }
@ -276,37 +283,38 @@ function editAccountConsoleAndSecurityAdminConsole(params: {
assert(client !== undefined); assert(client !== undefined);
{ for (const redirectUri of [
for (const redirectUri of [ `${TEST_APP_URL}/*`,
`${TEST_APP_URL}/*`, "http://localhost*",
"http://localhost*", "http://127.0.0.1*"
"http://127.0.0.1*" ]) {
]) { for (const propertyName of ["webOrigins", "redirectUris"] as const) {
for (const propertyName of ["webOrigins", "redirectUris"] as const) { const arr = (client[propertyName] ??= []);
const arr = (client[propertyName] ??= []);
if (arr.includes(redirectUri)) { if (arr.includes(redirectUri)) {
continue; continue;
}
arr.push(redirectUri);
} }
{ arr.push(redirectUri);
if (client.attributes === undefined) { }
client.attributes = {};
}
const arr = (client.attributes["post.logout.redirect.uris"] ?? "") {
.split("##") if (client.attributes === undefined) {
.map(s => s.trim()); client.attributes = {};
}
if (!arr.includes(redirectUri)) { const arr = (client.attributes["post.logout.redirect.uris"] ?? "")
arr.push(redirectUri); .split("##")
client.attributes["post.logout.redirect.uris"] = arr.join("##"); .map(s => s.trim());
}
if (!arr.includes(redirectUri)) {
arr.push(redirectUri);
client.attributes["post.logout.redirect.uris"] = arr.join("##");
} }
} }
} }
client.webOrigins?.sort().reverse();
client.redirectUris?.sort().reverse();
} }
} }