diff --git a/libs/backend-apisix/e2e/ping.e2e-spec.ts b/libs/backend-apisix/e2e/ping.e2e-spec.ts index 39ddb8dc..ab07bff9 100644 --- a/libs/backend-apisix/e2e/ping.e2e-spec.ts +++ b/libs/backend-apisix/e2e/ping.e2e-spec.ts @@ -1,12 +1,13 @@ import { join } from 'path'; import { BackendAPISIX } from '../src'; +import { server, token } from './support/constants'; describe('Ping', () => { it('should success (http)', async () => { const backend = new BackendAPISIX({ - server: globalThis.server, - token: globalThis.token, + server, + token, }); await backend.ping(); }); @@ -14,7 +15,7 @@ describe('Ping', () => { it('should success (mTLS)', async () => { const backend = new BackendAPISIX({ server: 'https://localhost:29180', - token: globalThis.token, + token, tlsClientCertFile: join(__dirname, 'assets/apisix_conf/mtls/client.cer'), tlsClientKeyFile: join(__dirname, 'assets/apisix_conf/mtls/client.key'), caCertFile: join(__dirname, 'assets/apisix_conf/mtls/ca.cer'), @@ -35,7 +36,7 @@ describe('Ping', () => { it('should failed (self-signed certificate)', async () => { const backend = new BackendAPISIX({ server: 'https://localhost:29180', - token: globalThis.token, + token, }); await expect(backend.ping()).rejects.toThrow( 'unable to verify the first certificate', @@ -45,7 +46,7 @@ describe('Ping', () => { it('should failed (miss client certificates)', async () => { const backend = new BackendAPISIX({ server: 'https://localhost:29180', - token: globalThis.token, + token, caCertFile: join(__dirname, 'assets/apisix_conf/mtls/ca.cer'), }); diff --git a/libs/backend-apisix/e2e/support/constants.ts b/libs/backend-apisix/e2e/support/constants.ts new file mode 100644 index 00000000..9c27e656 --- /dev/null +++ b/libs/backend-apisix/e2e/support/constants.ts @@ -0,0 +1,2 @@ +export const server = 'http://localhost:19180'; +export const token = 'edd1c9f034335f136f87ad84b625c8f1'; diff --git a/libs/backend-apisix/e2e/support/global-setup.ts b/libs/backend-apisix/e2e/support/global-setup.ts index 9de219ba..9223ddb3 100644 --- a/libs/backend-apisix/e2e/support/global-setup.ts +++ b/libs/backend-apisix/e2e/support/global-setup.ts @@ -1,4 +1,3 @@ export default async () => { - globalThis.server = 'http://localhost:19180'; - globalThis.token = 'edd1c9f034335f136f87ad84b625c8f1'; + //empty }; diff --git a/libs/backend-apisix/e2e/support/global-teardown.ts b/libs/backend-apisix/e2e/support/global-teardown.ts index 0bb7cc56..9223ddb3 100644 --- a/libs/backend-apisix/e2e/support/global-teardown.ts +++ b/libs/backend-apisix/e2e/support/global-teardown.ts @@ -1,3 +1,3 @@ export default async () => { - //TODO + //empty }; diff --git a/libs/backend-apisix/e2e/sync-and-dump-1.e2e-spec.ts b/libs/backend-apisix/e2e/sync-and-dump-1.e2e-spec.ts index a53c6140..2e729d5b 100644 --- a/libs/backend-apisix/e2e/sync-and-dump-1.e2e-spec.ts +++ b/libs/backend-apisix/e2e/sync-and-dump-1.e2e-spec.ts @@ -4,6 +4,7 @@ import { readFileSync } from 'node:fs'; import { join } from 'node:path'; import { BackendAPISIX } from '../src'; +import { server, token } from './support/constants'; import { createEvent, deleteEvent, @@ -17,8 +18,8 @@ describe('Sync and Dump - 1', () => { beforeAll(() => { backend = new BackendAPISIX({ - server: globalThis.server, - token: globalThis.token, + server, + token, tlsSkipVerify: true, gatewayGroup: 'default', });