Skip to content

Commit 75c4310

Browse files
committed
update
1 parent d3e6ff2 commit 75c4310

6 files changed

Lines changed: 6 additions & 70 deletions

File tree

‎test/integration/featureFlag.test.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { assert } from "chai";
66
import { DefaultAzureCredential } from "@azure/identity";
77
import { load } from "../../src/index.js";
88
import type { AzureAppConfiguration } from "../../src/index.js";
9-
import { createNotModifiedResponseTracker, getIntegrationTestEndpoint, IntegrationTestContext, REFRESH_INTERVAL_IN_MS, refreshUntil } from "./helpers.js";
9+
import { createNotModifiedResponseTracker, INTEGRATION_TEST_ENDPOINT as endpoint, IntegrationTestContext, REFRESH_INTERVAL_IN_MS, refreshUntil } from "./helpers.js";
1010

1111
interface FeatureFlag {
1212
id: string;
@@ -28,12 +28,10 @@ function getFeatureFlags(settings: AzureAppConfiguration): FeatureFlag[] {
2828
}
2929

3030
describe("integration: feature flags", function () {
31-
let endpoint: string;
3231
let credential: DefaultAzureCredential;
3332
let context: IntegrationTestContext;
3433

3534
before(() => {
36-
endpoint = getIntegrationTestEndpoint();
3735
credential = new DefaultAzureCredential();
3836
});
3937

‎test/integration/helpers.ts‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,10 @@ import type { PipelinePolicy } from "@azure/core-rest-pipeline";
88
import type { TokenCredential } from "@azure/identity";
99
import type { AzureAppConfiguration } from "../../src/index.js";
1010

11+
export const INTEGRATION_TEST_ENDPOINT = "https://appconfig-jsprovider-integrationtest.azconfig.io";
1112
export const REFRESH_INTERVAL_IN_MS = 1_000;
1213
const REFRESH_TIMEOUT_IN_MS = 30_000;
1314

14-
export function getIntegrationTestEndpoint(): string {
15-
const endpoint = process.env.AZ_CONFIG_ENDPOINT?.trim();
16-
if (!endpoint) {
17-
throw new Error("Set AZ_CONFIG_ENDPOINT to an App Configuration test-store endpoint before running integration tests.");
18-
}
19-
20-
const invalidEndpointMessage = "AZ_CONFIG_ENDPOINT must be an HTTPS App Configuration endpoint without a path, query, fragment, or embedded credentials.";
21-
if (!URL.canParse(endpoint)) {
22-
throw new Error(invalidEndpointMessage);
23-
}
24-
25-
const url = new URL(endpoint);
26-
if (url.protocol !== "https:" || url.pathname !== "/" || url.search || url.hash || url.username || url.password) {
27-
throw new Error(invalidEndpointMessage);
28-
}
29-
30-
return url.origin;
31-
}
32-
3315
export async function refreshUntil(
3416
settings: Pick<AzureAppConfiguration, "refresh">,
3517
condition: () => boolean,

‎test/integration/json.test.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
import { assert } from "chai";
55
import { DefaultAzureCredential } from "@azure/identity";
66
import { load } from "../../src/index.js";
7-
import { getIntegrationTestEndpoint, IntegrationTestContext } from "./helpers.js";
7+
import { INTEGRATION_TEST_ENDPOINT as endpoint, IntegrationTestContext } from "./helpers.js";
88

99
describe("integration: JSON", function () {
10-
let endpoint: string;
1110
let credential: DefaultAzureCredential;
1211
let context: IntegrationTestContext;
1312

1413
before(() => {
15-
endpoint = getIntegrationTestEndpoint();
1614
credential = new DefaultAzureCredential();
1715
});
1816

‎test/integration/load.test.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
import { assert } from "chai";
55
import { DefaultAzureCredential } from "@azure/identity";
66
import { load } from "../../src/index.js";
7-
import { getIntegrationTestEndpoint, IntegrationTestContext } from "./helpers.js";
7+
import { INTEGRATION_TEST_ENDPOINT as endpoint, IntegrationTestContext } from "./helpers.js";
88

99
describe("integration: load", function () {
10-
let endpoint: string;
1110
let credential: DefaultAzureCredential;
1211
let context: IntegrationTestContext;
1312

1413
before(() => {
15-
endpoint = getIntegrationTestEndpoint();
1614
credential = new DefaultAzureCredential();
1715
});
1816

‎test/integration/refresh.test.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ import { setTimeout as delay } from "node:timers/promises";
55
import { assert } from "chai";
66
import { DefaultAzureCredential } from "@azure/identity";
77
import { load } from "../../src/index.js";
8-
import { createNotModifiedResponseTracker, getIntegrationTestEndpoint, IntegrationTestContext, REFRESH_INTERVAL_IN_MS, refreshUntil } from "./helpers.js";
8+
import { createNotModifiedResponseTracker, INTEGRATION_TEST_ENDPOINT as endpoint, IntegrationTestContext, REFRESH_INTERVAL_IN_MS, refreshUntil } from "./helpers.js";
99

1010
describe("integration: refresh", function () {
11-
let endpoint: string;
1211
let credential: DefaultAzureCredential;
1312
let context: IntegrationTestContext;
1413

1514
before(() => {
16-
endpoint = getIntegrationTestEndpoint();
1715
credential = new DefaultAzureCredential();
1816
});
1917

‎test/integrationHelpers.test.ts‎

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,11 @@ import { AppConfigurationClient, featureFlagContentType } from "@azure/app-confi
88
import { createHttpHeaders, createPipelineRequest } from "@azure/core-rest-pipeline";
99
import type { PipelineRequest, PipelineResponse } from "@azure/core-rest-pipeline";
1010
import type { TokenCredential } from "@azure/identity";
11-
import { createNotModifiedResponseTracker, getIntegrationTestEndpoint, IntegrationTestContext, REFRESH_INTERVAL_IN_MS, refreshUntil } from "./integration/helpers.js";
11+
import { createNotModifiedResponseTracker, IntegrationTestContext, REFRESH_INTERVAL_IN_MS, refreshUntil } from "./integration/helpers.js";
1212

1313
chai.use(chaiAsPromised);
1414
const assert = chai.assert;
1515

16-
describe("integration test endpoint", function () {
17-
const originalEndpoint = process.env.AZ_CONFIG_ENDPOINT;
18-
19-
afterEach(() => {
20-
if (originalEndpoint === undefined) {
21-
delete process.env.AZ_CONFIG_ENDPOINT;
22-
} else {
23-
process.env.AZ_CONFIG_ENDPOINT = originalEndpoint;
24-
}
25-
});
26-
27-
it("requires an explicitly configured endpoint", () => {
28-
delete process.env.AZ_CONFIG_ENDPOINT;
29-
assert.throws(getIntegrationTestEndpoint, /Set AZ_CONFIG_ENDPOINT/);
30-
});
31-
32-
it("normalizes an HTTPS endpoint", () => {
33-
process.env.AZ_CONFIG_ENDPOINT = " https://integration.azconfig.io/ ";
34-
assert.equal(getIntegrationTestEndpoint(), "https://integration.azconfig.io");
35-
});
36-
37-
it("rejects empty, malformed, or non-origin endpoints", () => {
38-
for (const endpoint of [
39-
"",
40-
" ",
41-
"not-a-url",
42-
"http://integration.azconfig.io",
43-
"https://integration.azconfig.io/kv",
44-
"https://integration.azconfig.io?query=value",
45-
"https://integration.azconfig.io#fragment",
46-
"https://user:password@integration.azconfig.io"
47-
]) {
48-
process.env.AZ_CONFIG_ENDPOINT = endpoint;
49-
assert.throws(getIntegrationTestEndpoint, /AZ_CONFIG_ENDPOINT/, endpoint);
50-
}
51-
});
52-
});
53-
5416
describe("integration test context", function () {
5517
const endpoint = "https://integration.azconfig.io";
5618
const credential: TokenCredential = {

0 commit comments

Comments
 (0)