forked from mkg20001/libp2p-nodetrust
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdrop-wildcard.js
56 lines (46 loc) · 1.35 KB
/
drop-wildcard.js
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
51
52
53
54
55
56
'use strict'
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const {createServer, createClient} = require('./utils')
const {parallel} = require('async')
const fs = require('fs')
const path = require('path')
/* eslint-env mocha */
describe('drop-wildcard', () => {
let server
let client
let swarm
it('should start the server', cb => {
server = createServer({
zone: 'node.libp2p',
ca: {
provider: 'wilddrop',
key: path.join('server', 'wildkey.pem'),
cert: path.join('server', 'wildcert.pem')
},
dns: {
provider: 'memory'
},
discovery: {
}
}, cb)
})
it('should start the client', cb => {
[swarm, client] = createClient({
}, cb)
})
it('client should aquire cert', cb => {
client.enable(err => {
expect(err).to.not.exist()
expect(client.chain).to.exist()
expect(client.cert).to.exist()
expect(client.key).to.exist()
expect(client.cert.toString()).to.equal(fs.readFileSync(path.join('server', 'wildcert.pem')).toString())
expect(client.key.toString()).to.equal(fs.readFileSync(path.join('server', 'wildkey.pem')).toString())
cb()
})
})
after(cb => parallel([server.stop.bind(server), client.disable.bind(client), swarm.stop.bind(swarm)], cb))
})