File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -123,5 +123,36 @@ describe("Validation", function() {
123
123
throw new Error ( "Validation didn't fail" ) ;
124
124
}
125
125
} ) ;
126
+
127
+ describe ( "allowedHosts" , function ( ) {
128
+ it ( "should allow hosts in allowedHosts" , function ( ) {
129
+ const options = { allowedHosts : [ "test.host" ] } ;
130
+ const headers = { host : "test.host:80" } ;
131
+ const server = new Server ( compiler , options ) ;
132
+ if ( ! server . checkHost ( headers ) ) {
133
+ throw new Error ( "Validation didn't fail" ) ;
134
+ }
135
+ } ) ;
136
+ it ( "should return true if host passes a wildcard in allowedHosts" , function ( ) {
137
+ const options = { allowedHosts : [ ".example.com" ] } ;
138
+ const server = new Server ( compiler , options ) ;
139
+ const testDomains = [
140
+ "www.example.com" ,
141
+ "subdomain.example.com" ,
142
+ "example.com" ,
143
+ "subsubcomain.subdomain.example.com" ,
144
+ "example.com:80" ,
145
+ "subdomain.example.com:80"
146
+ ] ;
147
+
148
+ let headers ;
149
+ testDomains . forEach ( function ( testDomain ) {
150
+ headers = { host : testDomain } ;
151
+ if ( ! server . checkHost ( headers ) ) {
152
+ throw new Error ( "Validation didn't fail" ) ;
153
+ }
154
+ } ) ;
155
+ } ) ;
156
+ } ) ;
126
157
} )
127
158
} ) ;
You can’t perform that action at this time.
0 commit comments