mirror of
https://github.com/rclone/rclone.git
synced 2026-01-03 17:13:18 +00:00
vendor: switch to using go1.11 modules
This commit is contained in:
45
vendor/github.com/aws/aws-sdk-go/service/sts/customizations_test.go
generated
vendored
45
vendor/github.com/aws/aws-sdk-go/service/sts/customizations_test.go
generated
vendored
@@ -1,45 +0,0 @@
|
||||
package sts_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"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()
|
||||
if err != nil {
|
||||
t.Errorf("expect no error, got %v", err)
|
||||
}
|
||||
if e, a := "", req.HTTPRequest.Header.Get("Authorization"); e != a {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
if err != nil {
|
||||
t.Errorf("expect no error, got %v", err)
|
||||
}
|
||||
if e, a := "", req.HTTPRequest.Header.Get("Authorization"); e != a {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
}
|
||||
282
vendor/github.com/aws/aws-sdk-go/service/sts/examples_test.go
generated
vendored
282
vendor/github.com/aws/aws-sdk-go/service/sts/examples_test.go
generated
vendored
@@ -1,282 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package sts_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/sts"
|
||||
)
|
||||
|
||||
var _ time.Duration
|
||||
var _ strings.Reader
|
||||
var _ aws.Config
|
||||
|
||||
func parseTime(layout, value string) *time.Time {
|
||||
t, err := time.Parse(layout, value)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &t
|
||||
}
|
||||
|
||||
// To assume a role
|
||||
//
|
||||
|
||||
func ExampleSTS_AssumeRole_shared00() {
|
||||
svc := sts.New(session.New())
|
||||
input := &sts.AssumeRoleInput{
|
||||
DurationSeconds: aws.Int64(3600),
|
||||
ExternalId: aws.String("123ABC"),
|
||||
Policy: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"Stmt1\",\"Effect\":\"Allow\",\"Action\":\"s3:*\",\"Resource\":\"*\"}]}"),
|
||||
RoleArn: aws.String("arn:aws:iam::123456789012:role/demo"),
|
||||
RoleSessionName: aws.String("Bob"),
|
||||
}
|
||||
|
||||
result, err := svc.AssumeRole(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case sts.ErrCodeMalformedPolicyDocumentException:
|
||||
fmt.Println(sts.ErrCodeMalformedPolicyDocumentException, aerr.Error())
|
||||
case sts.ErrCodePackedPolicyTooLargeException:
|
||||
fmt.Println(sts.ErrCodePackedPolicyTooLargeException, aerr.Error())
|
||||
case sts.ErrCodeRegionDisabledException:
|
||||
fmt.Println(sts.ErrCodeRegionDisabledException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To assume a role as an OpenID Connect-federated user
|
||||
//
|
||||
|
||||
func ExampleSTS_AssumeRoleWithWebIdentity_shared00() {
|
||||
svc := sts.New(session.New())
|
||||
input := &sts.AssumeRoleWithWebIdentityInput{
|
||||
DurationSeconds: aws.Int64(3600),
|
||||
ProviderId: aws.String("www.amazon.com"),
|
||||
RoleArn: aws.String("arn:aws:iam::123456789012:role/FederatedWebIdentityRole"),
|
||||
RoleSessionName: aws.String("app1"),
|
||||
WebIdentityToken: aws.String("Atza%7CIQEBLjAsAhRFiXuWpUXuRvQ9PZL3GMFcYevydwIUFAHZwXZXXXXXXXXJnrulxKDHwy87oGKPznh0D6bEQZTSCzyoCtL_8S07pLpr0zMbn6w1lfVZKNTBdDansFBmtGnIsIapjI6xKR02Yc_2bQ8LZbUXSGm6Ry6_BG7PrtLZtj_dfCTj92xNGed-CrKqjG7nPBjNIL016GGvuS5gSvPRUxWES3VYfm1wl7WTI7jn-Pcb6M-buCgHhFOzTQxod27L9CqnOLio7N3gZAGpsp6n1-AJBOCJckcyXe2c6uD0srOJeZlKUm2eTDVMf8IehDVI0r1QOnTV6KzzAI3OY87Vd_cVMQ"),
|
||||
}
|
||||
|
||||
result, err := svc.AssumeRoleWithWebIdentity(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case sts.ErrCodeMalformedPolicyDocumentException:
|
||||
fmt.Println(sts.ErrCodeMalformedPolicyDocumentException, aerr.Error())
|
||||
case sts.ErrCodePackedPolicyTooLargeException:
|
||||
fmt.Println(sts.ErrCodePackedPolicyTooLargeException, aerr.Error())
|
||||
case sts.ErrCodeIDPRejectedClaimException:
|
||||
fmt.Println(sts.ErrCodeIDPRejectedClaimException, aerr.Error())
|
||||
case sts.ErrCodeIDPCommunicationErrorException:
|
||||
fmt.Println(sts.ErrCodeIDPCommunicationErrorException, aerr.Error())
|
||||
case sts.ErrCodeInvalidIdentityTokenException:
|
||||
fmt.Println(sts.ErrCodeInvalidIdentityTokenException, aerr.Error())
|
||||
case sts.ErrCodeExpiredTokenException:
|
||||
fmt.Println(sts.ErrCodeExpiredTokenException, aerr.Error())
|
||||
case sts.ErrCodeRegionDisabledException:
|
||||
fmt.Println(sts.ErrCodeRegionDisabledException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To decode information about an authorization status of a request
|
||||
//
|
||||
|
||||
func ExampleSTS_DecodeAuthorizationMessage_shared00() {
|
||||
svc := sts.New(session.New())
|
||||
input := &sts.DecodeAuthorizationMessageInput{
|
||||
EncodedMessage: aws.String("<encoded-message>"),
|
||||
}
|
||||
|
||||
result, err := svc.DecodeAuthorizationMessage(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case sts.ErrCodeInvalidAuthorizationMessageException:
|
||||
fmt.Println(sts.ErrCodeInvalidAuthorizationMessageException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To get details about a calling IAM user
|
||||
//
|
||||
// This example shows a request and response made with the credentials for a user named
|
||||
// Alice in the AWS account 123456789012.
|
||||
func ExampleSTS_GetCallerIdentity_shared00() {
|
||||
svc := sts.New(session.New())
|
||||
input := &sts.GetCallerIdentityInput{}
|
||||
|
||||
result, err := svc.GetCallerIdentity(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To get details about a calling user federated with AssumeRole
|
||||
//
|
||||
// This example shows a request and response made with temporary credentials created
|
||||
// by AssumeRole. The name of the assumed role is my-role-name, and the RoleSessionName
|
||||
// is set to my-role-session-name.
|
||||
func ExampleSTS_GetCallerIdentity_shared01() {
|
||||
svc := sts.New(session.New())
|
||||
input := &sts.GetCallerIdentityInput{}
|
||||
|
||||
result, err := svc.GetCallerIdentity(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To get details about a calling user federated with GetFederationToken
|
||||
//
|
||||
// This example shows a request and response made with temporary credentials created
|
||||
// by using GetFederationToken. The Name parameter is set to my-federated-user-name.
|
||||
func ExampleSTS_GetCallerIdentity_shared02() {
|
||||
svc := sts.New(session.New())
|
||||
input := &sts.GetCallerIdentityInput{}
|
||||
|
||||
result, err := svc.GetCallerIdentity(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To get temporary credentials for a role by using GetFederationToken
|
||||
//
|
||||
|
||||
func ExampleSTS_GetFederationToken_shared00() {
|
||||
svc := sts.New(session.New())
|
||||
input := &sts.GetFederationTokenInput{
|
||||
DurationSeconds: aws.Int64(3600),
|
||||
Name: aws.String("Bob"),
|
||||
Policy: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"Stmt1\",\"Effect\":\"Allow\",\"Action\":\"s3:*\",\"Resource\":\"*\"}]}"),
|
||||
}
|
||||
|
||||
result, err := svc.GetFederationToken(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case sts.ErrCodeMalformedPolicyDocumentException:
|
||||
fmt.Println(sts.ErrCodeMalformedPolicyDocumentException, aerr.Error())
|
||||
case sts.ErrCodePackedPolicyTooLargeException:
|
||||
fmt.Println(sts.ErrCodePackedPolicyTooLargeException, aerr.Error())
|
||||
case sts.ErrCodeRegionDisabledException:
|
||||
fmt.Println(sts.ErrCodeRegionDisabledException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To get temporary credentials for an IAM user or an AWS account
|
||||
//
|
||||
|
||||
func ExampleSTS_GetSessionToken_shared00() {
|
||||
svc := sts.New(session.New())
|
||||
input := &sts.GetSessionTokenInput{
|
||||
DurationSeconds: aws.Int64(3600),
|
||||
SerialNumber: aws.String("YourMFASerialNumber"),
|
||||
TokenCode: aws.String("123456"),
|
||||
}
|
||||
|
||||
result, err := svc.GetSessionToken(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case sts.ErrCodeRegionDisabledException:
|
||||
fmt.Println(sts.ErrCodeRegionDisabledException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
92
vendor/github.com/aws/aws-sdk-go/service/sts/stsiface/interface.go
generated
vendored
92
vendor/github.com/aws/aws-sdk-go/service/sts/stsiface/interface.go
generated
vendored
@@ -1,92 +0,0 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package stsiface provides an interface to enable mocking the AWS Security Token Service service client
|
||||
// for testing your code.
|
||||
//
|
||||
// It is important to note that this interface will have breaking changes
|
||||
// when the service model is updated and adds new API operations, paginators,
|
||||
// and waiters.
|
||||
package stsiface
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/service/sts"
|
||||
)
|
||||
|
||||
// STSAPI provides an interface to enable mocking the
|
||||
// sts.STS service client's API operation,
|
||||
// paginators, and waiters. This make unit testing your code that calls out
|
||||
// to the SDK's service client's calls easier.
|
||||
//
|
||||
// The best way to use this interface is so the SDK's service client's calls
|
||||
// can be stubbed out for unit testing your code with the SDK without needing
|
||||
// to inject custom request handlers into the SDK's request pipeline.
|
||||
//
|
||||
// // myFunc uses an SDK service client to make a request to
|
||||
// // AWS Security Token Service.
|
||||
// func myFunc(svc stsiface.STSAPI) bool {
|
||||
// // Make svc.AssumeRole request
|
||||
// }
|
||||
//
|
||||
// func main() {
|
||||
// sess := session.New()
|
||||
// svc := sts.New(sess)
|
||||
//
|
||||
// myFunc(svc)
|
||||
// }
|
||||
//
|
||||
// In your _test.go file:
|
||||
//
|
||||
// // Define a mock struct to be used in your unit tests of myFunc.
|
||||
// type mockSTSClient struct {
|
||||
// stsiface.STSAPI
|
||||
// }
|
||||
// func (m *mockSTSClient) AssumeRole(input *sts.AssumeRoleInput) (*sts.AssumeRoleOutput, error) {
|
||||
// // mock response/functionality
|
||||
// }
|
||||
//
|
||||
// func TestMyFunc(t *testing.T) {
|
||||
// // Setup Test
|
||||
// mockSvc := &mockSTSClient{}
|
||||
//
|
||||
// myfunc(mockSvc)
|
||||
//
|
||||
// // Verify myFunc's functionality
|
||||
// }
|
||||
//
|
||||
// It is important to note that this interface will have breaking changes
|
||||
// when the service model is updated and adds new API operations, paginators,
|
||||
// and waiters. Its suggested to use the pattern above for testing, or using
|
||||
// tooling to generate mocks to satisfy the interfaces.
|
||||
type STSAPI interface {
|
||||
AssumeRole(*sts.AssumeRoleInput) (*sts.AssumeRoleOutput, error)
|
||||
AssumeRoleWithContext(aws.Context, *sts.AssumeRoleInput, ...request.Option) (*sts.AssumeRoleOutput, error)
|
||||
AssumeRoleRequest(*sts.AssumeRoleInput) (*request.Request, *sts.AssumeRoleOutput)
|
||||
|
||||
AssumeRoleWithSAML(*sts.AssumeRoleWithSAMLInput) (*sts.AssumeRoleWithSAMLOutput, error)
|
||||
AssumeRoleWithSAMLWithContext(aws.Context, *sts.AssumeRoleWithSAMLInput, ...request.Option) (*sts.AssumeRoleWithSAMLOutput, error)
|
||||
AssumeRoleWithSAMLRequest(*sts.AssumeRoleWithSAMLInput) (*request.Request, *sts.AssumeRoleWithSAMLOutput)
|
||||
|
||||
AssumeRoleWithWebIdentity(*sts.AssumeRoleWithWebIdentityInput) (*sts.AssumeRoleWithWebIdentityOutput, error)
|
||||
AssumeRoleWithWebIdentityWithContext(aws.Context, *sts.AssumeRoleWithWebIdentityInput, ...request.Option) (*sts.AssumeRoleWithWebIdentityOutput, error)
|
||||
AssumeRoleWithWebIdentityRequest(*sts.AssumeRoleWithWebIdentityInput) (*request.Request, *sts.AssumeRoleWithWebIdentityOutput)
|
||||
|
||||
DecodeAuthorizationMessage(*sts.DecodeAuthorizationMessageInput) (*sts.DecodeAuthorizationMessageOutput, error)
|
||||
DecodeAuthorizationMessageWithContext(aws.Context, *sts.DecodeAuthorizationMessageInput, ...request.Option) (*sts.DecodeAuthorizationMessageOutput, error)
|
||||
DecodeAuthorizationMessageRequest(*sts.DecodeAuthorizationMessageInput) (*request.Request, *sts.DecodeAuthorizationMessageOutput)
|
||||
|
||||
GetCallerIdentity(*sts.GetCallerIdentityInput) (*sts.GetCallerIdentityOutput, error)
|
||||
GetCallerIdentityWithContext(aws.Context, *sts.GetCallerIdentityInput, ...request.Option) (*sts.GetCallerIdentityOutput, error)
|
||||
GetCallerIdentityRequest(*sts.GetCallerIdentityInput) (*request.Request, *sts.GetCallerIdentityOutput)
|
||||
|
||||
GetFederationToken(*sts.GetFederationTokenInput) (*sts.GetFederationTokenOutput, error)
|
||||
GetFederationTokenWithContext(aws.Context, *sts.GetFederationTokenInput, ...request.Option) (*sts.GetFederationTokenOutput, error)
|
||||
GetFederationTokenRequest(*sts.GetFederationTokenInput) (*request.Request, *sts.GetFederationTokenOutput)
|
||||
|
||||
GetSessionToken(*sts.GetSessionTokenInput) (*sts.GetSessionTokenOutput, error)
|
||||
GetSessionTokenWithContext(aws.Context, *sts.GetSessionTokenInput, ...request.Option) (*sts.GetSessionTokenOutput, error)
|
||||
GetSessionTokenRequest(*sts.GetSessionTokenInput) (*request.Request, *sts.GetSessionTokenOutput)
|
||||
}
|
||||
|
||||
var _ STSAPI = (*sts.STS)(nil)
|
||||
Reference in New Issue
Block a user