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.
		
		
		
		
		
			
		
			
				
					
					
						
							21 lines
						
					
					
						
							617 B
						
					
					
				
			
		
		
	
	
							21 lines
						
					
					
						
							617 B
						
					
					
				'use strict'
 | 
						|
 | 
						|
const selfCert = require('self-cert')
 | 
						|
 | 
						|
async function buildCertificate () {
 | 
						|
  // "global" is used in here because "t.context" is only supported by "t.beforeEach" and "t.afterEach"
 | 
						|
  // For the test case which execute this code which will be using `t.before` and it can reduce the
 | 
						|
  // number of times executing it.
 | 
						|
  if (!global.context || !global.context.cert || !global.context.key) {
 | 
						|
    const certs = selfCert({
 | 
						|
      expires: new Date(Date.now() + 86400000)
 | 
						|
    })
 | 
						|
    global.context = {
 | 
						|
      cert: certs.certificate,
 | 
						|
      key: certs.privateKey
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
module.exports = { buildCertificate }
 |