Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"id": "55555555-5555-4555-8555-555555555555",
"displayLabel": "Neptune with IAM (v1.5)",
"connection": {
"url": "https://proxy.example.com",
"queryEngine": "gremlin",
"proxyConnection": true,
"graphDbUrl": "https://neptune.example.com:8182",
"awsAuthEnabled": true,
"awsRegion": "us-west-2"
},
"schema": {
"vertices": [
{
"type": "airport",
"displayLabel": "airport",
"total": 3,
"attributes": [
{ "name": "code", "displayLabel": "code", "dataType": "String" }
]
}
],
"edges": [
{
"type": "route",
"displayLabel": "route",
"total": 2,
"attributes": [
{ "name": "dist", "displayLabel": "dist", "dataType": "Number" }
]
}
],
"lastUpdate": "2024-01-01T12:30:00.000Z"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"id": "66666666-6666-4666-8666-666666666666",
"displayLabel": "Neptune with IAM (v3.2.2)",
"connection": {
"url": "https://proxy.example.com",
"queryEngine": "gremlin",
"proxyConnection": true,
"awsAuthEnabled": true,
"serviceType": "neptune-db",
"awsRegion": "us-west-2",
"graphDbUrl": "https://neptune.example.com:8182"
},
"schema": {
"vertices": [
{
"type": "airport",
"attributes": [{ "name": "code", "dataType": "String" }],
"total": 3
}
],
"edges": [
{
"type": "route",
"attributes": [{ "name": "dist", "dataType": "Number" }],
"total": 2
}
],
"lastUpdate": "2024-01-01T12:30:00.000Z"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "77777777-7777-4777-8777-777777777777",
"displayLabel": "Neptune without IAM (v3.2.2)",
"connection": {
"url": "https://proxy.example.com",
"queryEngine": "gremlin",
"proxyConnection": true,
"awsAuthEnabled": false,
"serviceType": "neptune-db",
"awsRegion": "",
"graphDbUrl": "https://neptune.example.com:8182"
},
"schema": {
"vertices": [],
"edges": []
}
}
6 changes: 1 addition & 5 deletions packages/graph-explorer/src/connections/activeConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ export const activeConnectionAtom = atom(get => {
});

export const queryEngineSelector = atom(get =>
get(
selectAtom(activeConnectionAtom, c =>
c && c.queryEngine ? c.queryEngine : "gremlin",
),
),
get(selectAtom(activeConnectionAtom, c => c?.queryEngine ?? "gremlin")),
);

export function useQueryEngine() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ConfigurationContextProps } from "@/core/StateProvider/typeConfigT
import type { IriNamespace, RdfPrefix } from "@/utils/rdf";

import { createEdgeType, createVertexType } from "@/core/entities";
import { logger } from "@/utils";
import { stubDocumentUrl } from "@/utils/testing";
import { exportConnectionFileText } from "@/utils/testing/exportConnectionFileText";

Expand All @@ -15,6 +16,9 @@ import exportGoldenLegacyUrlProxy from "./__fixtures__/connection-file-export-go
import exportGoldenWithoutUrl from "./__fixtures__/connection-file-export-golden.txt?raw";
import legacyUrlDirect from "./__fixtures__/connection-file-legacy-url-direct.json?raw";
import legacyUrlProxy from "./__fixtures__/connection-file-legacy-url-proxy.json?raw";
import v1_5IamWithoutServiceType from "./__fixtures__/connection-file-v1.5-iam-without-service-type.json?raw";
import v3_2_2IamProxy from "./__fixtures__/connection-file-v3.2.2-iam-proxy.json?raw";
import v3_2_2ProxyIamOff from "./__fixtures__/connection-file-v3.2.2-proxy-iam-off.json?raw";
import { parseConnectionFile } from "./parseConnectionFile";

/**
Expand All @@ -28,6 +32,10 @@ import { parseConnectionFile } from "./parseConnectionFile";
* including the pre-unified-proxy `url`/`proxyConnection` form and legacy
* pass-through keys (`__inferred`, `dataType`), and the file `main` wrote
* between #1773 and #2315 with no `url` (`connection-file-export-golden.txt`).
* The `connection-file-v*` fixtures pin the IAM fields as tagged releases
* wrote them: v1.0.0 to v1.5.x wrote `awsAuthEnabled` and `awsRegion` with no
* `serviceType`, and v3.2.2 wrote every proxy connection with `serviceType`
* and `awsRegion`, even with IAM off.
* The export cases compare the writer's output byte-for-byte against the
* `connection-file-export-golden-legacy-url-*.txt` fixtures, so any change to
* the wire format — values, field order, or whitespace — is caught here rather
Expand Down Expand Up @@ -87,6 +95,62 @@ describe("golden Exported Connection Files import on the current build", () => {
expect(connection.proxyConnection).toBe(true);
});

test("v1.5 IAM connection without serviceType keeps IAM on without a warning", () => {
const parsed = parseConnectionFile(JSON.parse(v1_5IamWithoutServiceType));

expect(parsed?.connection).toStrictEqual({
url: "https://proxy.example.com",
queryEngine: "gremlin",
proxyConnection: true,
graphDbUrl: "https://neptune.example.com:8182",
awsAuthEnabled: true,
awsRegion: "us-west-2",
});
expect(logger.warn).not.toHaveBeenCalled();

// v1.5 schema sync wrote displayLabel and total on each type.
expect(parsed?.schema.vertices).toStrictEqual([
{
type: createVertexType("airport"),
displayLabel: "airport",
total: 3,
attributes: [
{ name: "code", displayLabel: "code", dataType: "String" },
],
},
]);
});

test("v3.2.2 IAM proxy connection keeps IAM on without a warning", () => {
const parsed = parseConnectionFile(JSON.parse(v3_2_2IamProxy));

expect(parsed?.connection).toStrictEqual({
url: "https://proxy.example.com",
queryEngine: "gremlin",
proxyConnection: true,
awsAuthEnabled: true,
serviceType: "neptune-db",
awsRegion: "us-west-2",
graphDbUrl: "https://neptune.example.com:8182",
});
expect(logger.warn).not.toHaveBeenCalled();
});

test("v3.2.2 proxy connection with IAM off keeps its empty awsRegion and serviceType", () => {
const parsed = parseConnectionFile(JSON.parse(v3_2_2ProxyIamOff));

expect(parsed?.connection).toStrictEqual({
url: "https://proxy.example.com",
queryEngine: "gremlin",
proxyConnection: true,
awsAuthEnabled: false,
serviceType: "neptune-db",
awsRegion: "",
graphDbUrl: "https://neptune.example.com:8182",
});
expect(logger.warn).not.toHaveBeenCalled();
});

test("legacy direct connection with only url and no graphDbUrl", () => {
const parsed = parseConnectionFile(JSON.parse(legacyUrlDirect));

Expand Down
12 changes: 8 additions & 4 deletions packages/graph-explorer/src/connections/defaultConnection.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ConnectionConfig } from "@shared/types";

import { neptuneServiceTypeOptions, queryEngineOptions } from "@shared/types";
import { z } from "zod";

Expand Down Expand Up @@ -36,7 +38,7 @@ export type DefaultConnectionData = z.infer<typeof DefaultConnectionDataSchema>;
* on failure. Throws `ReverseProxyMisconfiguredError` when the API URL can't
* be resolved from the page's path.
*/
export async function fetchDefaultConnection() {
export async function fetchDefaultConnection(): Promise<SavedConnection[]> {
const url = apiUrl("defaultConnection");
try {
const defaultConnection = await fetchDefaultConnectionFor(url);
Expand All @@ -47,7 +49,7 @@ export async function fetchDefaultConnection() {

const config = mapToConnection(defaultConnection);

if (config.connection?.queryEngine) {
if (config.connection.queryEngine) {
return [config];
}

Expand All @@ -59,7 +61,7 @@ export async function fetchDefaultConnection() {
...config.connection,
queryEngine: queryEngine,
},
} as SavedConnection;
};
});

return configs;
Expand Down Expand Up @@ -105,7 +107,9 @@ export async function fetchDefaultConnectionFor(
}
}

export function mapToConnection(data: DefaultConnectionData): SavedConnection {
export function mapToConnection(
data: DefaultConnectionData,
): SavedConnection & { connection: ConnectionConfig } {
return {
id: "Default Connection" as ConnectionId,
displayLabel: "Default Connection",
Expand Down
Loading
Loading