| 92 | } |
| 93 | |
| 94 | function buildCertificate () { |
| 95 | class="cm">// class="st">"global" is used in here because class="st">"t.context" is only supported by class="st">"t.beforeEach" and class="st">"t.afterEach" |
| 96 | class="cm">// For the test case which execute this code which will be using `t.before` and it can reduce the |
| 97 | class="cm">// number of times executing it. |
| 98 | if (!global.context || !global.context.cert || !global.context.key) { |
| 99 | const certs = selfCert({ |
| 100 | expires: new Date(Date.now() + 86400000) |
| 101 | }) |
| 102 | global.context = { |
| 103 | cert: certs.certificate, |
| 104 | key: certs.privateKey |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | module.exports = { buildCertificate } |