mirror of
https://github.com/rclone/rclone.git
synced 2024-12-03 05:45:24 +01:00
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
|
package sts_test
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
|
||
|
"github.com/aws/aws-sdk-go/aws"
|
||
|
"github.com/aws/aws-sdk-go/awstesting/unit"
|
||
|
"github.com/aws/aws-sdk-go/service/sts"
|
||
|
)
|
||
|
|
||
|
var svc = sts.New(unit.Session, &aws.Config{
|
||
|
Region: aws.String("mock-region"),
|
||
|
})
|
||
|
|
||
|
func TestUnsignedRequest_AssumeRoleWithSAML(t *testing.T) {
|
||
|
req, _ := svc.AssumeRoleWithSAMLRequest(&sts.AssumeRoleWithSAMLInput{
|
||
|
PrincipalArn: aws.String("ARN01234567890123456789"),
|
||
|
RoleArn: aws.String("ARN01234567890123456789"),
|
||
|
SAMLAssertion: aws.String("ASSERT"),
|
||
|
})
|
||
|
|
||
|
err := req.Sign()
|
||
|
assert.NoError(t, err)
|
||
|
assert.Equal(t, "", req.HTTPRequest.Header.Get("Authorization"))
|
||
|
}
|
||
|
|
||
|
func TestUnsignedRequest_AssumeRoleWithWebIdentity(t *testing.T) {
|
||
|
req, _ := svc.AssumeRoleWithWebIdentityRequest(&sts.AssumeRoleWithWebIdentityInput{
|
||
|
RoleArn: aws.String("ARN01234567890123456789"),
|
||
|
RoleSessionName: aws.String("SESSION"),
|
||
|
WebIdentityToken: aws.String("TOKEN"),
|
||
|
})
|
||
|
|
||
|
err := req.Sign()
|
||
|
assert.NoError(t, err)
|
||
|
assert.Equal(t, "", req.HTTPRequest.Header.Get("Authorization"))
|
||
|
}
|