mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-09-19 09:02:41 +01:00
Add Mongo and Cassandra connection string E2E tests
Add connection-string data-plane coverage for Mongo and Cassandra, including Mongo firewall rejection coverage and the supporting E2E account/command helpers. Remove an unused import left by the merged login error handling.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import { initializeIcons } from "@fluentui/react";
|
import { initializeIcons } from "@fluentui/react";
|
||||||
import { useBoolean } from "@fluentui/react-hooks";
|
import { useBoolean } from "@fluentui/react-hooks";
|
||||||
import { getErrorMessage } from "Common/ErrorHandlingUtils";
|
|
||||||
import { AadAuthorizationFailure } from "Platform/Hosted/Components/AadAuthorizationFailure";
|
import { AadAuthorizationFailure } from "Platform/Hosted/Components/AadAuthorizationFailure";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { render } from "react-dom";
|
import { render } from "react-dom";
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ import { Page, expect, test } from "@playwright/test";
|
|||||||
|
|
||||||
import { CosmosDBManagementClient } from "@azure/arm-cosmosdb";
|
import { CosmosDBManagementClient } from "@azure/arm-cosmosdb";
|
||||||
import {
|
import {
|
||||||
CommandBarButton,
|
CommandBarButton,
|
||||||
DataExplorer,
|
DataExplorer,
|
||||||
ONE_MINUTE_MS,
|
ONE_MINUTE_MS,
|
||||||
TestAccount,
|
TestAccount,
|
||||||
generateUniqueName,
|
generateUniqueName,
|
||||||
getAccountName,
|
getAccountName,
|
||||||
getAzureCLICredentials,
|
getAzureCLICredentials,
|
||||||
resourceGroupName,
|
resourceGroupName,
|
||||||
subscriptionId,
|
subscriptionId,
|
||||||
} from "../fx";
|
} from "../fx";
|
||||||
|
|
||||||
const keyspaceId = generateUniqueName("keyspace");
|
const keyspaceId = generateUniqueName("keyspace");
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export enum TestAccount {
|
|||||||
Cassandra = "Cassandra",
|
Cassandra = "Cassandra",
|
||||||
Gremlin = "Gremlin",
|
Gremlin = "Gremlin",
|
||||||
Mongo = "Mongo",
|
Mongo = "Mongo",
|
||||||
|
MongoConnectionStringPublicNetworkAccessDisabled = "MongoConnectionStringPublicNetworkAccessDisabled",
|
||||||
MongoReadonly = "MongoReadOnly",
|
MongoReadonly = "MongoReadOnly",
|
||||||
Mongo32 = "Mongo32",
|
Mongo32 = "Mongo32",
|
||||||
SQL = "SQL",
|
SQL = "SQL",
|
||||||
@@ -74,6 +75,8 @@ export function getDefaultAccountName(accountType: TestAccount): string {
|
|||||||
return `${accountNamePrefix}-de-test-gremlin-1`;
|
return `${accountNamePrefix}-de-test-gremlin-1`;
|
||||||
case TestAccount.Mongo:
|
case TestAccount.Mongo:
|
||||||
return `${accountNamePrefix}-de-test-mongo-1`;
|
return `${accountNamePrefix}-de-test-mongo-1`;
|
||||||
|
case TestAccount.MongoConnectionStringPublicNetworkAccessDisabled:
|
||||||
|
return `${accountNamePrefix}-de-test-mongo-connstring-nopublic-1`;
|
||||||
case TestAccount.MongoReadonly:
|
case TestAccount.MongoReadonly:
|
||||||
return `${accountNamePrefix}-de-test-mongo-readonly`;
|
return `${accountNamePrefix}-de-test-mongo-readonly`;
|
||||||
case TestAccount.Mongo32:
|
case TestAccount.Mongo32:
|
||||||
@@ -262,6 +265,7 @@ export async function getTestExplorerUrl(accountType: TestAccount, options?: Tes
|
|||||||
|
|
||||||
case TestAccount.SQLConnectionString:
|
case TestAccount.SQLConnectionString:
|
||||||
case TestAccount.SQLConnectionStringPublicNetworkAccessDisabled:
|
case TestAccount.SQLConnectionStringPublicNetworkAccessDisabled:
|
||||||
|
case TestAccount.MongoConnectionStringPublicNetworkAccessDisabled:
|
||||||
case TestAccount.TableConnectionString:
|
case TestAccount.TableConnectionString:
|
||||||
case TestAccount.GremlinConnectionString:
|
case TestAccount.GremlinConnectionString:
|
||||||
// Connection string (account key) login navigates directly to hostedExplorer.html and doesn't
|
// Connection string (account key) login navigates directly to hostedExplorer.html and doesn't
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ import { Page, expect, test } from "@playwright/test";
|
|||||||
|
|
||||||
import { CosmosDBManagementClient } from "@azure/arm-cosmosdb";
|
import { CosmosDBManagementClient } from "@azure/arm-cosmosdb";
|
||||||
import {
|
import {
|
||||||
CommandBarButton,
|
CommandBarButton,
|
||||||
DataExplorer,
|
DataExplorer,
|
||||||
ONE_MINUTE_MS,
|
ONE_MINUTE_MS,
|
||||||
TestAccount,
|
TestAccount,
|
||||||
generateUniqueName,
|
generateUniqueName,
|
||||||
getAccountName,
|
getAccountName,
|
||||||
getAzureCLICredentials,
|
getAzureCLICredentials,
|
||||||
resourceGroupName,
|
resourceGroupName,
|
||||||
subscriptionId,
|
subscriptionId,
|
||||||
} from "../fx";
|
} from "../fx";
|
||||||
|
|
||||||
const databaseId = generateUniqueName("db");
|
const databaseId = generateUniqueName("db");
|
||||||
@@ -143,6 +143,31 @@ test.describe("Mongo account using connection string login", () => {
|
|||||||
await expect(page.locator(".errorDetails")).not.toBeEmpty();
|
await expect(page.locator(".errorDetails")).not.toBeEmpty();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("blocks Data Explorer when the account does not have Portal middleware services' IPs allowlisted", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
const blockedAccountName = getAccountName(TestAccount.MongoConnectionStringPublicNetworkAccessDisabled);
|
||||||
|
const { connectionStrings = [] } = await armClient.databaseAccounts.listConnectionStrings(
|
||||||
|
resourceGroupName,
|
||||||
|
blockedAccountName,
|
||||||
|
);
|
||||||
|
|
||||||
|
const blockedConnectionString = connectionStrings.find((cs) => cs.type === "MongoDB")?.connectionString;
|
||||||
|
if (!blockedConnectionString) {
|
||||||
|
throw new Error(`Account ${blockedAccountName} did not return a MongoDB connection string`);
|
||||||
|
}
|
||||||
|
|
||||||
|
await loginWithConnectionString(page, blockedConnectionString);
|
||||||
|
|
||||||
|
// Unlike SQL, Mongo exchanges the connection string through the Portal Backend before opening
|
||||||
|
// Data Explorer. The account firewall rejects that middleware request, so login remains blocked.
|
||||||
|
await expect(page.locator("#connectExplorer")).toBeVisible();
|
||||||
|
await expect(page.locator(".errorDetails")).toContainText("Couldn't authenticate with Cosmos DB", {
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
});
|
||||||
|
await expect(page.getByRole("link", { name: "Allow access from Azure Portal" })).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
test("shows an error when the connection string is malformed", async ({ page }) => {
|
test("shows an error when the connection string is malformed", async ({ page }) => {
|
||||||
await loginWithConnectionString(page, "this-is-not-a-connection-string");
|
await loginWithConnectionString(page, "this-is-not-a-connection-string");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user