generated from nginx/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathacme-auto.test.ts
50 lines (45 loc) · 1.46 KB
/
acme-auto.test.ts
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
39
40
41
42
43
44
45
46
47
48
49
50
import { strict as assert } from 'assert'
import './hooks'
interface CertificateData {
certificate: {
issuer: {
[key: string]: string
}[]
domains: {
commonName: string
altNames: string[][]
}
notBefore: string
notAfter: string
}
renewedCertificate: boolean
}
describe('Integration:AutoMode', async function () {
it('issue cert', async function () {
this.timeout('10s')
const resp = await this.client.get('')
assert.equal(resp.statusCode, 200)
const respBody = JSON.parse(resp.body)
assert.equal(respBody.server_name, this.nginxHost)
assert.equal(respBody.ssl_session_id, '')
const respCert = await this.client.get('acme/auto')
assert.equal(respCert.statusCode, 200)
const certInfo = JSON.parse(respCert.body) as CertificateData
assert(
certInfo.certificate.domains.commonName.includes('Pebble Intermediate CA')
)
assert.equal(certInfo.certificate.domains.altNames.length, 1)
assert.equal(certInfo.certificate.domains.altNames[0], this.nginxHost)
const httpsClient = this.client.extend({
prefixUrl: `https://${this.nginxHost}:${this.nginx.ports[1]}`,
https: {
rejectUnauthorized: false,
},
})
const httpsResp = await httpsClient.get('')
assert.equal(httpsResp.statusCode, 200)
const httpsBody = JSON.parse(httpsResp.body)
assert.equal(httpsBody.server_name, this.nginxHost)
assert.notEqual(httpsBody.ssl_session_id, '')
})
})