# frozen_string_literal: true # WARNING ABOUT GENERATED CODE # # This file is generated. See the contributing guide for more information: # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md # # WARNING ABOUT GENERATED CODE require_relative 'spec_helper' module Aws::CodeCatalyst describe EndpointProvider do subject { Aws::CodeCatalyst::EndpointProvider.new } context 'Override endpoint' do let(:expected) do {"endpoint"=>{"url"=>"https://test.codecatalyst.global.api.aws"}} end it 'produces the expected output from the EndpointProvider' do params = EndpointParameters.new(**{:endpoint=>"https://test.codecatalyst.global.api.aws"}) endpoint = subject.resolve_endpoint(params) expect(endpoint.url).to eq(expected['endpoint']['url']) expect(endpoint.headers).to eq(expected['endpoint']['headers'] || {}) expect(endpoint.properties).to eq(expected['endpoint']['properties'] || {}) end end context 'Default endpoint (region not set)' do let(:expected) do {"endpoint"=>{"url"=>"https://codecatalyst.global.api.aws"}} end it 'produces the expected output from the EndpointProvider' do params = EndpointParameters.new(**{}) endpoint = subject.resolve_endpoint(params) expect(endpoint.url).to eq(expected['endpoint']['url']) expect(endpoint.headers).to eq(expected['endpoint']['headers'] || {}) expect(endpoint.properties).to eq(expected['endpoint']['properties'] || {}) end end context 'Default FIPS endpoint (region not set)' do let(:expected) do {"endpoint"=>{"url"=>"https://codecatalyst-fips.global.api.aws"}} end it 'produces the expected output from the EndpointProvider' do params = EndpointParameters.new(**{:use_fips=>true}) endpoint = subject.resolve_endpoint(params) expect(endpoint.url).to eq(expected['endpoint']['url']) expect(endpoint.headers).to eq(expected['endpoint']['headers'] || {}) expect(endpoint.properties).to eq(expected['endpoint']['properties'] || {}) end end context 'Default endpoint (region: aws-global)' do let(:expected) do {"endpoint"=>{"url"=>"https://codecatalyst.global.api.aws"}} end it 'produces the expected output from the EndpointProvider' do params = EndpointParameters.new(**{:region=>"aws-global"}) endpoint = subject.resolve_endpoint(params) expect(endpoint.url).to eq(expected['endpoint']['url']) expect(endpoint.headers).to eq(expected['endpoint']['headers'] || {}) expect(endpoint.properties).to eq(expected['endpoint']['properties'] || {}) end end context 'Default FIPS endpoint (region: aws-global)' do let(:expected) do {"endpoint"=>{"url"=>"https://codecatalyst-fips.global.api.aws"}} end it 'produces the expected output from the EndpointProvider' do params = EndpointParameters.new(**{:region=>"aws-global", :use_fips=>true}) endpoint = subject.resolve_endpoint(params) expect(endpoint.url).to eq(expected['endpoint']['url']) expect(endpoint.headers).to eq(expected['endpoint']['headers'] || {}) expect(endpoint.properties).to eq(expected['endpoint']['properties'] || {}) end end context 'Default endpoint for a valid home region (region: us-west-2)' do let(:expected) do {"endpoint"=>{"url"=>"https://codecatalyst.global.api.aws"}} end it 'produces the expected output from the EndpointProvider' do params = EndpointParameters.new(**{:region=>"us-west-2"}) endpoint = subject.resolve_endpoint(params) expect(endpoint.url).to eq(expected['endpoint']['url']) expect(endpoint.headers).to eq(expected['endpoint']['headers'] || {}) expect(endpoint.properties).to eq(expected['endpoint']['properties'] || {}) end end context 'Default FIPS endpoint for a valid home region (region: us-west-2)' do let(:expected) do {"endpoint"=>{"url"=>"https://codecatalyst-fips.global.api.aws"}} end it 'produces the expected output from the EndpointProvider' do params = EndpointParameters.new(**{:region=>"us-west-2", :use_fips=>true}) endpoint = subject.resolve_endpoint(params) expect(endpoint.url).to eq(expected['endpoint']['url']) expect(endpoint.headers).to eq(expected['endpoint']['headers'] || {}) expect(endpoint.properties).to eq(expected['endpoint']['properties'] || {}) end end context 'Default endpoint for an unavailable home region (region: us-east-1)' do let(:expected) do {"endpoint"=>{"url"=>"https://codecatalyst.global.api.aws"}} end it 'produces the expected output from the EndpointProvider' do params = EndpointParameters.new(**{:region=>"us-east-1"}) endpoint = subject.resolve_endpoint(params) expect(endpoint.url).to eq(expected['endpoint']['url']) expect(endpoint.headers).to eq(expected['endpoint']['headers'] || {}) expect(endpoint.properties).to eq(expected['endpoint']['properties'] || {}) end end context 'Default FIPS endpoint for an unavailable home region (region: us-east-1)' do let(:expected) do {"endpoint"=>{"url"=>"https://codecatalyst-fips.global.api.aws"}} end it 'produces the expected output from the EndpointProvider' do params = EndpointParameters.new(**{:region=>"us-east-1", :use_fips=>true}) endpoint = subject.resolve_endpoint(params) expect(endpoint.url).to eq(expected['endpoint']['url']) expect(endpoint.headers).to eq(expected['endpoint']['headers'] || {}) expect(endpoint.properties).to eq(expected['endpoint']['properties'] || {}) end end end end