-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Shared] Defined AWS domains as constants and added a test to validat…
…e that the correct domain is returned for a given region. Signed-off-by: Giacomo Marciani <mgiacomo@amazon.com>
- Loading branch information
Showing
2 changed files
with
44 additions
and
4 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
35 changes: 35 additions & 0 deletions
35
cookbooks/aws-parallelcluster-shared/spec/unit/libraries/environment_spec.rb
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,35 @@ | ||
require_relative '../../../libraries/environment' | ||
require 'spec_helper' | ||
|
||
describe 'aws_domain' do | ||
shared_examples 'a valid aws_domain function' do |region, expected_aws_domain| | ||
it 'returns the correct AWS domain' do | ||
allow_any_instance_of(Object).to receive(:aws_region).and_return(region) | ||
# We must force aws_domain to call the original function because | ||
# the spec_helper configures aws_domain to return a mocked value for all rspec tests. | ||
allow_any_instance_of(Object).to receive(:aws_domain).and_call_original | ||
|
||
expect(aws_domain).to eq(expected_aws_domain) | ||
end | ||
end | ||
|
||
context 'when in CN region' do | ||
include_examples 'a valid aws_domain function', 'cn-WHATEVER', 'amazonaws.com.cn' | ||
end | ||
|
||
context 'when in US-ISO region' do | ||
include_examples 'a valid aws_domain function', 'us-iso-WHATEVER', 'c2s.ic.gov' | ||
end | ||
|
||
context 'when in US-ISOB region' do | ||
include_examples 'a valid aws_domain function', 'us-isob-', 'sc2s.sgov.gov' | ||
end | ||
|
||
context 'when in GovCloud region' do | ||
include_examples 'a valid aws_domain function', 'us-gov-WHATEVER', 'amazonaws.com' | ||
end | ||
|
||
context 'when in whatever else region' do | ||
include_examples 'a valid aws_domain function', 'WHATEVER-ELSE', 'amazonaws.com' | ||
end | ||
end |