@@ -52,6 +52,10 @@ func (tc testCase) Run(t *testing.T) {
5252 assert .Equal (t , accessKey , creds .AccessKeyID )
5353 assert .Equal (t , secret , creds .SecretAccessKey )
5454 }
55+ if isStsEndpoint (& tc .authSettings .Endpoint ) {
56+ assert .Equal (t , tc .authSettings .Endpoint , * client .assumeRoleClient .stsConfig .BaseEndpoint )
57+ assert .Nil (t , cfg .BaseEndpoint )
58+ }
5559}
5660
5761func (tc testCase ) assertConfig (t * testing.T , cfg aws.Config ) {
@@ -134,6 +138,15 @@ func TestGetAWSConfig_Keys(t *testing.T) {
134138 Region : "ap-south-1" ,
135139 },
136140 },
141+ {
142+ name : "static credentials, sts endpoint" ,
143+ authSettings : Settings {
144+ LegacyAuthType : awsds .AuthTypeKeys ,
145+ AccessKey : "ubiquitous" ,
146+ SecretKey : "malevolent" ,
147+ Region : "ap-south-1" ,
148+ },
149+ },
137150 }.runAll (t )
138151}
139152
@@ -155,6 +168,23 @@ func TestGetAWSConfig_Keys_AssumeRule(t *testing.T) {
155168 Expiration : aws .Time (time .Now ().Add (time .Hour )),
156169 },
157170 },
171+ {
172+ name : "static assume role with sts endpoint - endpoint is nil" ,
173+ authSettings : Settings {
174+ AuthType : AuthTypeKeys ,
175+ AccessKey : "tensile" ,
176+ SecretKey : "diaphanous" ,
177+ Region : "us-east-1" ,
178+ Endpoint : "sts.us-east-1.amazonaws.com" ,
179+ AssumeRoleARN : "arn:aws:iam::1234567890:role/aws-service-role" ,
180+ },
181+ assumedCredentials : & ststypes.Credentials {
182+ AccessKeyId : aws .String ("assumed" ),
183+ SecretAccessKey : aws .String ("role" ),
184+ SessionToken : aws .String ("session" ),
185+ Expiration : aws .Time (time .Now ().Add (time .Hour )),
186+ },
187+ },
158188 {
159189 name : "static assume role with failure" ,
160190 authSettings : Settings {
@@ -227,25 +257,26 @@ func TestGetAWSConfig_Shared(t *testing.T) {
227257func TestGetAWSConfig_UnknownOrMissing (t * testing.T ) {
228258 testSuite {
229259 {
230- name : "shared reads from specified file " ,
260+ name : "unknown auth type fails " ,
231261 authSettings : Settings {
232262 AuthType : AuthTypeUnknown ,
233263 },
234264 shouldError : true ,
235265 },
236266 {
237- name : "grafana assume role uses the shared mechanism " ,
267+ name : "random auth type fails " ,
238268 authSettings : Settings {
239- AuthType : AuthTypeMissing ,
269+ AuthType : "rainbows" ,
240270 },
241271 shouldError : true ,
242272 },
243273 {
244- name : "grafana assume role uses the shared mechanism" ,
245- authSettings : Settings {
246- AuthType : "rainbows" ,
274+ name : "missing auth type fails back to legacy default (and does not fail)" ,
275+ authSettings : Settings {},
276+ environment : map [string ]string {
277+ "AWS_SHARED_CREDENTIALS_FILE" : testDataPath ("credentials" ),
247278 },
248- shouldError : true ,
279+ shouldError : false ,
249280 },
250281 }.runAll (t )
251282}
0 commit comments