@@ -3,7 +3,6 @@ package smoke_test
33import (
44 "bytes"
55 "encoding/json"
6- "fmt"
76 "html/template"
87 "strings"
98
@@ -22,7 +21,7 @@ var _ = Describe("list", func() {
2221 var testVars map [string ]string
2322
2423 listResources := func (queryParams ... string ) func (resourcePath string , resourcesMatch types.GomegaMatcher ) {
25- return func (resourcePath string , resourcesMatch types.GomegaMatcher ) {
24+ return func (resourcePath string , match types.GomegaMatcher ) {
2625 if len (queryParams ) > 0 {
2726 resourcePath += "?" + strings .Join (queryParams , "&" )
2827 }
@@ -34,7 +33,7 @@ var _ = Describe("list", func() {
3433
3534 cfCurlOutput , err := sessionOutput (helpers .Cf ("curl" , url .String ()))
3635 Expect (err ).NotTo (HaveOccurred ())
37- Expect (cfCurlOutput ).To (MatchJSONPath ( "$.resources" , resourcesMatch ), fmt . Sprintf ( "JSON output: %s" , cfCurlOutput ) )
36+ Expect (cfCurlOutput ).To (match )
3837 }
3938 }
4039
@@ -74,60 +73,65 @@ var _ = Describe("list", func() {
7473 appPackageJSON , err := sessionOutput (helpers .Cf ("curl" , "/v3/packages?app_guids=" + testVars ["appGUID" ]))
7574 Expect (err ).NotTo (HaveOccurred ())
7675 testVars ["packageGUID" ] = jsonGet ("$.resources[0].guid" , appPackageJSON )
76+
77+ appRouteJSON , err := sessionOutput (helpers .Cf ("curl" , "/v3/apps/" + testVars ["appGUID" ]+ "/routes" ))
78+ Expect (err ).NotTo (HaveOccurred ())
79+ testVars ["routeGUID" ] = jsonGet ("$.resources[0].guid" , appRouteJSON )
7780 })
7881
7982 DescribeTable ("authorised users get the resources" ,
8083 listResources (),
81- Entry ("apps" , "/v3/apps" , Not (BeEmpty ())),
82- Entry ("app droplets" , "/v3/apps/{{.appGUID}}/droplets" , Not (BeEmpty ())),
83- Entry ("app processes" , "/v3/apps/{{.appGUID}}/processes" , Not (BeEmpty ())),
84- Entry ("app routes" , "/v3/apps/{{.appGUID}}/routes" , Not (BeEmpty ())),
85- Entry ("app packages" , "/v3/apps/{{.appGUID}}/packages" , Not (BeEmpty ())),
86- Entry ("builds" , "/v3/builds" , Not (BeEmpty ())),
87- Entry ("buildpacks" , "/v3/buildpacks" , Not (BeEmpty ())),
88- Entry ("deployments" , "/v3/deployments" , Not (BeEmpty ())),
89- Entry ("domains" , "/v3/domains" , Not (BeEmpty ())),
90- Entry ("droplets" , "/v3/droplets" , Not (BeEmpty ())),
91- Entry ("orgs" , "/v3/organizations" , Not (BeEmpty ())),
92- Entry ("org domains" , "/v3/organizations/{{.orgGUID}}/domains" , Not (BeEmpty ())),
93- Entry ("packages" , "/v3/packages" , Not (BeEmpty ())),
94- Entry ("package droplets" , "/v3/packages/{{.packageGUID}}/droplets" , Not (BeEmpty ())),
95- Entry ("processes" , "/v3/processes" , Not (BeEmpty ())),
96- Entry ("routes" , "/v3/routes" , Not (BeEmpty ())),
97- Entry ("roles" , "/v3/roles" , Not (BeEmpty ())),
98- Entry ("service_instances" , "/v3/service_instances" , Not (BeEmpty ())),
99- Entry ("service_credential_bindings" , "/v3/service_credential_bindings" , Not (BeEmpty ())),
100- Entry ("service brokers" , "/v3/service_brokers" , Not (BeEmpty ())),
101- Entry ("service offerings" , "/v3/service_offerings" , Not (BeEmpty ())),
102- Entry ("service plans" , "/v3/service_plans" , Not (BeEmpty ())),
103- Entry ("spaces" , "/v3/spaces" , Not (BeEmpty ())),
104- Entry ("tasks" , "/v3/tasks" , Not (BeEmpty ())),
105- Entry ("app tasks" , "/v3/apps/{{.appGUID}}/tasks" , Not (BeEmpty ())),
84+ Entry ("apps" , "/v3/apps" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
85+ Entry ("app droplets" , "/v3/apps/{{.appGUID}}/droplets" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
86+ Entry ("app processes" , "/v3/apps/{{.appGUID}}/processes" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
87+ Entry ("app routes" , "/v3/apps/{{.appGUID}}/routes" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
88+ Entry ("app packages" , "/v3/apps/{{.appGUID}}/packages" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
89+ Entry ("builds" , "/v3/builds" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
90+ Entry ("buildpacks" , "/v3/buildpacks" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
91+ Entry ("deployments" , "/v3/deployments" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
92+ Entry ("domains" , "/v3/domains" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
93+ Entry ("droplets" , "/v3/droplets" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
94+ Entry ("orgs" , "/v3/organizations" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
95+ Entry ("org domains" , "/v3/organizations/{{.orgGUID}}/domains" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
96+ Entry ("packages" , "/v3/packages" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
97+ Entry ("package droplets" , "/v3/packages/{{.packageGUID}}/droplets" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
98+ Entry ("processes" , "/v3/processes" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
99+ Entry ("routes" , "/v3/routes" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
100+ Entry ("routes" , "/v3/routes/{{.routeGUID}}/destinations" , MatchJSONPath ("$.destinations" , Not (BeEmpty ()))),
101+ Entry ("roles" , "/v3/roles" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
102+ Entry ("service_instances" , "/v3/service_instances" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
103+ Entry ("service_credential_bindings" , "/v3/service_credential_bindings" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
104+ Entry ("service brokers" , "/v3/service_brokers" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
105+ Entry ("service offerings" , "/v3/service_offerings" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
106+ Entry ("service plans" , "/v3/service_plans" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
107+ Entry ("spaces" , "/v3/spaces" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
108+ Entry ("tasks" , "/v3/tasks" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
109+ Entry ("app tasks" , "/v3/apps/{{.appGUID}}/tasks" , MatchJSONPath ("$.resources" , Not (BeEmpty ()))),
106110 )
107111
108112 When ("paging params are provided" , func () {
109113 DescribeTable ("authorised users get the resources" ,
110114 listResources ("per_page=1" ),
111- Entry ("apps" , "/v3/apps" , HaveLen (1 )),
112- Entry ("app droplets" , "/v3/apps/{{.appGUID}}/droplets" , HaveLen (1 )),
113- Entry ("app processes" , "/v3/apps/{{.appGUID}}/processes" , HaveLen (1 )),
114- Entry ("app routes" , "/v3/apps/{{.appGUID}}/routes" , HaveLen (1 )),
115- Entry ("app packages" , "/v3/apps/{{.appGUID}}/packages" , HaveLen (1 )),
116- Entry ("builds" , "/v3/builds" , HaveLen (1 )),
117- Entry ("buildpacks" , "/v3/buildpacks" , HaveLen (1 )),
118- Entry ("deployments" , "/v3/deployments" , HaveLen (1 )),
119- Entry ("domains" , "/v3/domains" , HaveLen (1 )),
120- Entry ("droplets" , "/v3/droplets" , HaveLen (1 )),
121- Entry ("orgs" , "/v3/organizations" , HaveLen (1 )),
122- Entry ("org domains" , "/v3/organizations/{{.orgGUID}}/domains" , HaveLen (1 )),
123- Entry ("packages" , "/v3/packages" , HaveLen (1 )),
124- Entry ("package droplets" , "/v3/packages/{{.packageGUID}}/droplets" , HaveLen (1 )),
125- Entry ("processes" , "/v3/processes" , HaveLen (1 )),
126- Entry ("routes" , "/v3/routes" , HaveLen (1 )),
127- Entry ("roles" , "/v3/roles" , HaveLen (1 )),
128- Entry ("service_instances" , "/v3/service_instances" , HaveLen (1 )),
129- Entry ("service_credential_bindings" , "/v3/service_credential_bindings" , HaveLen (1 )),
130- Entry ("service brokers" , "/v3/service_brokers" , HaveLen (1 )),
115+ Entry ("apps" , "/v3/apps" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
116+ Entry ("app droplets" , "/v3/apps/{{.appGUID}}/droplets" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
117+ Entry ("app processes" , "/v3/apps/{{.appGUID}}/processes" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
118+ Entry ("app routes" , "/v3/apps/{{.appGUID}}/routes" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
119+ Entry ("app packages" , "/v3/apps/{{.appGUID}}/packages" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
120+ Entry ("builds" , "/v3/builds" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
121+ Entry ("buildpacks" , "/v3/buildpacks" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
122+ Entry ("deployments" , "/v3/deployments" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
123+ Entry ("domains" , "/v3/domains" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
124+ Entry ("droplets" , "/v3/droplets" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
125+ Entry ("orgs" , "/v3/organizations" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
126+ Entry ("org domains" , "/v3/organizations/{{.orgGUID}}/domains" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
127+ Entry ("packages" , "/v3/packages" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
128+ Entry ("package droplets" , "/v3/packages/{{.packageGUID}}/droplets" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
129+ Entry ("processes" , "/v3/processes" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
130+ Entry ("routes" , "/v3/routes" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
131+ Entry ("roles" , "/v3/roles" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
132+ Entry ("service_instances" , "/v3/service_instances" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
133+ Entry ("service_credential_bindings" , "/v3/service_credential_bindings" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
134+ Entry ("service brokers" , "/v3/service_brokers" , MatchJSONPath ( "$.resources" , HaveLen (1 ) )),
131135 )
132136 })
133137
@@ -152,27 +156,27 @@ var _ = Describe("list", func() {
152156
153157 DescribeTable ("gets empty resources list for non-global resources" ,
154158 listResources (),
155- Entry ("apps" , "/v3/apps" , BeEmpty ()),
156- Entry ("builds" , "/v3/builds" , BeEmpty ()),
157- Entry ("deployments" , "/v3/deployments" , BeEmpty ()),
158- Entry ("droplets" , "/v3/droplets" , BeEmpty ()),
159- Entry ("orgs" , "/v3/organizations" , BeEmpty ()),
160- Entry ("packages" , "/v3/packages" , BeEmpty ()),
161- Entry ("processes" , "/v3/processes" , BeEmpty ()),
162- Entry ("routes" , "/v3/routes" , BeEmpty ()),
163- Entry ("service_instances" , "/v3/service_instances" , BeEmpty ()),
164- Entry ("service_credential_bindings" , "/v3/service_credential_bindings" , BeEmpty ()),
165- Entry ("spaces" , "/v3/spaces" , BeEmpty ()),
166- Entry ("tasks" , "/v3/tasks" , BeEmpty ()),
159+ Entry ("apps" , "/v3/apps" , MatchJSONPath ( "$.resources" , BeEmpty () )),
160+ Entry ("builds" , "/v3/builds" , MatchJSONPath ( "$.resources" , BeEmpty () )),
161+ Entry ("deployments" , "/v3/deployments" , MatchJSONPath ( "$.resources" , BeEmpty () )),
162+ Entry ("droplets" , "/v3/droplets" , MatchJSONPath ( "$.resources" , BeEmpty () )),
163+ Entry ("orgs" , "/v3/organizations" , MatchJSONPath ( "$.resources" , BeEmpty () )),
164+ Entry ("packages" , "/v3/packages" , MatchJSONPath ( "$.resources" , BeEmpty () )),
165+ Entry ("processes" , "/v3/processes" , MatchJSONPath ( "$.resources" , BeEmpty () )),
166+ Entry ("routes" , "/v3/routes" , MatchJSONPath ( "$.resources" , BeEmpty () )),
167+ Entry ("service_instances" , "/v3/service_instances" , MatchJSONPath ( "$.resources" , BeEmpty () )),
168+ Entry ("service_credential_bindings" , "/v3/service_credential_bindings" , MatchJSONPath ( "$.resources" , BeEmpty () )),
169+ Entry ("spaces" , "/v3/spaces" , MatchJSONPath ( "$.resources" , BeEmpty () )),
170+ Entry ("tasks" , "/v3/tasks" , MatchJSONPath ( "$.resources" , BeEmpty () )),
167171 )
168172
169173 DescribeTable ("gets the global resources" ,
170174 listResources (),
171- Entry ("buildpacks" , "/v3/buildpacks" , Not (BeEmpty ())),
172- Entry ("domains" , "/v3/domains" , Not (BeEmpty ())),
173- Entry ("service brokers" , "/v3/service_brokers" , Not (BeEmpty ())),
174- Entry ("service offerings" , "/v3/service_offerings" , Not (BeEmpty ())),
175- Entry ("service plans" , "/v3/service_plans" , Not (BeEmpty ())),
175+ Entry ("buildpacks" , "/v3/buildpacks" , MatchJSONPath ( "$.resources" , Not (BeEmpty () ))),
176+ Entry ("domains" , "/v3/domains" , MatchJSONPath ( "$.resources" , Not (BeEmpty () ))),
177+ Entry ("service brokers" , "/v3/service_brokers" , MatchJSONPath ( "$.resources" , Not (BeEmpty () ))),
178+ Entry ("service offerings" , "/v3/service_offerings" , MatchJSONPath ( "$.resources" , Not (BeEmpty () ))),
179+ Entry ("service plans" , "/v3/service_plans" , MatchJSONPath ( "$.resources" , Not (BeEmpty () ))),
176180 )
177181 })
178182})
0 commit comments