1
1
'use strict' ;
2
2
3
3
const path = require ( 'path' ) ;
4
+ const fs = require ( 'fs' ) ;
4
5
const request = require ( 'supertest' ) ;
5
6
const helper = require ( './helper' ) ;
6
7
const config = require ( './fixtures/contentbase-config/webpack.config' ) ;
7
8
require ( 'mocha-sinon' ) ;
8
9
10
+ const httpsCertificateDirectory = path . join ( __dirname , 'fixtures/https-certificate' ) ;
9
11
const contentBasePublic = path . join ( __dirname , 'fixtures/contentbase-config/public' ) ;
10
12
11
13
describe ( 'HTTPS' , function testHttps ( ) {
@@ -30,4 +32,46 @@ describe('HTTPS', function testHttps() {
30
32
. expect ( 200 , / H e y o / , done ) ;
31
33
} ) ;
32
34
} ) ;
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
+ } ) ;
33
77
} ) ;
0 commit comments