11'use strict' ;
22
33const path = require ( 'path' ) ;
4+ const fs = require ( 'fs' ) ;
45const request = require ( 'supertest' ) ;
56const helper = require ( './helper' ) ;
67const config = require ( './fixtures/contentbase-config/webpack.config' ) ;
78require ( 'mocha-sinon' ) ;
89
10+ const httpsCertificateDirectory = path . join ( __dirname , 'fixtures/https-certificate' ) ;
911const contentBasePublic = path . join ( __dirname , 'fixtures/contentbase-config/public' ) ;
1012
1113describe ( 'HTTPS' , function testHttps ( ) {
@@ -30,4 +32,46 @@ describe('HTTPS', function testHttps() {
3032 . expect ( 200 , / H e y o / , done ) ;
3133 } ) ;
3234 } ) ;
35+
36+ describe ( 'ca, pfx, key and cert are buffer' , ( ) => {
37+ before ( ( done ) => {
38+ server = helper . start ( config , {
39+ contentBase : contentBasePublic ,
40+ https : {
41+ ca : fs . readFileSync ( path . join ( httpsCertificateDirectory , 'ca.pem' ) ) ,
42+ pfx : fs . readFileSync ( path . join ( httpsCertificateDirectory , 'server.pfx' ) ) ,
43+ key : fs . readFileSync ( path . join ( httpsCertificateDirectory , 'server.key' ) ) ,
44+ cert : fs . readFileSync ( path . join ( httpsCertificateDirectory , 'server.crt' ) ) ,
45+ passphrase : 'webpack-dev-server'
46+ }
47+ } , done ) ;
48+ req = request ( server . app ) ;
49+ } ) ;
50+
51+ it ( 'Request to index' , ( done ) => {
52+ req . get ( '/' )
53+ . expect ( 200 , / H e y o / , done ) ;
54+ } ) ;
55+ } ) ;
56+
57+ describe ( 'ca, pfx, key and cert are string' , ( ) => {
58+ before ( ( done ) => {
59+ server = helper . start ( config , {
60+ contentBase : contentBasePublic ,
61+ https : {
62+ ca : path . join ( httpsCertificateDirectory , 'ca.pem' ) ,
63+ pfx : path . join ( httpsCertificateDirectory , 'server.pfx' ) ,
64+ key : path . join ( httpsCertificateDirectory , 'server.key' ) ,
65+ cert : path . join ( httpsCertificateDirectory , 'server.crt' ) ,
66+ passphrase : 'webpack-dev-server'
67+ }
68+ } , done ) ;
69+ req = request ( server . app ) ;
70+ } ) ;
71+
72+ it ( 'Request to index' , ( done ) => {
73+ req . get ( '/' )
74+ . expect ( 200 , / H e y o / , done ) ;
75+ } ) ;
76+ } ) ;
3377} ) ;
0 commit comments