Skip to content
Merged
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
4 changes: 2 additions & 2 deletions packages/durabletask-js-azuremanaged/src/connection-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class DurableTaskAzureManagedConnectionString {
}

private getValue(name: string): string | undefined {
return this.properties.get(name);
return this.properties.get(name.toLowerCase());
}

private getRequiredValue(name: string): string {
Expand All @@ -108,7 +108,7 @@ export class DurableTaskAzureManagedConnectionString {
if (equalsIndex > 0) {
const key = pair.substring(0, equalsIndex).trim();
const value = pair.substring(equalsIndex + 1).trim();
properties.set(key, value);
properties.set(key.toLowerCase(), value);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,46 @@ describe("DurableTaskAzureManagedConnectionString", () => {
"The connection string must contain a TaskHub property",
);
});

it("should parse connection string with all-lowercase keys", () => {
const connectionString = new DurableTaskAzureManagedConnectionString(
"endpoint=https://example.com;authentication=ManagedIdentity;taskhub=myTaskHub",
);

expect(connectionString.getEndpoint()).toBe("https://example.com");
expect(connectionString.getAuthentication()).toBe("ManagedIdentity");
expect(connectionString.getTaskHubName()).toBe("myTaskHub");
});

it("should parse connection string with all-uppercase keys", () => {
const connectionString = new DurableTaskAzureManagedConnectionString(
"ENDPOINT=https://example.com;AUTHENTICATION=ManagedIdentity;TASKHUB=myTaskHub",
);

expect(connectionString.getEndpoint()).toBe("https://example.com");
expect(connectionString.getAuthentication()).toBe("ManagedIdentity");
expect(connectionString.getTaskHubName()).toBe("myTaskHub");
});

it("should parse connection string with mixed-case keys", () => {
const connectionString = new DurableTaskAzureManagedConnectionString(
"endPoint=https://example.com;AUTHENTICATION=ManagedIdentity;taskHub=myTaskHub",
);

expect(connectionString.getEndpoint()).toBe("https://example.com");
expect(connectionString.getAuthentication()).toBe("ManagedIdentity");
expect(connectionString.getTaskHubName()).toBe("myTaskHub");
});

it("should preserve value casing with case-insensitive keys", () => {
const connectionString = new DurableTaskAzureManagedConnectionString(
"endpoint=https://MyHost.example.com;authentication=ManagedIdentity;taskhub=MyTaskHub;clientid=My-Client-ID",
);

expect(connectionString.getEndpoint()).toBe("https://MyHost.example.com");
expect(connectionString.getTaskHubName()).toBe("MyTaskHub");
expect(connectionString.getClientId()).toBe("My-Client-ID");
});
});

describe("getAdditionallyAllowedTenants", () => {
Expand All @@ -87,6 +127,16 @@ describe("DurableTaskAzureManagedConnectionString", () => {

expect(connectionString.getAdditionallyAllowedTenants()).toBeUndefined();
});

it("should match property name case-insensitively", () => {
const connectionStringWithTenants =
VALID_CONNECTION_STRING + ";additionallyallowedtenants=tenant1,tenant2";

const connectionString = new DurableTaskAzureManagedConnectionString(connectionStringWithTenants);
const tenants = connectionString.getAdditionallyAllowedTenants();

expect(tenants).toEqual(["tenant1", "tenant2"]);
});
});

describe("getClientId", () => {
Expand Down
Loading