@@ -66,12 +66,12 @@ module VCAP::Services::ServiceBrokers::V2
6666 to have_been_made
6767 end
6868
69- it 'sets the X-Api-Info-Location header to the /v2/info endpoint at the external address' do
69+ it 'sets the X-Api-Info-Location header to the correct endpoint at the external address' do
7070 make_request
7171 expect ( a_request ( http_method , full_url ) .
7272 with ( basic_auth :) .
7373 with ( query : hash_including ( { } ) ) .
74- with ( headers : { 'X-Api-Info-Location' => "#{ TestConfig . config [ :external_domain ] } /v2/info" } ) ) .
74+ with ( headers : { 'X-Api-Info-Location' => "#{ TestConfig . config [ :external_domain ] } #{ TestConfig . config [ :temporary_enable_v2 ] ? ' /v2/info' : '/' } " } ) ) .
7575 to have_been_made
7676 end
7777
@@ -86,7 +86,8 @@ module VCAP::Services::ServiceBrokers::V2
8686 expect ( fake_logger ) . to have_received ( :debug ) . with ( match ( /X-VCAP-Request-ID"=>"[[:alnum:]-]+/ ) )
8787 expect ( fake_logger ) . to have_received ( :debug ) . with ( match ( /X-Broker-API-Request-Identity"=>"[[:alnum:]-]+/ ) )
8888 expect ( fake_logger ) . to have_received ( :debug ) . with ( match ( /X-Broker-Api-Version"=>"2\. 15/ ) )
89- expect ( fake_logger ) . to have_received ( :debug ) . with ( match ( %r{X-Api-Info-Location"=>"api2\. vcap\. me/v2/info} ) )
89+ api_info_path = TestConfig . config [ :temporary_enable_v2 ] ? '/v2/info' : '/'
90+ expect ( fake_logger ) . to have_received ( :debug ) . with ( match ( /X-Api-Info-Location"=>"api2\. vcap\. me#{ api_info_path } / ) )
9091 end
9192
9293 context 'when an https URL is used' do
@@ -148,6 +149,40 @@ module VCAP::Services::ServiceBrokers::V2
148149 end
149150 end
150151
152+ context 'X-Api-Info-Location' do
153+ context 'when temporary_enable_v2 is true' do
154+ before do
155+ TestConfig . config [ :temporary_enable_v2 ] = true
156+ end
157+
158+ it 'sets the info location to /v2/info' do
159+ make_request
160+
161+ expect ( a_request ( http_method , full_url ) .
162+ with ( basic_auth :) .
163+ with ( query : hash_including ( { } ) ) .
164+ with ( headers : { 'X-Api-Info-Location' => 'api2.vcap.me/v2/info' } ) ) .
165+ to have_been_made
166+ end
167+ end
168+
169+ context 'when temporary_enable_v2 is false' do
170+ before do
171+ TestConfig . config [ :temporary_enable_v2 ] = false
172+ end
173+
174+ it 'sets the info location to /' do
175+ make_request
176+
177+ expect ( a_request ( http_method , full_url ) .
178+ with ( basic_auth :) .
179+ with ( query : hash_including ( { } ) ) .
180+ with ( headers : { 'X-Api-Info-Location' => 'api2.vcap.me/' } ) ) .
181+ to have_been_made
182+ end
183+ end
184+ end
185+
151186 context 'X-Broker-Api-Originating-Identity' do
152187 context 'when user guid is set in the SecurityContext' do
153188 before do
0 commit comments