@@ -23,6 +23,7 @@ import (
2323 "github.com/aws/aws-sdk-go/aws/request"
2424 "github.com/aws/aws-sdk-go/internal/sdktesting"
2525 "github.com/aws/aws-sdk-go/internal/shareddefaults"
26+ "github.com/aws/aws-sdk-go/private/protocol"
2627 "github.com/aws/aws-sdk-go/service/sts"
2728)
2829
@@ -63,11 +64,31 @@ func setupCredentialsEndpoints(t *testing.T) (endpoints.Resolver, func()) {
6364
6465 stsServer := httptest .NewServer (http .HandlerFunc (
6566 func (w http.ResponseWriter , r * http.Request ) {
66- w .Write ([]byte (fmt .Sprintf (
67- assumeRoleRespMsg ,
68- time .Now ().
69- Add (15 * time .Minute ).
70- Format ("2006-01-02T15:04:05Z" ))))
67+ if err := r .ParseForm (); err != nil {
68+ w .WriteHeader (500 )
69+ return
70+ }
71+
72+ form := r .Form
73+
74+ switch form .Get ("Action" ) {
75+ case "AssumeRole" :
76+ w .Write ([]byte (fmt .Sprintf (
77+ assumeRoleRespMsg ,
78+ time .Now ().
79+ Add (15 * time .Minute ).
80+ Format (protocol .ISO8601TimeFormat ))))
81+ return
82+ case "AssumeRoleWithWebIdentity" :
83+ w .Write ([]byte (fmt .Sprintf (assumeRoleWithWebIdentityResponse ,
84+ time .Now ().
85+ Add (15 * time .Minute ).
86+ Format (protocol .ISO8601TimeFormat ))))
87+ return
88+ default :
89+ w .WriteHeader (404 )
90+ return
91+ }
7192 }))
7293
7394 ssoServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
@@ -275,6 +296,23 @@ func TestSharedConfigCredentialSource(t *testing.T) {
275296 return func () {}, nil
276297 },
277298 },
299+ {
300+ name : "sso mixed with credential process provider" ,
301+ profile : "sso_mixed_credproc" ,
302+ expectedAccessKey : "SSO_AKID" ,
303+ expectedSecretKey : "SSO_SECRET_KEY" ,
304+ expectedSessionToken : "SSO_SESSION_TOKEN" ,
305+ init : func () (func (), error ) {
306+ return ssoTestSetup ()
307+ },
308+ },
309+ {
310+ name : "sso mixed with web identity token provider" ,
311+ profile : "sso_mixed_webident" ,
312+ expectedAccessKey : "WEB_IDENTITY_AKID" ,
313+ expectedSecretKey : "WEB_IDENTITY_SECRET" ,
314+ expectedSessionToken : "WEB_IDENTITY_SESSION_TOKEN" ,
315+ },
278316 }
279317
280318 for i , c := range cases {
@@ -403,6 +441,28 @@ const assumeRoleRespMsg = `
403441</AssumeRoleResponse>
404442`
405443
444+ var assumeRoleWithWebIdentityResponse = `<AssumeRoleWithWebIdentityResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
445+ <AssumeRoleWithWebIdentityResult>
446+ <SubjectFromWebIdentityToken>amzn1.account.AF6RHO7KZU5XRVQJGXK6HB56KR2A</SubjectFromWebIdentityToken>
447+ <Audience>client.5498841531868486423.1548@apps.example.com</Audience>
448+ <AssumedRoleUser>
449+ <Arn>arn:aws:sts::123456789012:assumed-role/FederatedWebIdentityRole/app1</Arn>
450+ <AssumedRoleId>AROACLKWSDQRAOEXAMPLE:app1</AssumedRoleId>
451+ </AssumedRoleUser>
452+ <Credentials>
453+ <AccessKeyId>WEB_IDENTITY_AKID</AccessKeyId>
454+ <SecretAccessKey>WEB_IDENTITY_SECRET</SecretAccessKey>
455+ <SessionToken>WEB_IDENTITY_SESSION_TOKEN</SessionToken>
456+ <Expiration>%s</Expiration>
457+ </Credentials>
458+ <Provider>www.amazon.com</Provider>
459+ </AssumeRoleWithWebIdentityResult>
460+ <ResponseMetadata>
461+ <RequestId>request-id</RequestId>
462+ </ResponseMetadata>
463+ </AssumeRoleWithWebIdentityResponse>
464+ `
465+
406466const getRoleCredentialsResponse = `{
407467 "roleCredentials": {
408468 "accessKeyId": "SSO_AKID",
0 commit comments