mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-04-01 07:28:24 +01:00
Add allowed endpoints to make unit tests pass
This commit is contained in:
parent
899d7459c1
commit
3672da1e1d
@ -8,7 +8,6 @@ import {
|
|||||||
allowedEmulatorEndpoints,
|
allowedEmulatorEndpoints,
|
||||||
allowedGraphEndpoints,
|
allowedGraphEndpoints,
|
||||||
allowedHostedExplorerEndpoints,
|
allowedHostedExplorerEndpoints,
|
||||||
allowedJunoEndpoints,
|
|
||||||
allowedMongoBackendEndpoints,
|
allowedMongoBackendEndpoints,
|
||||||
allowedMsalRedirectEndpoints,
|
allowedMsalRedirectEndpoints,
|
||||||
validateEndpoint,
|
validateEndpoint,
|
||||||
@ -169,12 +168,7 @@ export function updateConfigContext(newContext: Partial<ConfigContext>): void {
|
|||||||
delete newContext.MONGO_BACKEND_ENDPOINT;
|
delete newContext.MONGO_BACKEND_ENDPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (!validateEndpoint(newContext.JUNO_ENDPOINT, configContext.allowedJunoOrigins)) {
|
||||||
!validateEndpoint(
|
|
||||||
newContext.JUNO_ENDPOINT,
|
|
||||||
allowedJunoEndpoints.map((endpoint) => endpoint)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
delete newContext.JUNO_ENDPOINT;
|
delete newContext.JUNO_ENDPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,16 @@ export function validateEndpoint(endpointToValidate: string | undefined, allowed
|
|||||||
if (!endpointToValidate) {
|
if (!endpointToValidate) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const originToValidate: string = new URL(endpointToValidate).origin;
|
const originToValidate: string = new URL(endpointToValidate).origin;
|
||||||
const allowedOrigins: string[] = allowedEndpoints.map((allowedEndpoint) => new URL(allowedEndpoint).origin) || [];
|
const allowedOrigins: string[] = allowedEndpoints.map((allowedEndpoint) => new URL(allowedEndpoint).origin) || [];
|
||||||
return allowedOrigins.indexOf(originToValidate) >= 0;
|
const valid = allowedOrigins.indexOf(originToValidate) >= 0;
|
||||||
|
|
||||||
|
if (!valid) {
|
||||||
|
console.error(`${endpointToValidate} not allowed`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const allowedArmEndpoints: ReadonlyArray<string> = [
|
export const allowedArmEndpoints: ReadonlyArray<string> = [
|
||||||
@ -15,6 +22,17 @@ export const allowedArmEndpoints: ReadonlyArray<string> = [
|
|||||||
|
|
||||||
export const allowedAadEndpoints: ReadonlyArray<string> = ["https://login.microsoftonline.com/"];
|
export const allowedAadEndpoints: ReadonlyArray<string> = ["https://login.microsoftonline.com/"];
|
||||||
|
|
||||||
|
export const allowedBackendEndpoints: ReadonlyArray<string> = [
|
||||||
|
"https://main.documentdb.ext.azure.com",
|
||||||
|
"https://localhost:12901",
|
||||||
|
"https://localhost:1234",
|
||||||
|
];
|
||||||
|
|
||||||
|
export const allowedMongoProxyEndpoints: ReadonlyArray<string> = [
|
||||||
|
"https://main.documentdb.ext.azure.com",
|
||||||
|
"https://localhost:12901",
|
||||||
|
];
|
||||||
|
|
||||||
export const allowedEmulatorEndpoints: ReadonlyArray<string> = [];
|
export const allowedEmulatorEndpoints: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
export const allowedGraphEndpoints: ReadonlyArray<string> = [];
|
export const allowedGraphEndpoints: ReadonlyArray<string> = [];
|
||||||
@ -23,18 +41,12 @@ export const allowedArcadiaEndpoints: ReadonlyArray<string> = [];
|
|||||||
|
|
||||||
export const allowedArcadiaLivyDnsZones: ReadonlyArray<string> = [];
|
export const allowedArcadiaLivyDnsZones: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
export const allowedBackendEndpoints: ReadonlyArray<string> = [];
|
export const allowedMongoBackendEndpoints: ReadonlyArray<string> = [
|
||||||
|
"https://localhost:1234"
|
||||||
export const allowedMongoBackendEndpoints: ReadonlyArray<string> = [];
|
];
|
||||||
|
|
||||||
export const allowedJunoEndpoints: ReadonlyArray<string> = [];
|
|
||||||
|
|
||||||
export const allowedHostedExplorerEndpoints: ReadonlyArray<string> = [];
|
export const allowedHostedExplorerEndpoints: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
export const allowedMsalRedirectEndpoints: ReadonlyArray<string> = [];
|
export const allowedMsalRedirectEndpoints: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
export const allowedMongoProxyEndpoints: ReadonlyArray<string> = [];
|
|
||||||
|
|
||||||
export const allowedPhoenixEndpoints: ReadonlyArray<string> = [];
|
|
||||||
|
|
||||||
export const allowedNotebookServerUrls: ReadonlyArray<string> = [];
|
export const allowedNotebookServerUrls: ReadonlyArray<string> = [];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user