Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/aws_s3_object: Additional cross-region tests #35402

Merged
merged 18 commits into from
Jan 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add 'names.IsOptInRegion'.
  • Loading branch information
ewbankkit committed Jan 18, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 0f9028e02bfcfd1b1a3512aaf8eaa507df54fa5e
17 changes: 17 additions & 0 deletions names/names.go
Original file line number Diff line number Diff line change
@@ -185,6 +185,23 @@ func DNSSuffixForPartition(partition string) string {
}
}

func IsOptInRegion(region string) bool {
switch region {
case AFSouth1RegionID,
APEast1RegionID, APSouth2RegionID,
APSoutheast3RegionID, APSoutheast4RegionID,
CAWest1RegionID,
EUCentral2RegionID,
EUSouth1RegionID, EUSouth2RegionID,
ILCentral1RegionID,
MECentral1RegionID,
MESouth1RegionID:
return true
default:
return false
}
}

func PartitionForRegion(region string) string {
switch region {
case "":
47 changes: 47 additions & 0 deletions names/names_test.go
Original file line number Diff line number Diff line change
@@ -58,6 +58,53 @@ func TestDNSSuffixForPartition(t *testing.T) {
}
}

func TestIsOptInRegion(t *testing.T) {
t.Parallel()

testCases := []struct {
name string
input string
expected bool
}{
{
name: "empty",
input: "",
expected: false,
},
{
name: "China",
input: CNNorth1RegionID,
expected: false,
},
{
name: "GovCloud",
input: USGovWest1RegionID,
expected: false,
},
{
name: "standard opt-in",
input: CAWest1RegionID,
expected: true,
},
{
name: "standard not opt-in",
input: CACentral1RegionID,
expected: false,
},
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()

if got, want := IsOptInRegion(testCase.input), testCase.expected; got != want {
t.Errorf("got: %t, expected: %t", got, want)
}
})
}
}

func TestPartitionForRegion(t *testing.T) {
t.Parallel()