@@ -138,6 +138,44 @@ const UpdateOutput = `
138138}
139139`
140140
141+ // ListTagsOutput provides the output to a ListTags request.
142+ const ListTagsOutput = `
143+ {
144+ "tags": ["foo", "bar"]
145+ }
146+ `
147+
148+ // ModifyProjectTagsRequest provides the input to a ModifyTags request.
149+ const ModifyProjectTagsRequest = `
150+ {
151+ "tags": ["foo", "bar"]
152+ }
153+ `
154+
155+ // ModifyProjectTagsOutput provides the output to a ModifyTags request.
156+ const ModifyProjectTagsOutput = `
157+ {
158+ "links": {
159+ "next": null,
160+ "previous": null,
161+ "self": "http://identity:5000/v3/projects"
162+ },
163+ "projects": [
164+ {
165+ "description": "Test Project",
166+ "domain_id": "default",
167+ "enabled": true,
168+ "id": "3d4c2c82bd5948f0bcab0cf3a7c9b48c",
169+ "links": {
170+ "self": "http://identity:5000/v3/projects/3d4c2c82bd5948f0bcab0cf3a7c9b48c"
171+ },
172+ "name": "demo",
173+ "tags": ["foo", "bar"]
174+ }
175+ ]
176+ }
177+ `
178+
141179// FirstProject is a Project fixture.
142180var FirstProject = projects.Project {
143181 Description : "my first project" ,
@@ -212,6 +250,31 @@ var ExpectedAvailableProjectsSlice = []projects.Project{FirstProject, SecondProj
212250// ExpectedProjectSlice is the slice of projects expected to be returned from ListOutput.
213251var ExpectedProjectSlice = []projects.Project {RedTeam , BlueTeam }
214252
253+ var ExpectedTags = projects.Tags {
254+ Tags : []string {"foo" , "bar" },
255+ }
256+
257+ var ExpectedProjects = projects.ProjectTags {
258+ Projects : []projects.Project {
259+ {
260+ Description : "Test Project" ,
261+ DomainID : "default" ,
262+ Enabled : true ,
263+ ID : "3d4c2c82bd5948f0bcab0cf3a7c9b48c" ,
264+ Extra : map [string ]interface {}{"links" : map [string ]interface {}{
265+ "self" : "http://identity:5000/v3/projects/3d4c2c82bd5948f0bcab0cf3a7c9b48c" ,
266+ }},
267+ Name : "demo" ,
268+ Tags : []string {"foo" , "bar" },
269+ },
270+ },
271+ Links : map [string ]interface {}{
272+ "next" : nil ,
273+ "previous" : nil ,
274+ "self" : "http://identity:5000/v3/projects" ,
275+ },
276+ }
277+
215278// HandleListAvailableProjectsSuccessfully creates an HTTP handler at `/auth/projects`
216279// on the test handler mux that responds with a list of two tenants.
217280func HandleListAvailableProjectsSuccessfully (t * testing.T ) {
@@ -290,3 +353,32 @@ func HandleUpdateProjectSuccessfully(t *testing.T) {
290353 fmt .Fprintf (w , UpdateOutput )
291354 })
292355}
356+
357+ func HandleListProjectTagsSuccessfully (t * testing.T ) {
358+ th .Mux .HandleFunc ("/projects/966b3c7d36a24facaf20b7e458bf2192/tags" , func (w http.ResponseWriter , r * http.Request ) {
359+ th .TestMethod (t , r , "GET" )
360+ th .TestHeader (t , r , "X-Auth-Token" , client .TokenID )
361+
362+ w .WriteHeader (http .StatusOK )
363+ fmt .Fprintf (w , ListTagsOutput )
364+ })
365+ }
366+
367+ func HandleModifyProjectTagsSuccessfully (t * testing.T ) {
368+ th .Mux .HandleFunc ("/projects/966b3c7d36a24facaf20b7e458bf2192/tags" , func (w http.ResponseWriter , r * http.Request ) {
369+ th .TestMethod (t , r , "PUT" )
370+ th .TestHeader (t , r , "X-Auth-Token" , client .TokenID )
371+ th .TestJSONRequest (t , r , ModifyProjectTagsRequest )
372+
373+ w .WriteHeader (http .StatusOK )
374+ fmt .Fprintf (w , ModifyProjectTagsOutput )
375+ })
376+ }
377+ func HandleDeleteProjectTagsSuccessfully (t * testing.T ) {
378+ th .Mux .HandleFunc ("/projects/966b3c7d36a24facaf20b7e458bf2192/tags" , func (w http.ResponseWriter , r * http.Request ) {
379+ th .TestMethod (t , r , "DELETE" )
380+ th .TestHeader (t , r , "X-Auth-Token" , client .TokenID )
381+
382+ w .WriteHeader (http .StatusNoContent )
383+ })
384+ }
0 commit comments