@@ -15,17 +15,20 @@ describe('requestsConfigAssert', () => {
1515 viaProxy : false ,
1616 trustedProxyCIDRs : [ ] ,
1717 extractClientIPFromHeader : '' ,
18+ extractProtocolFromHeader : '' ,
1819 } ) ;
1920 } ,
2021 'shouldnt throw an error if requests config via proxy is set to false' ) ;
2122 } ) ;
2223 it ( 'should not throw an error if requests config via proxy is true, ' +
23- 'trustedProxyCIDRs & extractClientIPFromHeader are set' , ( ) => {
24+ 'trustedProxyCIDRs & extractClientIPFromHeader & ' +
25+ 'extractProtocolFromHeader are set' , ( ) => {
2426 assert . doesNotThrow ( ( ) => {
2527 requestsConfigAssert ( {
2628 viaProxy : true ,
2729 trustedProxyCIDRs : [ '123.123.123.123' ] ,
2830 extractClientIPFromHeader : 'x-forwarded-for' ,
31+ extractProtocolFromHeader : 'x-forwarded-proto' ,
2932 } ) ;
3033 } ,
3134 'should not throw an error if requests config ' +
@@ -38,6 +41,7 @@ describe('requestsConfigAssert', () => {
3841 viaProxy : 1 ,
3942 trustedProxyCIDRs : [ '123.123.123.123' ] ,
4043 extractClientIPFromHeader : 'x-forwarded-for' ,
44+ extractProtocolFromHeader : 'x-forwarded-proto' ,
4145 } ) ;
4246 } ,
4347 '/config: invalid requests configuration. viaProxy must be a ' +
@@ -50,6 +54,7 @@ describe('requestsConfigAssert', () => {
5054 viaProxy : true ,
5155 trustedProxyCIDRs : 1 ,
5256 extractClientIPFromHeader : 'x-forwarded-for' ,
57+ extractProtocolFromHeader : 'x-forwarded-proto' ,
5358 } ) ;
5459 } ,
5560 '/config: invalid requests configuration. ' +
@@ -63,6 +68,7 @@ describe('requestsConfigAssert', () => {
6368 viaProxy : true ,
6469 trustedProxyCIDRs : [ ] ,
6570 extractClientIPFromHeader : 'x-forwarded-for' ,
71+ extractProtocolFromHeader : 'x-forwarded-proto' ,
6672 } ) ;
6773 } ,
6874 '/config: invalid requests configuration. ' +
@@ -76,23 +82,53 @@ describe('requestsConfigAssert', () => {
7682 viaProxy : true ,
7783 trustedProxyCIDRs : [ ] ,
7884 extractClientIPFromHeader : 1 ,
85+ extractProtocolFromHeader : 'x-forwarded-proto' ,
7986 } ) ;
8087 } ,
8188 '/config: invalid requests configuration. ' +
8289 'extractClientIPFromHeader must be set if viaProxy is ' +
8390 'set to true and must be a string/' ) ;
8491 } ) ;
92+ it ( 'should throw an error if requests.extractProtocolFromHeader ' +
93+ 'is not a string' , ( ) => {
94+ assert . throws ( ( ) => {
95+ requestsConfigAssert ( {
96+ viaProxy : true ,
97+ trustedProxyCIDRs : [ ] ,
98+ extractClientIPFromHeader : 'x-forwarded-for' ,
99+ extractProtocolFromHeader : 1 ,
100+ } ) ;
101+ } ,
102+ '/config: invalid requests configuration. ' +
103+ 'extractProtocolFromHeader must be set if viaProxy is ' +
104+ 'set to true and must be a string/' ) ;
105+ } ) ;
85106 it ( 'should throw an error if requests.extractClientIPFromHeader ' +
86107 'is empty' , ( ) => {
87108 assert . throws ( ( ) => {
88109 requestsConfigAssert ( {
89110 viaProxy : true ,
90111 trustedProxyCIDRs : [ ] ,
91112 extractClientIPFromHeader : '' ,
113+ extractProtocolFromHeader : 'x-forwarded-proto' ,
92114 } ) ;
93115 } ,
94116 '/config: invalid requests configuration. ' +
95117 'extractClientIPFromHeader must be set if viaProxy is ' +
96118 'set to true and must be a string/' ) ;
97119 } ) ;
120+ it ( 'should throw an error if requests.extractProtocolFromHeader ' +
121+ 'is empty' , ( ) => {
122+ assert . throws ( ( ) => {
123+ requestsConfigAssert ( {
124+ viaProxy : true ,
125+ trustedProxyCIDRs : [ ] ,
126+ extractClientIPFromHeader : 'x-forwarded-for' ,
127+ extractProtocolFromHeader : '' ,
128+ } ) ;
129+ } ,
130+ '/config: invalid requests configuration. ' +
131+ 'extractProtocolFromHeader must be set if viaProxy is ' +
132+ 'set to true and must be a string/' ) ;
133+ } ) ;
98134} ) ;
0 commit comments