@@ -11,7 +11,7 @@ import tls from "node:tls"
1111
1212import appDataPathPkg from "appdata-path"
1313
14- import * as certs from "../src/certs.ts"
14+ import { generate , getCerts , remove } from "../src/certs.ts"
1515import { getEnv } from "../src/env.ts"
1616import createServer from "../src/index.ts"
1717import type { HttpsLocalhostApp } from "../src/index.ts"
@@ -90,26 +90,26 @@ async function makeRequest(
9090
9191describe ( "Testing certs" , { timeout : 300000 } , ( ) => {
9292 afterEach ( ( ) => {
93- certs . remove ( "test/custom-folder" )
94- certs . remove ( "test/custom folder" )
93+ remove ( "test/custom-folder" )
94+ remove ( "test/custom folder" )
9595 delete process . env [ "CERT_PATH" ]
9696 delete process . env [ "HOST" ]
9797 } )
9898
9999 it ( "can be uninstalled" , ( ) => {
100- certs . remove ( )
100+ remove ( )
101101 } )
102102
103103 it ( "uninstall is idempotent (doesn't fail if called twice)" , ( ) => {
104- certs . remove ( )
104+ remove ( )
105105 } )
106106
107107 it ( "can be installed" , async ( ) => {
108- await certs . generate ( )
108+ await generate ( )
109109 } )
110110
111111 it ( "can be installed at first run" , async ( ) => {
112- certs . remove ( )
112+ remove ( )
113113
114114 app = createServer ( )
115115 app . get ( "/test/module" , ( _req : import ( "express" ) . Request , res : import ( "express" ) . Response ) =>
@@ -134,13 +134,13 @@ describe("Testing certs", { timeout: 300000 }, () => {
134134
135135 it ( "crashes if certs doesn't exists in custom folder" , async ( ) => {
136136 const customCertPath = "test/custom-folder"
137- await certs . generate ( { appDataPath : customCertPath } )
137+ await generate ( { appDataPath : customCertPath } )
138138 fs . unlinkSync ( "test/custom-folder/localhost.crt" )
139139 fs . unlinkSync ( "test/custom-folder/localhost.key" )
140140
141141 app = createServer ( { certPath : customCertPath } )
142142 await assert . rejects ( app . listen ( HTTPS_PORT ) , / C e r t i f i c a t e s a r e m i s s i n g / )
143- certs . remove ( customCertPath )
143+ remove ( customCertPath )
144144 } )
145145
146146 it ( "support path with spaces" , async ( ) => {
@@ -153,17 +153,17 @@ describe("Testing certs", { timeout: 300000 }, () => {
153153
154154 await makeRequest ( "/test/module" ) . then ( res => assert ( res . data === "TEST" ) )
155155 await closeServer ( app . server )
156- certs . remove ( "test/custom folder" )
156+ remove ( "test/custom folder" )
157157 } )
158158
159159 it ( "provides the certificate" , async ( ) => {
160160 const env = getEnv ( )
161- const appCerts = await certs . getCerts ( {
161+ const appCerts = await getCerts ( {
162162 domain : env . HOST ,
163163 certPath : env . CERT_PATH ,
164164 reinstall : env . REINSTALL ,
165165 } )
166- const realCerts = await certs . getCerts ( {
166+ const realCerts = await getCerts ( {
167167 domain : env . HOST ,
168168 certPath : env . CERT_PATH ,
169169 reinstall : env . REINSTALL ,
@@ -172,7 +172,7 @@ describe("Testing certs", { timeout: 300000 }, () => {
172172 } )
173173
174174 it ( "works with environment domain" , async ( ) => {
175- const appCerts = await certs . getCerts ( { domain : "192.168.0.1" } )
175+ const appCerts = await getCerts ( { domain : "192.168.0.1" } )
176176 const secureContext = tls . createSecureContext ( {
177177 cert : appCerts . cert ,
178178 } )
0 commit comments