Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
feat(csi-47): added negative test scenarios for int tests
Browse files Browse the repository at this point in the history
  • Loading branch information
geka-evk committed Jun 18, 2024
1 parent e1dc4fe commit 59f8faf
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ jobs:
run: |
docker compose build
docker compose up -d
sleep 15
echo "waiting for 10sec before tests run..." && sleep 10
npm run test:int
docker compose down -v
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
build:
context: ./
dockerfile: Dockerfile
command: /bin/sh -c "sleep 15 && npm start" # todo: use better approach instead of sleep 15
command: /bin/sh -c "sleep 10 && npm start" # todo: use better approach instead of sleep 10
restart: on-failure
env_file: .env
environment:
Expand Down
7 changes: 7 additions & 0 deletions test/certs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"wrongClient": {
"ca": "-----BEGIN CERTIFICATE-----\nMIIDazCCAlOgAwIBAgIUfKD8ZlWxBAAax4e/OitK+WBMIswwDQYJKoZIhvcNAQEL\nBQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM\nGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yNDA2MTgxMTQ0MTRaFw0yNzA0\nMDgxMTQ0MTRaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw\nHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEB\nAQUAA4IBDwAwggEKAoIBAQDubQRiN3XoPx1hOofH6XfOCeTq5c7DEKL8+pECF9tV\nAIP1hw/zVizvPHMT4RYWkD8kTHHr6Crv8SxvE1jv2byM9hBe/GC0BrAL1By1fhar\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t8QKBgQC3\n6p+514nLT2kR3h0bmhMxAv7xbjQiuIZe38UGg+72brmcLPFLlpFa++Xa/8kmS60L\nIoZl7LCtLRuc2/u1uChEeYnsN8HvaU3tKS2fQPOmJkMNok9lBEYafkSZMBQTVb0B\n2p1hxDR0VSXuuYmbUWw0xjiNiXfVYkZaZZui4Dnh0QKBgDJkG2QvK2w5/yOJW6S3\nc9TB0XHzC14aWmbeYWUwAbzAyfeuOhSz+7TxqrzWn54icpHS4ubhyLsVZOLIeIOK\nwBbUFWMz7Fl7bpCiLja4wp4PGfXxEXWUY76DUDgy1dtTHpmaR5r7zIMZR8Sf1CTe\nXBsI2HW3VX0swibHS36xcvDh\n-----END PRIVATE KEY-----"
}
}
35 changes: 33 additions & 2 deletions test/integration/domain/ISPA.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
--------------
**********/

import https from 'node:https';
import axios from 'axios'; // todo: add wrapper
import config from '#src/config';
import { PROXY_HEADER, AUTH_HEADER } from '#src/constants';

import certs from '#test/certs.json';

const PROXY_HOST = 'http://localhost';
const { serverAConfig, PROXY_ID } = config.get();
const { serverAConfig, hubAConfig, PROXY_ID } = config.get();

const checkProxyServiceHeaders = (headers: Record<string, unknown>) => {
expect(headers[PROXY_HEADER.toLowerCase()]).toBe(PROXY_ID);
Expand Down Expand Up @@ -56,5 +59,33 @@ describe('ISPA Integration Tests -->', () => {
expect(data.body).toEqual(payload);
expect(data.headers.h1).toBe(headers.h1);
});
// todo: add negative scenario with wrong certs and auth token

describe('mTLS hub (peer-endpoint) Tests -->', () => {
const url = `${hubAConfig.baseUrl}/int-test`;
const sendGetRequest = async (options: axios.AxiosRequestConfig) =>
axios
.request({
...options,
method: 'GET',
})
.catch((err) => err);

test('should fail when connect to https hub (peer-endpoint) without certs', async () => {
const httpsAgent = new https.Agent({ rejectUnauthorized: false });
const response = await sendGetRequest({ url, httpsAgent });
expect(response).toBeInstanceOf(Error);
expect(response.message).toMatch(/routines:ssl3_read_bytes:tlsv13 alert certificate required/);
});

test('should fail when connect to https hub (peer-endpoint) with wrong certs', async () => {
const httpsAgent = new https.Agent({
...certs.wrongClient,
rejectUnauthorized: false,
});
const response = await sendGetRequest({ url, httpsAgent });
expect(response).toBeInstanceOf(Error);
expect(response.message).toBe('socket hang up');
});
});
// todo: add negative scenario with wrong auth token
});

0 comments on commit 59f8faf

Please sign in to comment.