File tree Expand file tree Collapse file tree 2 files changed +10
-31
lines changed Expand file tree Collapse file tree 2 files changed +10
-31
lines changed Original file line number Diff line number Diff line change 33namespace AsyncAws \Core \Sts ;
44
55use AsyncAws \Core \AbstractApi ;
6- use AsyncAws \Core \Exception \UnsupportedRegion ;
76use AsyncAws \Core \RequestContext ;
87use AsyncAws \Core \Sts \Input \AssumeRoleRequest ;
98use AsyncAws \Core \Sts \Input \AssumeRoleWithWebIdentityRequest ;
@@ -107,32 +106,6 @@ protected function getEndpointMetadata(?string $region): array
107106 }
108107
109108 switch ($ region ) {
110- case 'af-south-1 ' :
111- case 'ap-east-1 ' :
112- case 'ap-northeast-1 ' :
113- case 'ap-northeast-2 ' :
114- case 'ap-south-1 ' :
115- case 'ap-southeast-1 ' :
116- case 'ap-southeast-2 ' :
117- case 'ca-central-1 ' :
118- case 'eu-central-1 ' :
119- case 'eu-north-1 ' :
120- case 'eu-south-1 ' :
121- case 'eu-west-1 ' :
122- case 'eu-west-2 ' :
123- case 'eu-west-3 ' :
124- case 'me-south-1 ' :
125- case 'sa-east-1 ' :
126- case 'us-east-1 ' :
127- case 'us-east-2 ' :
128- case 'us-west-1 ' :
129- case 'us-west-2 ' :
130- return [
131- 'endpoint ' => "https://sts. $ region.amazonaws.com " ,
132- 'signRegion ' => $ region ,
133- 'signService ' => 'sts ' ,
134- 'signVersions ' => ['v4 ' ],
135- ];
136109 case 'cn-north-1 ' :
137110 case 'cn-northwest-1 ' :
138111 return [
@@ -207,7 +180,12 @@ protected function getEndpointMetadata(?string $region): array
207180 ];
208181 }
209182
210- throw new UnsupportedRegion (sprintf ('The region "%s" is not supported by "Sts". ' , $ region ));
183+ return [
184+ 'endpoint ' => "https://sts. $ region.amazonaws.com " ,
185+ 'signRegion ' => $ region ,
186+ 'signService ' => 'sts ' ,
187+ 'signVersions ' => ['v4 ' ],
188+ ];
211189 }
212190
213191 protected function getServiceCode (): string
Original file line number Diff line number Diff line change 33namespace AsyncAws \Core \Tests \Integration ;
44
55use AsyncAws \Core \Credentials \NullProvider ;
6- use AsyncAws \Core \Exception \UnsupportedRegion ;
76use AsyncAws \Core \Sts \Input \AssumeRoleRequest ;
87use AsyncAws \Core \Sts \Input \AssumeRoleWithWebIdentityRequest ;
98use AsyncAws \Core \Sts \Input \GetCallerIdentityRequest ;
@@ -96,14 +95,16 @@ public function testNonAwsRegionWithCustomEndpoint(): void
9695 self ::assertNotEmpty ($ client ->presign (new AssumeRoleRequest (['RoleArn ' => 'demo ' , 'RoleSessionName ' => 'demo ' ])));
9796 }
9897
98+ /**
99+ * A region that is not recognized should be treated as "default" region.
100+ */
99101 public function testNonAwsRegion (): void
100102 {
101103 $ client = new StsClient ([
102104 'region ' => 'test ' ,
103105 ], new NullProvider ());
104106
105- $ this ->expectException (UnsupportedRegion::class);
106- $ client ->presign (new AssumeRoleRequest (['RoleArn ' => 'demo ' , 'RoleSessionName ' => 'demo ' ]));
107+ self ::assertNotEmpty ($ client ->presign (new AssumeRoleRequest (['RoleArn ' => 'demo ' , 'RoleSessionName ' => 'demo ' ])));
107108 }
108109
109110 public function testCustomEndpointSignature (): void
You can’t perform that action at this time.
0 commit comments