ChooseVersion accounts for missing /s.
diff --git a/acceptance/openstack/client_test.go b/acceptance/openstack/client_test.go
index 053e2ac..b9fdc82 100644
--- a/acceptance/openstack/client_test.go
+++ b/acceptance/openstack/client_test.go
@@ -18,7 +18,7 @@
}
// Trim out unused fields.
- ao.TenantID, ao.TenantName, ao.Username = "", "", ""
+ ao.TenantID, ao.TenantName = "", ""
client, err := openstack.AuthenticatedClient(ao)
if err != nil {
diff --git a/openstack/utils/choose_version.go b/openstack/utils/choose_version.go
index 088e086..57e2a81 100644
--- a/openstack/utils/choose_version.go
+++ b/openstack/utils/choose_version.go
@@ -69,6 +69,13 @@
var highest *Version
var endpoint string
+ normalize := func(endpoint string) string {
+ if !strings.HasSuffix(endpoint, "/") {
+ return endpoint + "/"
+ }
+ return endpoint
+ }
+
for _, value := range resp.Versions.Values {
href := ""
for _, link := range value.Links {
@@ -79,7 +86,7 @@
if matching, ok := byID[value.ID]; ok {
// Prefer a version that exactly matches the provided endpoint.
- if href == identityEndpoint {
+ if normalize(href) == normalize(identityEndpoint) {
if href == "" {
return nil, "", fmt.Errorf("Endpoint missing in version %s response from %s", value.ID, normalized)
}
diff --git a/openstack/utils/choose_version_test.go b/openstack/utils/choose_version_test.go
index d2aec8a..4a8a443 100644
--- a/openstack/utils/choose_version_test.go
+++ b/openstack/utils/choose_version_test.go
@@ -67,7 +67,7 @@
v2 := &Version{ID: "v2.0", Priority: 2}
v3 := &Version{ID: "v3.0", Priority: 3}
- v, endpoint, err := ChooseVersion(testhelper.Endpoint()+"v2.0", []*Version{v2, v3})
+ v, endpoint, err := ChooseVersion(testhelper.Endpoint()+"v2.0/", []*Version{v2, v3})
if err != nil {
t.Fatalf("Unexpected error from ChooseVersion: %v", err)
}