func TestEndpoint_OutpostBucketARN(t *testing.T) {
	cases := map[string]testParams{
		"Outpost Bucket with no S3UseARNRegion flag set": {
			bucket: "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				Region: aws.String("us-west-2"),
			},
			expectedEndpoint:           "https://s3-outposts.us-west-2.amazonaws.com",
			expectedSigningName:        "s3-outposts",
			expectedSigningRegion:      "us-west-2",
			expectedHeaderForOutpostID: "op-01234567890123456",
			expectedHeaderForAccountID: true,
		},
		"Outpost Bucket Cross-Region Enabled": {
			bucket: "arn:aws:s3-outposts:us-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				Region:         aws.String("us-west-2"),
				S3UseARNRegion: aws.Bool(true),
			},
			expectedEndpoint:           "https://s3-outposts.us-east-1.amazonaws.com",
			expectedSigningName:        "s3-outposts",
			expectedSigningRegion:      "us-east-1",
			expectedHeaderForOutpostID: "op-01234567890123456",
			expectedHeaderForAccountID: true,
		},
		"Outpost Bucket Cross-Region Disabled": {
			bucket: "arn:aws:s3-outposts:us-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				Region: aws.String("us-west-2"),
			},
			expectedErr: "client region does not match provided ARN region",
		},
		"Outpost Bucket other partition": {
			bucket: "arn:aws-cn:s3-outposts:cn-north-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				Region:         aws.String("us-west-2"),
				S3UseARNRegion: aws.Bool(true),
			},
			expectedErr: "ConfigurationError: client partition does not match provided ARN partition",
		},
		"Outpost Bucket us-gov region": {
			bucket: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				Region:         aws.String("us-gov-east-1"),
				S3UseARNRegion: aws.Bool(true),
			},
			expectedEndpoint:           "https://s3-outposts.us-gov-east-1.amazonaws.com",
			expectedSigningName:        "s3-outposts",
			expectedSigningRegion:      "us-gov-east-1",
			expectedHeaderForOutpostID: "op-01234567890123456",
			expectedHeaderForAccountID: true,
		},
		"Outpost Bucket Fips region": {
			bucket: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				EndpointResolver: endpoints.AwsUsGovPartition(),
				Region:           aws.String("fips-us-gov-east-1"),
			},
			expectedErr: "ConfigurationError: client region does not match provided ARN region",
		},
		"Outpost Bucket Fips region in Arn": {
			bucket: "arn:aws-us-gov:s3-outposts:fips-us-gov-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				EndpointResolver:        endpoints.AwsUsGovPartition(),
				EnforceShouldRetryCheck: nil,
				Region:                  aws.String("fips-us-gov-east-1"),
				DisableSSL:              nil,
				HTTPClient:              nil,
				S3UseARNRegion:          aws.Bool(true),
			},
			expectedErr: "InvalidARNError: resource ARN not supported for FIPS region",
		},
		"Outpost Bucket Fips region with valid ARN region": {
			bucket: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				EndpointResolver: endpoints.AwsUsGovPartition(),
				Region:           aws.String("fips-us-gov-east-1"),
				S3UseARNRegion:   aws.Bool(true),
			},
			expectedEndpoint:           "https://s3-outposts.us-gov-east-1.amazonaws.com",
			expectedSigningName:        "s3-outposts",
			expectedSigningRegion:      "us-gov-east-1",
			expectedHeaderForOutpostID: "op-01234567890123456",
			expectedHeaderForAccountID: true,
		},
		"Outpost Bucket with DualStack": {
			bucket: "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				Region:       aws.String("us-west-2"),
				UseDualStack: aws.Bool(true),
			},
			expectedErr: "ConfigurationError: client configured for S3 Dual-stack but is not supported with resource ARN",
		},
		"Outpost Bucket with Accelerate": {
			bucket: "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
			config: &aws.Config{
				Region:          aws.String("us-west-2"),
				S3UseAccelerate: aws.Bool(true),
			},
			expectedErr: "ConfigurationError: client configured for S3 Accelerate but is not supported with resource ARN",
		},
		"Missing bucket id": {
			bucket: "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:bucket",
			config: &aws.Config{
				Region:          aws.String("us-west-2"),
				S3UseAccelerate: aws.Bool(true),
			},
			expectedErr: "invalid Amazon s3-outposts ARN",
		},
		"Invalid ARN": {
			bucket: "arn:aws:s3-outposts:us-west-2:123456789012:bucket:mybucket",
			config: &aws.Config{
				Region: aws.String("us-west-2"),
			},
			expectedErr: "invalid Amazon s3-outposts ARN, unknown resource type",
		},
	}

	runValidations(t, cases)
}
// Test endpoint from outpost bucket arn
Test endpoint from outpost bucket arn
// Test endpoint from outpost bucket arn
func TestEndpoint_OutpostBucketARN(t *testing.T) {
	cases := map[string]testParams{
		"Outpost Bucket with no S3UseARNRegion flag set": {
			bucket: "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				Region: aws.String("us-west-2"),
			},
			expectedEndpoint:           "https://s3-outposts.us-west-2.amazonaws.com",
			expectedSigningName:        "s3-outposts",
			expectedSigningRegion:      "us-west-2",
			expectedHeaderForOutpostID: "op-01234567890123456",
			expectedHeaderForAccountID: true,
		},
		"Outpost Bucket Cross-Region Enabled": {
			bucket: "arn:aws:s3-outposts:us-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				Region:         aws.String("us-west-2"),
				S3UseARNRegion: aws.Bool(true),
			},
			expectedEndpoint:           "https://s3-outposts.us-east-1.amazonaws.com",
			expectedSigningName:        "s3-outposts",
			expectedSigningRegion:      "us-east-1",
			expectedHeaderForOutpostID: "op-01234567890123456",
			expectedHeaderForAccountID: true,
		},
		"Outpost Bucket Cross-Region Disabled": {
			bucket: "arn:aws:s3-outposts:us-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				Region: aws.String("us-west-2"),
			},
			expectedErr: "client region does not match provided ARN region",
		},
		"Outpost Bucket other partition": {
			bucket: "arn:aws-cn:s3-outposts:cn-north-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				Region:         aws.String("us-west-2"),
				S3UseARNRegion: aws.Bool(true),
			},
			expectedErr: "ConfigurationError: client partition does not match provided ARN partition",
		},
		"Outpost Bucket us-gov region": {
			bucket: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				Region:         aws.String("us-gov-east-1"),
				S3UseARNRegion: aws.Bool(true),
			},
			expectedEndpoint:           "https://s3-outposts.us-gov-east-1.amazonaws.com",
			expectedSigningName:        "s3-outposts",
			expectedSigningRegion:      "us-gov-east-1",
			expectedHeaderForOutpostID: "op-01234567890123456",
			expectedHeaderForAccountID: true,
		},
		"Outpost Bucket Fips region": {
			bucket: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				EndpointResolver: endpoints.AwsUsGovPartition(),
				Region:           aws.String("fips-us-gov-east-1"),
			},
			expectedErr: "ConfigurationError: client region does not match provided ARN region",
		},
		"Outpost Bucket Fips region in Arn": {
			bucket: "arn:aws-us-gov:s3-outposts:fips-us-gov-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				EndpointResolver:        endpoints.AwsUsGovPartition(),
				EnforceShouldRetryCheck: nil,
				Region:                  aws.String("fips-us-gov-east-1"),
				DisableSSL:              nil,
				HTTPClient:              nil,
				S3UseARNRegion:          aws.Bool(true),
			},
			expectedErr: "InvalidARNError: resource ARN not supported for FIPS region",
		},
		"Outpost Bucket Fips region with valid ARN region": {
			bucket: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				EndpointResolver: endpoints.AwsUsGovPartition(),
				Region:           aws.String("fips-us-gov-east-1"),
				S3UseARNRegion:   aws.Bool(true),
			},
			expectedEndpoint:           "https://s3-outposts.us-gov-east-1.amazonaws.com",
			expectedSigningName:        "s3-outposts",
			expectedSigningRegion:      "us-gov-east-1",
			expectedHeaderForOutpostID: "op-01234567890123456",
			expectedHeaderForAccountID: true,
		},
		"Outpost Bucket with DualStack": {
			bucket: "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:bucket:mybucket",
			config: &aws.Config{
				Region:       aws.String("us-west-2"),
				UseDualStack: aws.Bool(true),
			},
			expectedErr: "ConfigurationError: client configured for S3 Dual-stack but is not supported with resource ARN",
		},
		"Outpost Bucket with Accelerate": {
			bucket: "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
			config: &aws.Config{
				Region:          aws.String("us-west-2"),
				S3UseAccelerate: aws.Bool(true),
			},
			expectedErr: "ConfigurationError: client configured for S3 Accelerate but is not supported with resource ARN",
		},
		"Missing bucket id": {
			bucket: "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:bucket",
			config: &aws.Config{
				Region:          aws.String("us-west-2"),
				S3UseAccelerate: aws.Bool(true),
			},
			expectedErr: "invalid Amazon s3-outposts ARN",
		},
		"Invalid ARN": {
			bucket: "arn:aws:s3-outposts:us-west-2:123456789012:bucket:mybucket",
			config: &aws.Config{
				Region: aws.String("us-west-2"),
			},
			expectedErr: "invalid Amazon s3-outposts ARN, unknown resource type",
		},
	}
	runValidations(t, cases)
}
func TestEndpoint_OutpostBucketARN ( t * testing . T ) { cases := map [ string ] testParams { " " : { bucket : " " , config : & aws . Config { Region : aws . String ( " " ) , } , expectedEndpoint : " " , expectedSigningName : " " , expectedSigningRegion : " " , expectedHeaderForOutpostID : " " , expectedHeaderForAccountID : true , } , " " : { bucket : " " , config : & aws . Config { Region : aws . String ( " " ) , S3UseARNRegion : aws . Bool ( true ) , } , expectedEndpoint : " " , expectedSigningName : " " , expectedSigningRegion : " " , expectedHeaderForOutpostID : " " , expectedHeaderForAccountID : true , } , " " : { bucket : " " , config : & aws . Config { Region : aws . String ( " " ) , } , expectedErr : " " , } , " " : { bucket : " " , config : & aws . Config { Region : aws . String ( " " ) , S3UseARNRegion : aws . Bool ( true ) , } , expectedErr : " " , } , " " : { bucket : " " , config : & aws . Config { Region : aws . String ( " " ) , S3UseARNRegion : aws . Bool ( true ) , } , expectedEndpoint : " " , expectedSigningName : " " , expectedSigningRegion : " " , expectedHeaderForOutpostID : " " , expectedHeaderForAccountID : true , } , " " : { bucket : " " , config : & aws . Config { EndpointResolver : endpoints . AwsUsGovPartition ( ) , Region : aws . String ( " " ) , } , expectedErr : " " , } , " " : { bucket : " " , config : & aws . Config { EndpointResolver : endpoints . AwsUsGovPartition ( ) , EnforceShouldRetryCheck : nil , Region : aws . String ( " " ) , DisableSSL : nil , HTTPClient : nil , S3UseARNRegion : aws . Bool ( true ) , } , expectedErr : " " , } , " " : { bucket : " " , config : & aws . Config { EndpointResolver : endpoints . AwsUsGovPartition ( ) , Region : aws . String ( " " ) , S3UseARNRegion : aws . Bool ( true ) , } , expectedEndpoint : " " , expectedSigningName : " " , expectedSigningRegion : " " , expectedHeaderForOutpostID : " " , expectedHeaderForAccountID : true , } , " " : { bucket : " " , config : & aws . Config { Region : aws . String ( " " ) , UseDualStack : aws . Bool ( true ) , } , expectedErr : " " , } , " " : { bucket : " " , config : & aws . Config { Region : aws . String ( " " ) , S3UseAccelerate : aws . Bool ( true ) , } , expectedErr : " " , } , " " : { bucket : " " , config : & aws . Config { Region : aws . String ( " " ) , S3UseAccelerate : aws . Bool ( true ) , } , expectedErr : " " , } , " " : { bucket : " " , config : & aws . Config { Region : aws . String ( " " ) , } , expectedErr : " " , } , } runValidations ( t , cases ) }
Test endpoint from outpost bucket arn
Test endpoint from outpost bucket arn