Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed May 26, 2021
1 parent 393765e commit 0dfc20d
Showing 1 changed file with 69 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ describe('axios connections', () => {
expect(res.status).toBe(200);
});

test('it works with verificationMode "none" config', async () => {
const { url, server } = await createServer(true);
testServer = server;

const configurationUtilities = getACUfromConfig({
tls: {
verificationMode: 'none',
},
});
const res = await request({ axios, url, logger, configurationUtilities });
expect(res.status).toBe(200);
});

test('it works with rejectUnauthorized custom host config', async () => {
const { url, server } = await createServer(true);
testServer = server;
Expand All @@ -103,6 +116,17 @@ describe('axios connections', () => {
expect(res.status).toBe(200);
});

test('it works with verificationMode "none" for custom host config', async () => {
const { url, server } = await createServer(true);
testServer = server;

const configurationUtilities = getACUfromConfig({
customHostSettings: [{ url, tls: { verificationMode: 'none' } }],
});
const res = await request({ axios, url, logger, configurationUtilities });
expect(res.status).toBe(200);
});

test('it works with ca in custom host config', async () => {
const { url, server } = await createServer(true);
testServer = server;
Expand Down Expand Up @@ -144,6 +168,25 @@ describe('axios connections', () => {
expect(res.status).toBe(200);
});

test('it works with incorrect ca in custom host config but verificationMode "none"', async () => {
const { url, server } = await createServer(true);
testServer = server;

const configurationUtilities = getACUfromConfig({
customHostSettings: [
{
url,
tls: {
certificateAuthoritiesData: CA,
verificationMode: 'none',
},
},
],
});
const res = await request({ axios, url, logger, configurationUtilities });
expect(res.status).toBe(200);
});

test('it works with incorrect ca in custom host config but rejectUnauthorized config true', async () => {
const { url, server } = await createServer(true);
testServer = server;
Expand All @@ -163,13 +206,34 @@ describe('axios connections', () => {
expect(res.status).toBe(200);
});

test('it works with incorrect ca in custom host config but verificationMode config "none"', async () => {
const { url, server } = await createServer(true);
testServer = server;

const configurationUtilities = getACUfromConfig({
tls: {
verificationMode: 'none',
},
customHostSettings: [
{
url,
tls: {
certificateAuthoritiesData: CA,
},
},
],
});
const res = await request({ axios, url, logger, configurationUtilities });
expect(res.status).toBe(200);
});

test('it fails with no matching custom host settings', async () => {
const { url, server } = await createServer(true);
const otherUrl = 'https://example.com';
testServer = server;

const configurationUtilities = getACUfromConfig({
customHostSettings: [{ url: otherUrl, tls: { rejectUnauthorized: false } }],
customHostSettings: [{ url: otherUrl, tls: { verificationMode: 'none' } }],
});
const fn = async () => await request({ axios, url, logger, configurationUtilities });
await expect(fn()).rejects.toThrow('certificate');
Expand Down Expand Up @@ -251,6 +315,10 @@ const BaseActionsConfig: ActionsConfig = {
proxyUrl: undefined,
proxyHeaders: undefined,
proxyRejectUnauthorizedCertificates: true,
tls: {
proxyVerificationMode: 'full',
verificationMode: 'full',
},
proxyBypassHosts: undefined,
proxyOnlyHosts: undefined,
rejectUnauthorized: true,
Expand Down

0 comments on commit 0dfc20d

Please sign in to comment.