@@ -446,97 +446,24 @@ describe('Plugin', () => {
446
446
} )
447
447
} )
448
448
449
- it ( 'should skip injecting if the Authorization header contains an AWS signature' , done => {
450
- const app = express ( )
451
-
452
- app . get ( '/' , ( req , res ) => {
453
- try {
454
- expect ( req . get ( 'x-datadog-trace-id' ) ) . to . be . undefined
455
- expect ( req . get ( 'x-datadog-parent-id' ) ) . to . be . undefined
456
-
457
- res . status ( 200 ) . send ( )
458
-
459
- done ( )
460
- } catch ( e ) {
461
- done ( e )
462
- }
463
- } )
464
-
465
- appListener = server ( app , port => {
466
- const req = http . request ( {
467
- port,
468
- headers : {
469
- Authorization : 'AWS4-HMAC-SHA256 ...'
470
- }
471
- } )
449
+ it ( 'should inject tracing header into request without mutating the header' , done => {
450
+ // ensures that the tracer clones request headers instead of mutating.
451
+ // Fixes aws-sdk InvalidSignatureException, more info:
452
+ // https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1609#issuecomment-1826167348
472
453
473
- req . end ( )
474
- } )
475
- } )
476
-
477
- it ( 'should skip injecting if one of the Authorization headers contains an AWS signature' , done => {
478
454
const app = express ( )
479
455
480
- app . get ( '/' , ( req , res ) => {
481
- try {
482
- expect ( req . get ( 'x-datadog-trace-id' ) ) . to . be . undefined
483
- expect ( req . get ( 'x-datadog-parent-id' ) ) . to . be . undefined
484
-
485
- res . status ( 200 ) . send ( )
486
-
487
- done ( )
488
- } catch ( e ) {
489
- done ( e )
490
- }
491
- } )
492
-
493
- appListener = server ( app , port => {
494
- const req = http . request ( {
495
- port,
496
- headers : {
497
- Authorization : [ 'AWS4-HMAC-SHA256 ...' ]
498
- }
499
- } )
500
-
501
- req . end ( )
502
- } )
503
- } )
504
-
505
- it ( 'should skip injecting if the X-Amz-Signature header is set' , done => {
506
- const app = express ( )
456
+ const originalHeaders = {
457
+ Authorization : 'AWS4-HMAC-SHA256 ...'
458
+ }
507
459
508
460
app . get ( '/' , ( req , res ) => {
509
461
try {
510
- expect ( req . get ( 'x-datadog-trace-id' ) ) . to . be . undefined
511
- expect ( req . get ( 'x-datadog-parent-id' ) ) . to . be . undefined
512
-
513
- res . status ( 200 ) . send ( )
514
-
515
- done ( )
516
- } catch ( e ) {
517
- done ( e )
518
- }
519
- } )
520
-
521
- appListener = server ( app , port => {
522
- const req = http . request ( {
523
- port,
524
- headers : {
525
- 'X-Amz-Signature' : 'abc123'
526
- }
527
- } )
528
-
529
- req . end ( )
530
- } )
531
- } )
532
-
533
- it ( 'should skip injecting if the X-Amz-Signature query param is set' , done => {
534
- const app = express ( )
462
+ expect ( req . get ( 'x-datadog-trace-id' ) ) . to . be . a ( 'string' )
463
+ expect ( req . get ( 'x-datadog-parent-id' ) ) . to . be . a ( 'string' )
535
464
536
- app . get ( '/' , ( req , res ) => {
537
- try {
538
- expect ( req . get ( 'x-datadog-trace-id' ) ) . to . be . undefined
539
- expect ( req . get ( 'x-datadog-parent-id' ) ) . to . be . undefined
465
+ expect ( originalHeaders [ 'x-datadog-trace-id' ] ) . to . be . undefined
466
+ expect ( originalHeaders [ 'x-datadog-parent-id' ] ) . to . be . undefined
540
467
541
468
res . status ( 200 ) . send ( )
542
469
@@ -549,7 +476,7 @@ describe('Plugin', () => {
549
476
appListener = server ( app , port => {
550
477
const req = http . request ( {
551
478
port,
552
- path : '/?X-Amz-Signature=abc123'
479
+ headers : originalHeaders
553
480
} )
554
481
555
482
req . end ( )
@@ -1093,50 +1020,6 @@ describe('Plugin', () => {
1093
1020
} )
1094
1021
} )
1095
1022
1096
- describe ( 'with config enablePropagationWithAmazonHeaders enabled' , ( ) => {
1097
- let config
1098
-
1099
- beforeEach ( ( ) => {
1100
- config = {
1101
- enablePropagationWithAmazonHeaders : true
1102
- }
1103
-
1104
- return agent . load ( 'http' , config )
1105
- . then ( ( ) => {
1106
- http = require ( pluginToBeLoaded )
1107
- express = require ( 'express' )
1108
- } )
1109
- } )
1110
-
1111
- it ( 'should inject tracing header into AWS signed request' , done => {
1112
- const app = express ( )
1113
-
1114
- app . get ( '/' , ( req , res ) => {
1115
- try {
1116
- expect ( req . get ( 'x-datadog-trace-id' ) ) . to . be . a ( 'string' )
1117
- expect ( req . get ( 'x-datadog-parent-id' ) ) . to . be . a ( 'string' )
1118
-
1119
- res . status ( 200 ) . send ( )
1120
-
1121
- done ( )
1122
- } catch ( e ) {
1123
- done ( e )
1124
- }
1125
- } )
1126
-
1127
- appListener = server ( app , port => {
1128
- const req = http . request ( {
1129
- port,
1130
- headers : {
1131
- Authorization : 'AWS4-HMAC-SHA256 ...'
1132
- }
1133
- } )
1134
-
1135
- req . end ( )
1136
- } )
1137
- } )
1138
- } )
1139
-
1140
1023
describe ( 'with validateStatus configuration' , ( ) => {
1141
1024
let config
1142
1025
0 commit comments