fix format of result of extensions query and related functions
diff --git a/openstack/identity/common_test.go b/openstack/identity/common_test.go
index 95a2ccb..18c5340 100644
--- a/openstack/identity/common_test.go
+++ b/openstack/identity/common_test.go
@@ -89,49 +89,99 @@
}
}`
-// Taken from: http://docs.openstack.org/api/openstack-identity-service/2.0/content/GET_listExtensions_v2.0_extensions_.html#GET_listExtensions_v2.0_extensions_-Request
+// Taken from: http://developer.openstack.org/api-ref-identity-v2.html
const queryResults = `{
- "extensions":[{
- "name": "Reset Password Extension",
- "namespace": "http://docs.rackspacecloud.com/identity/api/ext/rpe/v2.0",
- "alias": "RS-RPE",
- "updated": "2011-01-22T13:25:27-06:00",
- "description": "Adds the capability to reset a user's password. The user is emailed when the password has been reset.",
- "links":[{
- "rel": "describedby",
- "type": "application/pdf",
- "href": "http://docs.rackspacecloud.com/identity/api/ext/identity-rpe-20111111.pdf"
- },
- {
- "rel": "describedby",
- "type": "application/vnd.sun.wadl+xml",
- "href": "http://docs.rackspacecloud.com/identity/api/ext/identity-rpe.wadl"
- }
- ]
- },
- {
- "name": "User Metadata Extension",
- "namespace": "http://docs.rackspacecloud.com/identity/api/ext/meta/v2.0",
- "alias": "RS-META",
- "updated": "2011-01-12T11:22:33-06:00",
- "description": "Allows associating arbritrary metadata with a user.",
- "links":[{
- "rel": "describedby",
- "type": "application/pdf",
- "href": "http://docs.rackspacecloud.com/identity/api/ext/identity-meta-20111201.pdf"
- },
- {
- "rel": "describedby",
- "type": "application/vnd.sun.wadl+xml",
- "href": "http://docs.rackspacecloud.com/identity/api/ext/identity-meta.wadl"
- }
- ]
- }
- ],
- "extensions_links":[]
+ "extensions": {
+ "values": [
+ {
+ "updated": "2013-07-07T12:00:0-00:00",
+ "name": "OpenStack S3 API",
+ "links": [
+ {
+ "href": "https://github.com/openstack/identity-api",
+ "type": "text/html",
+ "rel": "describedby"
+ }
+ ],
+ "namespace": "http://docs.openstack.org/identity/api/ext/s3tokens/v1.0",
+ "alias": "s3tokens",
+ "description": "OpenStack S3 API."
+ },
+ {
+ "updated": "2013-07-23T12:00:0-00:00",
+ "name": "OpenStack Keystone Endpoint Filter API",
+ "links": [
+ {
+ "href": "https://github.com/openstack/identity-api/blob/master/openstack-identity-api/v3/src/markdown/identity-api-v3-os-ep-filter-ext.md",
+ "type": "text/html",
+ "rel": "describedby"
+ }
+ ],
+ "namespace": "http://docs.openstack.org/identity/api/ext/OS-EP-FILTER/v1.0",
+ "alias": "OS-EP-FILTER",
+ "description": "OpenStack Keystone Endpoint Filter API."
+ },
+ {
+ "updated": "2013-12-17T12:00:0-00:00",
+ "name": "OpenStack Federation APIs",
+ "links": [
+ {
+ "href": "https://github.com/openstack/identity-api",
+ "type": "text/html",
+ "rel": "describedby"
+ }
+ ],
+ "namespace": "http://docs.openstack.org/identity/api/ext/OS-FEDERATION/v1.0",
+ "alias": "OS-FEDERATION",
+ "description": "OpenStack Identity Providers Mechanism."
+ },
+ {
+ "updated": "2013-07-11T17:14:00-00:00",
+ "name": "OpenStack Keystone Admin",
+ "links": [
+ {
+ "href": "https://github.com/openstack/identity-api",
+ "type": "text/html",
+ "rel": "describedby"
+ }
+ ],
+ "namespace": "http://docs.openstack.org/identity/api/ext/OS-KSADM/v1.0",
+ "alias": "OS-KSADM",
+ "description": "OpenStack extensions to Keystone v2.0 API enabling Administrative Operations."
+ },
+ {
+ "updated": "2014-01-20T12:00:0-00:00",
+ "name": "OpenStack Simple Certificate API",
+ "links": [
+ {
+ "href": "https://github.com/openstack/identity-api",
+ "type": "text/html",
+ "rel": "describedby"
+ }
+ ],
+ "namespace": "http://docs.openstack.org/identity/api/ext/OS-SIMPLE-CERT/v1.0",
+ "alias": "OS-SIMPLE-CERT",
+ "description": "OpenStack simple certificate retrieval extension"
+ },
+ {
+ "updated": "2013-07-07T12:00:0-00:00",
+ "name": "OpenStack EC2 API",
+ "links": [
+ {
+ "href": "https://github.com/openstack/identity-api",
+ "type": "text/html",
+ "rel": "describedby"
+ }
+ ],
+ "namespace": "http://docs.openstack.org/identity/api/ext/OS-EC2/v1.0",
+ "alias": "OS-EC2",
+ "description": "OpenStack EC2 Credentials backend."
+ }
+ ]
+ }
}`
-// Same as queryResults above, but with a bogus JSON envelop.
+// Extensions query with a bogus JSON envelop.
const bogusExtensionsResults = `{
"explosions":[{
"name": "Reset Password Extension",
diff --git a/openstack/identity/extensions.go b/openstack/identity/extensions.go
index e769f1c..9cf9c78 100644
--- a/openstack/identity/extensions.go
+++ b/openstack/identity/extensions.go
@@ -1,7 +1,6 @@
package identity
import (
- "fmt"
"github.com/mitchellh/mapstructure"
)
@@ -65,20 +64,16 @@
func extensions(er ExtensionsResult) ([]interface{}, error) {
ei, ok := er["extensions"]
- fmt.Printf("%+v\n\n", ei)
if !ok {
return nil, ErrNotImplemented
}
e := ei.(map[string]interface{})
- //e := ei.([]interface{})
vi, ok := e["values"]
- fmt.Printf("%+v\n\n", e)
if !ok {
return nil, ErrNotImplemented
}
v := vi.([]interface{})
return v, nil
- //return e, nil
}
// Aliases returns the set of extension handles, or "aliases" as OpenStack calls them.
diff --git a/openstack/identity/extensions_test.go b/openstack/identity/extensions_test.go
index 009d29d..3000fc0 100644
--- a/openstack/identity/extensions_test.go
+++ b/openstack/identity/extensions_test.go
@@ -15,7 +15,7 @@
}
e := ExtensionsResult(getExtensionsResults)
- for _, alias := range []string{"RS-RPE", "RS-META"} {
+ for _, alias := range []string{"OS-KSADM", "OS-FEDERATION"} {
if !e.IsExtensionAvailable(alias) {
t.Errorf("Expected extension %s present.", alias)
return
@@ -37,7 +37,7 @@
}
e := ExtensionsResult(getExtensionsResults)
- ed, err := e.ExtensionDetailsByAlias("RS-META")
+ ed, err := e.ExtensionDetailsByAlias("OS-KSADM")
if err != nil {
t.Error(err)
return
@@ -51,10 +51,10 @@
}
expecteds := map[string]string{
- "name": "User Metadata Extension",
- "namespace": "http://docs.rackspacecloud.com/identity/api/ext/meta/v2.0",
- "updated": "2011-01-12T11:22:33-06:00",
- "description": "Allows associating arbritrary metadata with a user.",
+ "name": "OpenStack Keystone Admin",
+ "namespace": "http://docs.openstack.org/identity/api/ext/OS-KSADM/v1.0",
+ "updated": "2013-07-11T17:14:00-00:00",
+ "description": "OpenStack extensions to Keystone v2.0 API enabling Administrative Operations.",
}
for k, v := range expecteds {
@@ -74,7 +74,7 @@
}
e := ExtensionsResult(getExtensionsResults)
- _, err = e.ExtensionDetailsByAlias("RS-META")
+ _, err = e.ExtensionDetailsByAlias("OS-KSADM")
if err == nil {
t.Error("Expected ErrNotImplemented at least")
return
@@ -104,7 +104,8 @@
t.Error(err)
return
}
- if len(aliases) != len(e) {
+ extensions := (((e["extensions"]).(map[string]interface{}))["values"]).([]interface{})
+ if len(aliases) != len(extensions) {
t.Error("Expected one alias name per extension")
return
}