Identity v3 Projects Get (#164)
* Identity v3 Projects Get
* Renaming ToGetQuery to ToProjectGetQuery
* Fixing acceptance test
diff --git a/openstack/identity/v3/projects/testing/fixtures.go b/openstack/identity/v3/projects/testing/fixtures.go
index c4d9c03..cb10313 100644
--- a/openstack/identity/v3/projects/testing/fixtures.go
+++ b/openstack/identity/v3/projects/testing/fixtures.go
@@ -40,6 +40,21 @@
}
`
+// GetOutput provides a Get result.
+const GetOutput = `
+{
+ "project": {
+ "is_domain": false,
+ "description": "The team that is red",
+ "domain_id": "default",
+ "enabled": true,
+ "id": "1234",
+ "name": "Red Team",
+ "parent_id": null
+ }
+}
+`
+
// RedTeam is a Project fixture.
var RedTeam = projects.Project{
IsDomain: false,
@@ -65,7 +80,7 @@
// ExpectedProjectSlice is the slice of projects expected to be returned from ListOutput.
var ExpectedProjectSlice = []projects.Project{RedTeam, BlueTeam}
-// HandleListProjectSuccessfully creates an HTTP handler at `/projects` on the
+// HandleListProjectsSuccessfully creates an HTTP handler at `/projects` on the
// test handler mux that responds with a list of two tenants.
func HandleListProjectsSuccessfully(t *testing.T) {
th.Mux.HandleFunc("/projects", func(w http.ResponseWriter, r *http.Request) {
@@ -78,3 +93,17 @@
fmt.Fprintf(w, ListOutput)
})
}
+
+// HandleGetProjectSuccessfully creates an HTTP handler at `/projects` on the
+// test handler mux that responds with a single project.
+func HandleGetProjectSuccessfully(t *testing.T) {
+ th.Mux.HandleFunc("/projects/1234", func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "GET")
+ th.TestHeader(t, r, "Accept", "application/json")
+ th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ fmt.Fprintf(w, GetOutput)
+ })
+}
diff --git a/openstack/identity/v3/projects/testing/requests_test.go b/openstack/identity/v3/projects/testing/requests_test.go
index 31730f9..eeb2049 100644
--- a/openstack/identity/v3/projects/testing/requests_test.go
+++ b/openstack/identity/v3/projects/testing/requests_test.go
@@ -28,3 +28,13 @@
th.AssertNoErr(t, err)
th.CheckEquals(t, count, 1)
}
+
+func TestGetProject(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ HandleGetProjectSuccessfully(t)
+
+ actual, err := projects.Get(client.ServiceClient(), "1234", nil).Extract()
+ th.AssertNoErr(t, err)
+ th.CheckDeepEquals(t, RedTeam, *actual)
+}