This repository was archived by the owner on Jun 2, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,6 +81,13 @@ def build_links
8181 }
8282 end
8383
84+ routing_client = CloudController ::DependencyLocator . instance . routing_api_client
85+ if domain . router_group_guid && routing_client . enabled?
86+ links [ :router_group ] = {
87+ href : url_builder . build_url ( path : "/routing/v1/router_groups/#{ domain . router_group_guid } " )
88+ }
89+ end
90+
8491 links
8592 end
8693 end
Original file line number Diff line number Diff line change 752752
753753 let ( :domain_json ) do
754754 {
755- guid : UUID_REGEX ,
756- created_at : iso8601 ,
757- updated_at : iso8601 ,
758- name : params [ :name ] ,
759- internal : false ,
760- router_group : { guid : 'some-router-guid' } ,
761- metadata : {
762- labels : { key : 'value' } ,
763- annotations : { key2 : 'value2' }
764- } ,
765- relationships : {
766- organization : {
767- data : nil
755+ guid : UUID_REGEX ,
756+ created_at : iso8601 ,
757+ updated_at : iso8601 ,
758+ name : params [ :name ] ,
759+ internal : false ,
760+ router_group : { guid : 'some-router-guid' } ,
761+ metadata : {
762+ labels : { key : 'value' } ,
763+ annotations : { key2 : 'value2' }
768764 } ,
769- shared_organizations : {
770- data : [ ]
771- }
772- } ,
773- links : {
774- self : { href : %r(#{ Regexp . escape ( link_prefix ) } \/ v3\/ domains\/ #{ UUID_REGEX } ) } ,
775- route_reservations : { href : %r(#{ Regexp . escape ( link_prefix ) } \/ v3/domains/#{ UUID_REGEX } /route_reservations) } ,
765+ relationships : {
766+ organization : {
767+ data : nil
768+ } ,
769+ shared_organizations : {
770+ data : [ ]
771+ }
772+ } ,
773+ links : {
774+ self : { href : %r(#{ Regexp . escape ( link_prefix ) } /v3/domains/#{ UUID_REGEX } ) } ,
775+ route_reservations : { href : %r(#{ Regexp . escape ( link_prefix ) } /v3/domains/#{ UUID_REGEX } /route_reservations) } ,
776+ router_group : { href : %r(#{ Regexp . escape ( link_prefix ) } /routing/v1/router_groups/some-router-guid) } ,
776777 }
777778 }
778779 end
Original file line number Diff line number Diff line change @@ -172,8 +172,22 @@ module VCAP::CloudController::Presenters::V3
172172 expect ( subject [ :links ] [ :self ] [ :href ] ) . to eq ( "#{ link_prefix } /v3/domains/#{ domain . guid } " )
173173 expect ( subject [ :links ] [ :organization ] [ :href ] ) . to eq ( "#{ link_prefix } /v3/organizations/#{ domain . owning_organization . guid } " )
174174 expect ( subject [ :links ] [ :route_reservations ] [ :href ] ) . to eq ( "#{ link_prefix } /v3/domains/#{ domain . guid } /route_reservations" )
175+ expect ( subject [ :links ] [ :router_group ] [ :href ] ) . to eq ( "#{ link_prefix } /routing/v1/router_groups/some-router-guid" )
175176 expect ( subject [ :links ] [ :shared_organizations ] [ :href ] ) . to eq ( "#{ link_prefix } /v3/domains/#{ domain . guid } /relationships/shared_organizations" )
176177 end
178+
179+ context 'and the routing API is disabled' do
180+ let ( :routing_api_client ) { instance_double ( VCAP ::CloudController ::RoutingApi ::Client ) }
181+
182+ before do
183+ allow ( VCAP ::CloudController ::RoutingApi ::Client ) . to receive ( :new ) . and_return ( routing_api_client )
184+ allow ( routing_api_client ) . to receive ( :enabled? ) . and_return false
185+ end
186+
187+ it 'does not include a link to the router group' do
188+ expect ( subject [ :links ] [ :router_group ] ) . to eq ( nil )
189+ end
190+ end
177191 end
178192 end
179193 end
You can’t perform that action at this time.
0 commit comments