You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

26 lines
624 B

import test from 'ava';
import createTestServer from 'create-test-server';
import got from '..';
let s;
test.before('setup', async () => {
s = await createTestServer({certificate: 'sindresorhus.com'});
s.get('/', (req, res) => res.send('ok'));
});
test('make request to https server without ca', async t => {
t.truthy((await got(s.sslUrl, {rejectUnauthorized: false})).body);
});
test('make request to https server with ca', async t => {
const {body} = await got(s.sslUrl, {
ca: s.caCert,
headers: {host: 'sindresorhus.com'}
});
t.is(body, 'ok');
});
test.after('cleanup', async () => {
await s.close();
});