-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathqueries.test.ts
More file actions
38 lines (32 loc) · 1.14 KB
/
queries.test.ts
File metadata and controls
38 lines (32 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { sslTest, dnssec, headers, dmarcSpf } from './queries';
import test from 'ava';
test('SSL positive', async t => {
const result = await sslTest({ host: 'google.com' });
t.is(result.endpoints.length, 2);
t.is(result.endpoints[0].grade, 'B');
t.is(result.endpoints[1].grade, 'B');
t.true(result.endpoints[0].details.supportsAlpn);
t.true(result.endpoints[1].details.supportsAlpn);
});
test('DNSSEC positive', async t => {
const result = await dnssec({ host: 'verisigninc.com' });
t.true(result.secure);
});
test('DNSSEC negative', async t => {
const result = await dnssec({ host: 'google.com' });
t.false(result.secure);
});
test('Security headers positive', async t => {
const result = await headers({ url: 'https://securityheaders.io' });
const sts = result.get('strict-transport-security');
if (!sts) {
t.fail('STS header should be set.');
} else {
t.true('preload' in sts);
t.true('includeSubDomains' in sts);
t.true(Number(sts['max-age']) >= 31536000);
}
});
test('DMARC/SPF positive', async t => {
t.true(await dmarcSpf({ hostname: 'valimail.com' }));
});