@@ -215,6 +215,102 @@ describe('Plugin', () => {
215215 } )
216216 } )
217217
218+ it ( 'should skip injecting if the Authorization header contains an AWS signature' , done => {
219+ const app = express ( )
220+
221+ app . get ( '/' , ( req , res ) => {
222+ try {
223+ expect ( req . get ( 'x-datadog-trace-id' ) ) . to . be . undefined
224+ expect ( req . get ( 'x-datadog-parent-id' ) ) . to . be . undefined
225+
226+ res . status ( 200 ) . send ( )
227+
228+ done ( )
229+ } catch ( e ) {
230+ done ( e )
231+ }
232+ } )
233+
234+ appListener = server ( app , port => {
235+ fetch ( `http://localhost:${ port } /` , {
236+ headers : {
237+ Authorization : 'AWS4-HMAC-SHA256 ...'
238+ }
239+ } )
240+ } )
241+ } )
242+
243+ it ( 'should skip injecting if one of the Authorization headers contains an AWS signature' , done => {
244+ const app = express ( )
245+
246+ app . get ( '/' , ( req , res ) => {
247+ try {
248+ expect ( req . get ( 'x-datadog-trace-id' ) ) . to . be . undefined
249+ expect ( req . get ( 'x-datadog-parent-id' ) ) . to . be . undefined
250+
251+ res . status ( 200 ) . send ( )
252+
253+ done ( )
254+ } catch ( e ) {
255+ done ( e )
256+ }
257+ } )
258+
259+ appListener = server ( app , port => {
260+ fetch ( `http://localhost:${ port } /` , {
261+ headers : {
262+ Authorization : [ 'AWS4-HMAC-SHA256 ...' ]
263+ }
264+ } )
265+ } )
266+ } )
267+
268+ it ( 'should skip injecting if the X-Amz-Signature header is set' , done => {
269+ const app = express ( )
270+
271+ app . get ( '/' , ( req , res ) => {
272+ try {
273+ expect ( req . get ( 'x-datadog-trace-id' ) ) . to . be . undefined
274+ expect ( req . get ( 'x-datadog-parent-id' ) ) . to . be . undefined
275+
276+ res . status ( 200 ) . send ( )
277+
278+ done ( )
279+ } catch ( e ) {
280+ done ( e )
281+ }
282+ } )
283+
284+ appListener = server ( app , port => {
285+ fetch ( `http://localhost:${ port } /` , {
286+ headers : {
287+ 'X-Amz-Signature' : 'abc123'
288+ }
289+ } )
290+ } )
291+ } )
292+
293+ it ( 'should skip injecting if the X-Amz-Signature query param is set' , done => {
294+ const app = express ( )
295+
296+ app . get ( '/' , ( req , res ) => {
297+ try {
298+ expect ( req . get ( 'x-datadog-trace-id' ) ) . to . be . undefined
299+ expect ( req . get ( 'x-datadog-parent-id' ) ) . to . be . undefined
300+
301+ res . status ( 200 ) . send ( )
302+
303+ done ( )
304+ } catch ( e ) {
305+ done ( e )
306+ }
307+ } )
308+
309+ appListener = server ( app , port => {
310+ fetch ( `http://localhost:${ port } /?X-Amz-Signature=abc123` )
311+ } )
312+ } )
313+
218314 it ( 'should handle connection errors' , done => {
219315 let error
220316
0 commit comments