Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 95c2901

Browse files
v3: client can view a route's protocol
- a route's protocol is defined by the domain that it belongs to [#172512289] Co-authored-by: Sarah Weinstein <sweinstein@pivotal.io> Co-authored-by: Belinda Liu <bliu@pivotal.io>
1 parent 77af3f1 commit 95c2901

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

app/presenters/v3/route_presenter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def initialize(
2626
def to_hash
2727
hash = {
2828
guid: route.guid,
29+
protocol: route.domain.protocols[0],
2930
created_at: route.created_at,
3031
updated_at: route.updated_at,
3132
host: route.host,

spec/request/routes_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
let(:route_in_org_json) do
2828
{
2929
guid: route_in_org.guid,
30+
protocol: route_in_org.domain.protocols[0],
3031
host: route_in_org.host,
3132
path: route_in_org.path,
3233
url: "#{route_in_org.host}.#{route_in_org.domain.name}#{route_in_org.path}",
@@ -80,6 +81,7 @@
8081
let(:route_in_other_org_json) do
8182
{
8283
guid: route_in_other_org.guid,
84+
protocol: route_in_other_org.domain.protocols[0],
8385
host: route_in_other_org.host,
8486
path: route_in_other_org.path,
8587
url: "#{route_in_other_org.host}.#{route_in_other_org.domain.name}#{route_in_other_org.path}",
@@ -245,6 +247,7 @@
245247
let(:route1_domain1_json) do
246248
{
247249
guid: route1_domain1.guid,
250+
protocol: route1_domain1.domain.protocols[0],
248251
created_at: iso8601,
249252
updated_at: iso8601,
250253
host: route1_domain1.host,
@@ -307,6 +310,7 @@
307310
let(:route_without_host_and_with_path_json) do
308311
{
309312
guid: 'route-without-host',
313+
protocol: domain.protocols[0],
310314
created_at: iso8601,
311315
updated_at: iso8601,
312316
destinations: [],
@@ -340,6 +344,7 @@
340344
let(:route_without_host_and_with_path2_json) do
341345
{
342346
guid: 'route-without-host2',
347+
protocol: domain.protocols[0],
343348
created_at: iso8601,
344349
updated_at: iso8601,
345350
destinations: [],
@@ -376,6 +381,7 @@
376381
let(:route_without_path_and_with_host_json) do
377382
{
378383
guid: 'route-without-path',
384+
protocol: domain.protocols[0],
379385
created_at: iso8601,
380386
updated_at: iso8601,
381387
destinations: [],
@@ -809,6 +815,7 @@
809815
let(:route_json) do
810816
{
811817
guid: route.guid,
818+
protocol: route.domain.protocols[0],
812819
host: route.host,
813820
path: route.path,
814821
url: "#{route.host}.#{route.domain.name}#{route.path}",
@@ -892,6 +899,7 @@
892899
let(:route_json) do
893900
{
894901
guid: route.guid,
902+
protocol: route.domain.protocols[0],
895903
host: route.host,
896904
path: route.path,
897905
url: "#{route.host}.#{route.domain.name}#{route.path}",
@@ -950,6 +958,7 @@
950958
let(:route_json) do
951959
{
952960
guid: UUID_REGEX,
961+
protocol: domain.protocols[0],
953962
host: '',
954963
path: '',
955964
url: domain.name,
@@ -1022,6 +1031,7 @@
10221031
let(:route_json) do
10231032
{
10241033
guid: UUID_REGEX,
1034+
protocol: domain.protocols[0],
10251035
host: 'some-host',
10261036
path: '/some-path',
10271037
url: "some-host.#{domain.name}/some-path",
@@ -1101,6 +1111,7 @@
11011111
let(:route_json) do
11021112
{
11031113
guid: UUID_REGEX,
1114+
protocol: domain.protocols[0],
11041115
host: '*',
11051116
path: '',
11061117
url: "*.#{domain.name}",
@@ -1193,6 +1204,7 @@
11931204
let(:route_json) do
11941205
{
11951206
guid: UUID_REGEX,
1207+
protocol: domain.protocols[0],
11961208
host: 'some-host',
11971209
path: '',
11981210
url: "some-host.#{domain.name}",
@@ -1260,6 +1272,7 @@
12601272
let(:route_json) do
12611273
{
12621274
guid: UUID_REGEX,
1275+
protocol: domain.protocols[0],
12631276
host: '*',
12641277
path: '',
12651278
url: "*.#{domain.name}",
@@ -1334,6 +1347,7 @@
13341347
let(:route_json) do
13351348
{
13361349
guid: UUID_REGEX,
1350+
protocol: domain.protocols[0],
13371351
host: 'some-host',
13381352
path: '',
13391353
url: "some-host.#{domain.name}",
@@ -1450,6 +1464,7 @@
14501464
let(:route_json) do
14511465
{
14521466
guid: UUID_REGEX,
1467+
protocol: domain.protocols[0],
14531468
host: 'some-host',
14541469
path: '',
14551470
url: "some-host.#{domain.name}",
@@ -1677,6 +1692,7 @@
16771692
let(:route_json) do
16781693
{
16791694
guid: UUID_REGEX,
1695+
protocol: domain.protocols[0],
16801696
host: params[:host],
16811697
path: '',
16821698
url: "#{params[:host]}.#{domain.name}",
@@ -1902,6 +1918,7 @@
19021918
let(:route_json) do
19031919
{
19041920
guid: UUID_REGEX,
1921+
protocol: domain.protocols[0],
19051922
host: '',
19061923
path: '',
19071924
url: domain.name,
@@ -1959,6 +1976,7 @@
19591976
let(:route_json) do
19601977
{
19611978
guid: UUID_REGEX,
1979+
protocol: domain.protocols[0],
19621980
host: '',
19631981
path: '',
19641982
url: domain.name,
@@ -2130,6 +2148,7 @@
21302148
let(:route1_json) do
21312149
{
21322150
guid: route1.guid,
2151+
protocol: route1.domain.protocols[0],
21332152
host: route1.host,
21342153
path: route1.path,
21352154
url: "#{route1.host}.#{route1.domain.name}#{route1.path}",
@@ -2172,6 +2191,7 @@
21722191
let(:route2_json) do
21732192
{
21742193
guid: route2.guid,
2194+
protocol: route2.domain.protocols[0],
21752195
host: route2.host,
21762196
path: route2.path,
21772197
url: "#{route2.host}.#{route2.domain.name}#{route2.path}",

spec/unit/presenters/v3/route_presenter_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ module VCAP::CloudController::Presenters::V3
6363

6464
it 'presents the route as json' do
6565
expect(subject[:guid]).to eq(route.guid)
66+
expect(subject[:protocol]).to eq('http')
6667
expect(subject[:created_at]).to be_a(Time)
6768
expect(subject[:updated_at]).to be_a(Time)
6869
expect(subject[:host]).to eq(route_host)

0 commit comments

Comments
 (0)