Preserve connection restriction check order

This commit is contained in:
Asier Isayas
2026-08-27 15:23:24 -04:00
parent 13c9feebd8
commit 465b059b5f
2 changed files with 13 additions and 13 deletions
@@ -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.",
),
).toBeInTheDocument();
expect(mockIsAccountRestricted).not.toHaveBeenCalled();
expect(mockIsAccountRestricted).toHaveBeenCalledWith("not-a-valid-connection-string");
expect(mockFetchEncryptedToken).not.toHaveBeenCalled();
});
@@ -58,6 +58,18 @@ export const ConnectExplorer: React.FunctionComponent<Props> = ({
setIsConnecting(true);
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)) {
setAuthType(AuthType.ResourceToken);
return;
@@ -71,18 +83,6 @@ export const ConnectExplorer: React.FunctionComponent<Props> = ({
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)) {
setAccountMetadata(metadata);
setAuthType(AuthType.ConnectionString);