Feature/filestorage securityservices delete (#133)
* sfs: Add support for security services Delete
* sfs: Add acceptance tests for security service Delete
diff --git a/openstack/sharedfilesystems/v2/securityservices/requests.go b/openstack/sharedfilesystems/v2/securityservices/requests.go
index eca9fe5..1253d33 100644
--- a/openstack/sharedfilesystems/v2/securityservices/requests.go
+++ b/openstack/sharedfilesystems/v2/securityservices/requests.go
@@ -59,3 +59,9 @@
})
return
}
+
+// Delete will delete the existing SecurityService with the provided ID.
+func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) {
+ _, r.Err = client.Delete(deleteURL(client, id), nil)
+ return
+}
diff --git a/openstack/sharedfilesystems/v2/securityservices/results.go b/openstack/sharedfilesystems/v2/securityservices/results.go
index e34692d..746b2b3 100644
--- a/openstack/sharedfilesystems/v2/securityservices/results.go
+++ b/openstack/sharedfilesystems/v2/securityservices/results.go
@@ -50,3 +50,8 @@
type CreateResult struct {
commonResult
}
+
+// DeleteResult contains the response body and error from a Delete request.
+type DeleteResult struct {
+ gophercloud.ErrResult
+}
diff --git a/openstack/sharedfilesystems/v2/securityservices/testing/fixtures.go b/openstack/sharedfilesystems/v2/securityservices/testing/fixtures.go
index 78adc48..e6b101a 100644
--- a/openstack/sharedfilesystems/v2/securityservices/testing/fixtures.go
+++ b/openstack/sharedfilesystems/v2/securityservices/testing/fixtures.go
@@ -50,3 +50,11 @@
}`)
})
}
+
+func MockDeleteResponse(t *testing.T) {
+ th.Mux.HandleFunc("/security-services/securityServiceID", func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "DELETE")
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
+ w.WriteHeader(http.StatusAccepted)
+ })
+}
diff --git a/openstack/sharedfilesystems/v2/securityservices/testing/requests_test.go b/openstack/sharedfilesystems/v2/securityservices/testing/requests_test.go
index 2b3325e..8ef88ee 100644
--- a/openstack/sharedfilesystems/v2/securityservices/testing/requests_test.go
+++ b/openstack/sharedfilesystems/v2/securityservices/testing/requests_test.go
@@ -51,3 +51,14 @@
t.Fatal("ErrMissingInput was expected to occur")
}
}
+
+// Verifies that security service deletion works
+func TestDelete(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+
+ MockDeleteResponse(t)
+
+ res := securityservices.Delete(client.ServiceClient(), "securityServiceID")
+ th.AssertNoErr(t, res.Err)
+}
diff --git a/openstack/sharedfilesystems/v2/securityservices/urls.go b/openstack/sharedfilesystems/v2/securityservices/urls.go
index ba0ae6d..5cbdd17 100644
--- a/openstack/sharedfilesystems/v2/securityservices/urls.go
+++ b/openstack/sharedfilesystems/v2/securityservices/urls.go
@@ -5,3 +5,7 @@
func createURL(c *gophercloud.ServiceClient) string {
return c.ServiceURL("security-services")
}
+
+func deleteURL(c *gophercloud.ServiceClient, id string) string {
+ return c.ServiceURL("security-services", id)
+}