Skip to content

Commit

Permalink
ci: move globalThis to constants
Browse files Browse the repository at this point in the history
  • Loading branch information
bzp2010 committed Jul 13, 2024
1 parent f654869 commit b569f0d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
11 changes: 6 additions & 5 deletions libs/backend-apisix/e2e/ping.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
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();
});

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'),
Expand All @@ -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',
Expand All @@ -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'),
});

Expand Down
2 changes: 2 additions & 0 deletions libs/backend-apisix/e2e/support/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const server = 'http://localhost:19180';
export const token = 'edd1c9f034335f136f87ad84b625c8f1';
3 changes: 1 addition & 2 deletions libs/backend-apisix/e2e/support/global-setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export default async () => {
globalThis.server = 'http://localhost:19180';
globalThis.token = 'edd1c9f034335f136f87ad84b625c8f1';
//empty
};
2 changes: 1 addition & 1 deletion libs/backend-apisix/e2e/support/global-teardown.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default async () => {
//TODO
//empty
};
5 changes: 3 additions & 2 deletions libs/backend-apisix/e2e/sync-and-dump-1.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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',
});
Expand Down

0 comments on commit b569f0d

Please sign in to comment.