@@ -494,3 +494,96 @@ func TestValidationAllowList_NoPathsRegistered(t *testing.T) {
494
494
assert .False (t , ignore )
495
495
496
496
}
497
+
498
+ func TestGetRewriteHeaderValues (t * testing.T ) {
499
+
500
+ expectedValue := []string {"ExpectedValue" }
501
+
502
+ requestList := []* http.Request {
503
+ {
504
+ Header : http.Header {
505
+ "Rewriteid" : expectedValue ,
506
+ "Other-Header" : []string {"another header" },
507
+ "other-header" : []string {"another another header" },
508
+ },
509
+ },
510
+ {
511
+ Header : http.Header {
512
+ "Rewrite-Id" : expectedValue ,
513
+ "Other-Header" : []string {"another header" },
514
+ "other-header" : []string {"another another header" },
515
+ },
516
+ },
517
+ {
518
+ Header : http.Header {
519
+ "Rewrite_id" : expectedValue ,
520
+ "Other-Header" : []string {"another header" },
521
+ "other-header" : []string {"another another header" },
522
+ },
523
+ },
524
+ {
525
+ Header : http.Header {
526
+ "RewriteId" : expectedValue ,
527
+ "Other-Header" : []string {"another header" },
528
+ "other-header" : []string {"another another header" },
529
+ },
530
+ },
531
+ {
532
+ Header : http.Header {
533
+ "RewrIte-Id" : expectedValue ,
534
+ "Other-Header" : []string {"another header" },
535
+ "other-header" : []string {"another another header" },
536
+ },
537
+ },
538
+ {
539
+ Header : http.Header {
540
+ "rewriteid" : expectedValue ,
541
+ "Other-Header" : []string {"another header" },
542
+ "other-header" : []string {"another another header" },
543
+ },
544
+ },
545
+ {
546
+ Header : http.Header {
547
+ "rewrite-id" : expectedValue ,
548
+ "Other-Header" : []string {"another header" },
549
+ "other-header" : []string {"another another header" },
550
+ },
551
+ },
552
+ {
553
+ Header : http.Header {
554
+ "rewrite_id" : expectedValue ,
555
+ "Other-Header" : []string {"another header" },
556
+ "other-header" : []string {"another another header" },
557
+ },
558
+ },
559
+ }
560
+
561
+ for _ , request := range requestList {
562
+ actualValue , found := getRewriteIdHeaderValues (request )
563
+ assert .Equal (t , expectedValue , actualValue )
564
+ assert .True (t , found )
565
+ }
566
+
567
+ }
568
+
569
+ func TestGetRewriteHeaderValues_MissingHeader (t * testing.T ) {
570
+
571
+ requestList := []* http.Request {
572
+ {
573
+ Header : http.Header {
574
+ "Other-Header" : []string {"another header" },
575
+ "other-header" : []string {"another another header" },
576
+ },
577
+ },
578
+ {
579
+ Header : http.Header {},
580
+ },
581
+ }
582
+
583
+ for _ , request := range requestList {
584
+ actualValue , found := getRewriteIdHeaderValues (request )
585
+ assert .Equal (t , []string {}, actualValue )
586
+ assert .False (t , found )
587
+ }
588
+
589
+ }
0 commit comments