File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -123,5 +123,43 @@ describe("Validation", function() {
123123 throw new Error ( "Validation didn't fail" ) ;
124124 }
125125 } ) ;
126+
127+ describe ( "allowedHosts" , function ( ) {
128+ it ( "should allow hosts in allowedHosts" , function ( ) {
129+ const testHosts = [
130+ "test.host" ,
131+ "test2.host" ,
132+ "test3.host"
133+ ] ;
134+ const options = { allowedHosts : testHosts } ;
135+ const server = new Server ( compiler , options ) ;
136+
137+ testHosts . forEach ( function ( testHost ) {
138+ const headers = { host : testHost } ;
139+ if ( ! server . checkHost ( headers ) ) {
140+ throw new Error ( "Validation didn't fail" ) ;
141+ }
142+ } ) ;
143+ } ) ;
144+ it ( "should allow hosts that pass a wildcard in allowedHosts" , function ( ) {
145+ const options = { allowedHosts : [ ".example.com" ] } ;
146+ const server = new Server ( compiler , options ) ;
147+ const testHosts = [
148+ "www.example.com" ,
149+ "subdomain.example.com" ,
150+ "example.com" ,
151+ "subsubcomain.subdomain.example.com" ,
152+ "example.com:80" ,
153+ "subdomain.example.com:80"
154+ ] ;
155+
156+ testHosts . forEach ( function ( testHost ) {
157+ const headers = { host : testHost } ;
158+ if ( ! server . checkHost ( headers ) ) {
159+ throw new Error ( "Validation didn't fail" ) ;
160+ }
161+ } ) ;
162+ } ) ;
163+ } ) ;
126164 } )
127165} ) ;
You can’t perform that action at this time.
0 commit comments