Add an E2E test that SQL connection string login skips the Portal Backend

Nothing asserted the defining behavior of the direct login path, so reverting the short-circuit in connectWithConnectionString would have gone unnoticed. The listener filters on the connectionstring route so it covers both generatetoken and accessinputmetadata, and leaves the account restriction check alone since that still runs for every API.
This commit is contained in:
Asier Isayas
2026-08-19 16:01:41 -07:00
parent adc28d8082
commit 3005ebd02d
3 changed files with 20 additions and 4 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ const App: React.FunctionComponent = () => {
// For handling encrypted portal tokens sent via query paramter // For handling encrypted portal tokens sent via query paramter
const params = new URLSearchParams(window.location.search); const params = new URLSearchParams(window.location.search);
const [encryptedToken, setEncryptedToken] = React.useState<string>(params && params.get("key")); const [encryptedToken, setEncryptedToken] = React.useState<string>(params && params.get("key"));
// Encrypted token logins resolve the account metadata through the Portal Backend, while SQL/Tables/Gremlin // Encrypted token logins resolve the account metadata through the Portal Backend, while SQL/Table/Gremlin
// connection-string logins derive it client-side, so both paths write to the same value. // connection-string logins derive it client-side, so both paths write to the same value.
const [accountMetadata, setAccountMetadata] = React.useState<AccessInputMetadata>(); const [accountMetadata, setAccountMetadata] = React.useState<AccessInputMetadata>();
@@ -85,9 +85,6 @@ describe("ConnectionStringParser", () => {
expect(metadata.accountName).toBe(mockAccountName); expect(metadata.accountName).toBe(mockAccountName);
expect(metadata.apiKind).toBe(DataModels.ApiKind.Cassandra); expect(metadata.apiKind).toBe(DataModels.ApiKind.Cassandra);
// Cassandra still uses the Portal Backend proxy, so no client-side endpoints are constructed.
expect(metadata.documentEndpoint).toBeUndefined();
expect(metadata.apiEndpoint).toBeUndefined();
}); });
it("should fail to parse an invalid connection string", () => { it("should fail to parse an invalid connection string", () => {
+19
View File
@@ -83,6 +83,25 @@ test.describe("SQL account using connection string login", () => {
expect(resultData?.id).toEqual(documentId); expect(resultData?.id).toEqual(documentId);
}); });
test("does not call the Portal Backend during login", async ({ page }) => {
// SQL derives the account metadata from the connection string and signs data-plane requests with the
// account key, so neither the encrypted token nor the access metadata endpoint should be hit.
const portalBackendCalls: string[] = [];
page.on("request", (request) => {
if (request.url().includes("/api/connectionstring/")) {
portalBackendCalls.push(request.url());
}
});
await loginWithConnectionString(page, connectionString);
const explorer = await DataExplorer.waitForExplorer(page);
const collectionNode = await explorer.waitForContainerNode(databaseId, containerId);
await expect(collectionNode.element).toBeAttached();
expect(portalBackendCalls).toEqual([]);
});
test("opens Data Explorer when the connection string has the wrong account key", async ({ page }) => { test("opens Data Explorer when the connection string has the wrong account key", async ({ page }) => {
// A well-formed but incorrect base64 account key. The login is accepted // A well-formed but incorrect base64 account key. The login is accepted
// without checking the key against the account, so the user gets into Data Explorer either way and // without checking the key against the account, so the user gets into Data Explorer either way and