Handle Unmarshaling Compute Security Group IDs (#192)
* Handling integer secgroup IDs
* Handling integer secgroup rule IDs
* Updating unit tests for integer secgroup IDs and rule IDs
* Style updates
* Style updates
* Test formatting fix
diff --git a/openstack/compute/v2/extensions/secgroups/testing/fixtures.go b/openstack/compute/v2/extensions/secgroups/testing/fixtures.go
index 8a83ca8..536e7f8 100644
--- a/openstack/compute/v2/extensions/secgroups/testing/fixtures.go
+++ b/openstack/compute/v2/extensions/secgroups/testing/fixtures.go
@@ -163,10 +163,35 @@
fmt.Fprintf(w, `
{
"security_group": {
- "id": "12345"
+ "id": %d
}
}
- `)
+ `, groupID)
+ })
+}
+
+func mockGetNumericIDGroupRuleResponse(t *testing.T, groupID int) {
+ url := fmt.Sprintf("%s/%d", rootPath, groupID)
+ th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "GET")
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
+
+ w.Header().Add("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+
+ fmt.Fprintf(w, `
+{
+ "security_group": {
+ "id": %d,
+ "rules": [
+ {
+ "parent_group_id": %d,
+ "id": %d
+ }
+ ]
+ }
+}
+ `, groupID, groupID, groupID)
})
}