@@ -127,29 +127,91 @@ module VCAP::CloudController
127127 expect ( hash [ 'links' ] [ 'network_policy_v1' ] [ 'href' ] ) . to eq ( expected_uri )
128128 end
129129
130- it 'returns a link to the logging API' do
131- expected_uri = 'wss://doppler.my-super-cool-cf.com:1234'
132- TestConfig . override ( doppler : { url : expected_uri } )
130+ describe 'logging link' do
131+ context 'doppler url is configured' do
132+ it 'returns a link to the logging API' do
133+ expected_uri = 'wss://doppler.my-super-cool-cf.com:1234'
134+ TestConfig . override ( doppler : { url : expected_uri } )
133135
134- get '/'
135- hash = Oj . load ( last_response . body )
136- expect ( hash [ 'links' ] [ 'logging' ] [ 'href' ] ) . to eq ( expected_uri )
136+ get '/'
137+ hash = Oj . load ( last_response . body )
138+ expect ( hash [ 'links' ] [ 'logging' ] [ 'href' ] ) . to eq ( expected_uri )
139+ end
140+ end
141+
142+ context 'doppler url is blank' do
143+ before do
144+ TestConfig . override ( doppler : { url : '' } )
145+ end
146+
147+ it 'does not return a link' do
148+ get '/'
149+ hash = Oj . load ( last_response . body )
150+ expect ( hash [ 'links' ] [ 'logging' ] ) . to be_nil
151+ end
152+ end
137153 end
138154
139- it 'returns a link to the log cache API' do
140- expected_uri = 'https://log-cache.example.com'
155+ describe 'log_cache link' do
156+ context 'log_cache url is configured' do
157+ it 'returns a link to the log cache API' do
158+ expected_uri = 'https://log-cache.example.com'
141159
142- get '/'
143- hash = Oj . load ( last_response . body )
144- expect ( hash [ 'links' ] [ 'log_cache' ] [ 'href' ] ) . to eq ( expected_uri )
160+ get '/'
161+ hash = Oj . load ( last_response . body )
162+ expect ( hash [ 'links' ] [ 'log_cache' ] [ 'href' ] ) . to eq ( expected_uri )
163+ end
164+ end
165+
166+ context 'log_cache url is blank' do
167+ before do
168+ TestConfig . override ( log_cache : { url : '' } )
169+ end
170+
171+ it 'does not return a link' do
172+ get '/'
173+ hash = Oj . load ( last_response . body )
174+ expect ( hash [ 'links' ] [ 'log_cache' ] ) . to be_nil
175+ end
176+ end
145177 end
146178
147- it 'returns a link to the v2 logging API' do
148- expected_uri = 'https://log-stream.example.com'
179+ describe 'log_stream link' do
180+ context 'log_stream url is configured' do
181+ it 'returns a link to the v2 logging API' do
182+ expected_uri = 'https://log-stream.example.com'
149183
150- get '/'
151- hash = Oj . load ( last_response . body )
152- expect ( hash [ 'links' ] [ 'log_stream' ] [ 'href' ] ) . to eq ( expected_uri )
184+ get '/'
185+ hash = Oj . load ( last_response . body )
186+ expect ( hash [ 'links' ] [ 'log_stream' ] [ 'href' ] ) . to eq ( expected_uri )
187+ end
188+ end
189+
190+ context 'log_stream url is blank' do
191+ before do
192+ TestConfig . override ( log_stream : { url : '' } )
193+ end
194+
195+ it 'does not return a link' do
196+ get '/'
197+ hash = Oj . load ( last_response . body )
198+ expect ( hash [ 'links' ] [ 'log_stream' ] ) . to be_nil
199+ end
200+ end
201+ end
202+
203+ context 'all loggregator urls are blank' do
204+ before do
205+ TestConfig . override ( doppler : { url : '' } , log_cache : { url : '' } , log_stream : { url : '' } )
206+ end
207+
208+ it 'returns nil for all three loggregator links' do
209+ get '/'
210+ hash = Oj . load ( last_response . body )
211+ expect ( hash [ 'links' ] [ 'logging' ] ) . to be_nil
212+ expect ( hash [ 'links' ] [ 'log_cache' ] ) . to be_nil
213+ expect ( hash [ 'links' ] [ 'log_stream' ] ) . to be_nil
214+ end
153215 end
154216
155217 it 'returns a link for app_ssh with metadata' do
0 commit comments