@@ -10,6 +10,41 @@ import (
1010 "github.com/gophercloud/gophercloud/testhelper/client"
1111)
1212
13+ // ListAvailableOutput provides a single page of available Project results.
14+ const ListAvailableOutput = `
15+ {
16+ "projects": [
17+ {
18+ "description": "my first project",
19+ "domain_id": "11111",
20+ "enabled": true,
21+ "id": "abcde",
22+ "links": {
23+ "self": "http://localhost:5000/identity/v3/projects/abcde"
24+ },
25+ "name": "project 1",
26+ "parent_id": "11111"
27+ },
28+ {
29+ "description": "my second project",
30+ "domain_id": "22222",
31+ "enabled": true,
32+ "id": "bcdef",
33+ "links": {
34+ "self": "http://localhost:5000/identity/v3/projects/bcdef"
35+ },
36+ "name": "project 2",
37+ "parent_id": "22222"
38+ }
39+ ],
40+ "links": {
41+ "next": null,
42+ "previous": null,
43+ "self": "http://localhost:5000/identity/v3/users/foobar/projects"
44+ }
45+ }
46+ `
47+
1348// ListOutput provides a single page of Project results.
1449const ListOutput = `
1550{
@@ -103,6 +138,32 @@ const UpdateOutput = `
103138}
104139`
105140
141+ // FirstProject is a Project fixture.
142+ var FirstProject = projects.Project {
143+ Description : "my first project" ,
144+ DomainID : "11111" ,
145+ Enabled : true ,
146+ ID : "abcde" ,
147+ Name : "project 1" ,
148+ ParentID : "11111" ,
149+ Extra : map [string ]interface {}{
150+ "links" : map [string ]interface {}{"self" : "http://localhost:5000/identity/v3/projects/abcde" },
151+ },
152+ }
153+
154+ // SecondProject is a Project fixture.
155+ var SecondProject = projects.Project {
156+ Description : "my second project" ,
157+ DomainID : "22222" ,
158+ Enabled : true ,
159+ ID : "bcdef" ,
160+ Name : "project 2" ,
161+ ParentID : "22222" ,
162+ Extra : map [string ]interface {}{
163+ "links" : map [string ]interface {}{"self" : "http://localhost:5000/identity/v3/projects/bcdef" },
164+ },
165+ }
166+
106167// RedTeam is a Project fixture.
107168var RedTeam = projects.Project {
108169 IsDomain : false ,
@@ -144,9 +205,27 @@ var UpdatedRedTeam = projects.Project{
144205 Extra : map [string ]interface {}{"test" : "new" },
145206}
146207
208+ // ExpectedAvailableProjectsSlice is the slice of projects expected to be returned
209+ // from ListAvailableOutput.
210+ var ExpectedAvailableProjectsSlice = []projects.Project {FirstProject , SecondProject }
211+
147212// ExpectedProjectSlice is the slice of projects expected to be returned from ListOutput.
148213var ExpectedProjectSlice = []projects.Project {RedTeam , BlueTeam }
149214
215+ // HandleListAvailableProjectsSuccessfully creates an HTTP handler at `/auth/projects`
216+ // on the test handler mux that responds with a list of two tenants.
217+ func HandleListAvailableProjectsSuccessfully (t * testing.T ) {
218+ th .Mux .HandleFunc ("/auth/projects" , func (w http.ResponseWriter , r * http.Request ) {
219+ th .TestMethod (t , r , "GET" )
220+ th .TestHeader (t , r , "Accept" , "application/json" )
221+ th .TestHeader (t , r , "X-Auth-Token" , client .TokenID )
222+
223+ w .Header ().Set ("Content-Type" , "application/json" )
224+ w .WriteHeader (http .StatusOK )
225+ fmt .Fprintf (w , ListAvailableOutput )
226+ })
227+ }
228+
150229// HandleListProjectsSuccessfully creates an HTTP handler at `/projects` on the
151230// test handler mux that responds with a list of two tenants.
152231func HandleListProjectsSuccessfully (t * testing.T ) {
0 commit comments