@@ -46,15 +46,34 @@ describe(getResolvedSigningRegion.name, () => {
46
46
expect ( isFipsRegion ) . toHaveBeenCalledTimes ( 1 ) ;
47
47
expect ( isFipsRegion ) . toHaveBeenCalledWith ( mockRegion ) ;
48
48
} ) ;
49
+
50
+ it ( "region is not present between dots in a hostname" , ( ) => {
51
+ const regionInHostname = "us-east-1" ;
52
+ ( isFipsRegion as jest . Mock ) . mockReturnValueOnce ( true ) ;
53
+
54
+ expect (
55
+ getResolvedSigningRegion ( mockRegion , {
56
+ ...mockOptions ,
57
+ hostname : `test-${ regionInHostname } .amazonaws.com` ,
58
+ regionRegex : "^(us|eu|ap|sa|ca|me|af)\\-\\w+\\-\\d+$" ,
59
+ } )
60
+ ) . not . toBeDefined ( ) ;
61
+ expect ( isFipsRegion ) . toHaveBeenCalledTimes ( 1 ) ;
62
+ expect ( isFipsRegion ) . toHaveBeenCalledWith ( mockRegion ) ;
63
+ } ) ;
49
64
} ) ;
50
65
51
- it ( "returns region from hostname is signingRegion is not present" , ( ) => {
66
+ it ( "returns region from hostname if signingRegion is not present" , ( ) => {
67
+ const regionInHostname = "us-east-1" ;
52
68
( isFipsRegion as jest . Mock ) . mockReturnValueOnce ( true ) ;
53
- const matchSpy = jest . spyOn ( String . prototype , "match" ) . mockReturnValueOnce ( [ `.${ mockSigningRegion } .` ] ) ;
54
69
55
- expect ( getResolvedSigningRegion ( mockRegion , mockOptions ) ) . toEqual ( mockSigningRegion ) ;
56
- expect ( matchSpy ) . toHaveBeenCalledTimes ( 1 ) ;
57
- expect ( matchSpy ) . toHaveBeenCalledWith ( mockRegionRegex ) ;
70
+ expect (
71
+ getResolvedSigningRegion ( mockRegion , {
72
+ ...mockOptions ,
73
+ hostname : `test.${ regionInHostname } .amazonaws.com` ,
74
+ regionRegex : "^(us|eu|ap|sa|ca|me|af)\\-\\w+\\-\\d+$" ,
75
+ } )
76
+ ) . toEqual ( regionInHostname ) ;
58
77
expect ( isFipsRegion ) . toHaveBeenCalledTimes ( 1 ) ;
59
78
expect ( isFipsRegion ) . toHaveBeenCalledWith ( mockRegion ) ;
60
79
} ) ;
0 commit comments