This repository has been archived by the owner on Mar 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement regional STS endpoint support (#229)
* Implement regional STS endpoint support * Add an example to the description and check the DNS resolution of the lookup. * Update the README
- Loading branch information
1 parent
179d14f
commit adf03bb
Showing
5 changed files
with
164 additions
and
13 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,88 @@ | ||
// Copyright 2017 uSwitch | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package sts | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go/service/sts" | ||
) | ||
|
||
func TestRegionalGateway(t *testing.T) { | ||
gateway, err := DefaultGateway("", "us-west-2") | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
config := gateway.session.ClientConfig(sts.EndpointsID) | ||
|
||
if config.SigningRegion != "us-west-2" { | ||
t.Error("Unexpected region. Region was: ", config.SigningRegion) | ||
} | ||
|
||
if config.Endpoint != "https://sts.us-west-2.amazonaws.com" { | ||
t.Error("Unexpected regional endpoint. Endpoint was: ", config.Endpoint) | ||
} | ||
} | ||
|
||
func TestRegionalGatewayCn(t *testing.T) { | ||
gateway, err := DefaultGateway("", "cn-north-1") | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
config := gateway.session.ClientConfig(sts.EndpointsID) | ||
|
||
if config.SigningRegion != "cn-north-1" { | ||
t.Error("Unexpected region. Region was: ", config.SigningRegion) | ||
} | ||
|
||
if config.Endpoint != "https://sts.cn-north-1.amazonaws.com.cn" { | ||
t.Error("Unexpected regional endpoint. Endpoint was: ", config.Endpoint) | ||
} | ||
} | ||
|
||
func TestRegionalGatewayFips(t *testing.T) { | ||
gateway, err := DefaultGateway("", "us-east-1-fips") | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
config := gateway.session.ClientConfig(sts.EndpointsID) | ||
|
||
if config.SigningRegion != "us-east-1" { | ||
t.Error("Unexpected region. Region was: ", config.SigningRegion) | ||
} | ||
|
||
if config.Endpoint != "https://sts-fips.us-east-1.amazonaws.com" { | ||
t.Error("Unexpected regional endpoint. Endpoint was: ", config.Endpoint) | ||
} | ||
} | ||
|
||
func TestDefaultGlobalGateway(t *testing.T) { | ||
gateway, err := DefaultGateway("", "") | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
config := gateway.session.ClientConfig(sts.EndpointsID) | ||
|
||
if config.SigningRegion != "us-east-1" { | ||
t.Error("Unexpected region. Region was: ", config.SigningRegion) | ||
} | ||
|
||
if config.Endpoint != "https://sts.amazonaws.com" { | ||
t.Error("Unexpected regional endpoint. Endpoint was: ", config.Endpoint) | ||
} | ||
} |
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