-
Notifications
You must be signed in to change notification settings - Fork 655
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIPS & DualStack Endpoint Resolver Support (#1274)
* DualStack and FIPS Modelling Support
- Loading branch information
Showing
1,654 changed files
with
100,676 additions
and
15,194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
package aws | ||
|
||
import ( | ||
"strconv" | ||
"testing" | ||
) | ||
|
||
type mockOptions struct { | ||
Bool bool | ||
Str string | ||
DualStackEndpointState DualStackEndpointState | ||
FIPSEndpointState FIPSEndpointState | ||
} | ||
|
||
func (m mockOptions) GetDisableHTTPS() bool { | ||
return m.Bool | ||
} | ||
|
||
func (m mockOptions) GetUseDualStackEndpoint() DualStackEndpointState { | ||
return m.DualStackEndpointState | ||
} | ||
|
||
func (m mockOptions) GetUseFIPSEndpoint() FIPSEndpointState { | ||
return m.FIPSEndpointState | ||
} | ||
|
||
func (m mockOptions) GetResolvedRegion() string { | ||
return m.Str | ||
} | ||
|
||
func TestGetDisableHTTPS(t *testing.T) { | ||
cases := []struct { | ||
Options []interface{} | ||
ExpectFound bool | ||
ExpectValue bool | ||
}{ | ||
{ | ||
Options: []interface{}{struct{}{}}, | ||
}, | ||
{ | ||
Options: []interface{}{mockOptions{ | ||
Bool: false, | ||
}}, | ||
ExpectFound: true, | ||
ExpectValue: false, | ||
}, | ||
{ | ||
Options: []interface{}{mockOptions{ | ||
Bool: true, | ||
}}, | ||
ExpectFound: true, | ||
ExpectValue: true, | ||
}, | ||
{ | ||
Options: []interface{}{struct{}{}, mockOptions{Bool: true}, mockOptions{Bool: false}}, | ||
ExpectFound: true, | ||
ExpectValue: true, | ||
}, | ||
} | ||
|
||
for i, tt := range cases { | ||
t.Run(strconv.Itoa(i), func(t *testing.T) { | ||
value, found := GetDisableHTTPS(tt.Options...) | ||
if found != tt.ExpectFound { | ||
t.Fatalf("expect value to not be found") | ||
} | ||
if value != tt.ExpectValue { | ||
t.Errorf("expect %v, got %v", tt.ExpectValue, value) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestGetResolvedRegion(t *testing.T) { | ||
cases := []struct { | ||
Options []interface{} | ||
ExpectFound bool | ||
ExpectValue string | ||
}{ | ||
{ | ||
Options: []interface{}{struct{}{}}, | ||
}, | ||
{ | ||
Options: []interface{}{mockOptions{Str: ""}}, | ||
ExpectFound: true, | ||
ExpectValue: "", | ||
}, | ||
{ | ||
Options: []interface{}{mockOptions{Str: "foo"}}, | ||
ExpectFound: true, | ||
ExpectValue: "foo", | ||
}, | ||
{ | ||
Options: []interface{}{struct{}{}, mockOptions{Str: "bar"}, mockOptions{Str: "baz"}}, | ||
ExpectFound: true, | ||
ExpectValue: "bar", | ||
}, | ||
} | ||
|
||
for i, tt := range cases { | ||
t.Run(strconv.Itoa(i), func(t *testing.T) { | ||
value, found := GetResolvedRegion(tt.Options...) | ||
if found != tt.ExpectFound { | ||
t.Fatalf("expect value to not be found") | ||
} | ||
if value != tt.ExpectValue { | ||
t.Errorf("expect %v, got %v", tt.ExpectValue, value) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestGetUseDualStackEndpoint(t *testing.T) { | ||
cases := []struct { | ||
Options []interface{} | ||
ExpectFound bool | ||
ExpectValue DualStackEndpointState | ||
}{ | ||
{ | ||
Options: []interface{}{struct{}{}}, | ||
}, | ||
{ | ||
Options: []interface{}{mockOptions{DualStackEndpointState: DualStackEndpointStateUnset}}, | ||
ExpectFound: true, | ||
ExpectValue: DualStackEndpointStateUnset, | ||
}, | ||
{ | ||
Options: []interface{}{mockOptions{DualStackEndpointState: DualStackEndpointStateEnabled}}, | ||
ExpectFound: true, | ||
ExpectValue: DualStackEndpointStateEnabled, | ||
}, | ||
{ | ||
Options: []interface{}{struct{}{}, mockOptions{DualStackEndpointState: DualStackEndpointStateEnabled}, mockOptions{DualStackEndpointState: DualStackEndpointStateDisabled}}, | ||
ExpectFound: true, | ||
ExpectValue: DualStackEndpointStateEnabled, | ||
}, | ||
} | ||
|
||
for i, tt := range cases { | ||
t.Run(strconv.Itoa(i), func(t *testing.T) { | ||
value, found := GetUseDualStackEndpoint(tt.Options...) | ||
if found != tt.ExpectFound { | ||
t.Fatalf("expect value to not be found") | ||
} | ||
if value != tt.ExpectValue { | ||
t.Errorf("expect %v, got %v", tt.ExpectValue, value) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestGetUseFIPSEndpoint(t *testing.T) { | ||
cases := []struct { | ||
Options []interface{} | ||
ExpectFound bool | ||
ExpectValue FIPSEndpointState | ||
}{ | ||
{ | ||
Options: []interface{}{struct{}{}}, | ||
}, | ||
{ | ||
Options: []interface{}{mockOptions{FIPSEndpointState: FIPSEndpointStateUnset}}, | ||
ExpectFound: true, | ||
ExpectValue: FIPSEndpointStateUnset, | ||
}, | ||
{ | ||
Options: []interface{}{mockOptions{FIPSEndpointState: FIPSEndpointStateEnabled}}, | ||
ExpectFound: true, | ||
ExpectValue: FIPSEndpointStateEnabled, | ||
}, | ||
{ | ||
Options: []interface{}{struct{}{}, mockOptions{FIPSEndpointState: FIPSEndpointStateEnabled}, mockOptions{FIPSEndpointState: FIPSEndpointStateDisabled}}, | ||
ExpectFound: true, | ||
ExpectValue: FIPSEndpointStateEnabled, | ||
}, | ||
} | ||
|
||
for i, tt := range cases { | ||
t.Run(strconv.Itoa(i), func(t *testing.T) { | ||
value, found := GetUseFIPSEndpoint(tt.Options...) | ||
if found != tt.ExpectFound { | ||
t.Fatalf("expect value to not be found") | ||
} | ||
if value != tt.ExpectValue { | ||
t.Errorf("expect %v, got %v", tt.ExpectValue, value) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.