mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-08-30 02:08:40 +01:00
Preserve connection restriction check order
This commit is contained in:
@@ -101,7 +101,7 @@ it("rejects an unrecognized connection string before token exchange", async () =
|
|||||||
"We couldn't recognize this connection string. Verify that it is a valid Azure Cosmos DB connection string and try again.",
|
"We couldn't recognize this connection string. Verify that it is a valid Azure Cosmos DB connection string and try again.",
|
||||||
),
|
),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
expect(mockIsAccountRestricted).not.toHaveBeenCalled();
|
expect(mockIsAccountRestricted).toHaveBeenCalledWith("not-a-valid-connection-string");
|
||||||
expect(mockFetchEncryptedToken).not.toHaveBeenCalled();
|
expect(mockFetchEncryptedToken).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,18 @@ export const ConnectExplorer: React.FunctionComponent<Props> = ({
|
|||||||
setIsConnecting(true);
|
setIsConnecting(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
try {
|
||||||
|
if (await isAccountRestrictedForConnectionStringLogin(connectionString)) {
|
||||||
|
setErrorMessage(
|
||||||
|
"This account has been blocked from connection-string login. Please go to cosmos.azure.com/aad for AAD based login.",
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setErrorMessage(getErrorMessage(error as Error));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isResourceTokenConnectionString(connectionString)) {
|
if (isResourceTokenConnectionString(connectionString)) {
|
||||||
setAuthType(AuthType.ResourceToken);
|
setAuthType(AuthType.ResourceToken);
|
||||||
return;
|
return;
|
||||||
@@ -71,18 +83,6 @@ export const ConnectExplorer: React.FunctionComponent<Props> = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
if (await isAccountRestrictedForConnectionStringLogin(connectionString)) {
|
|
||||||
setErrorMessage(
|
|
||||||
"This account has been blocked from connection-string login. Please go to cosmos.azure.com/aad for AAD based login.",
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
setErrorMessage(getErrorMessage(error as Error));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isDirectConnectionStringLoginApi(metadata.apiKind)) {
|
if (isDirectConnectionStringLoginApi(metadata.apiKind)) {
|
||||||
setAccountMetadata(metadata);
|
setAccountMetadata(metadata);
|
||||||
setAuthType(AuthType.ConnectionString);
|
setAuthType(AuthType.ConnectionString);
|
||||||
|
|||||||
Reference in New Issue
Block a user