Tests and bug fixes for UserID + Password.
diff --git a/openstack/identity/v3/tokens/requests.go b/openstack/identity/v3/tokens/requests.go
index 5be55ed..1790df5 100644
--- a/openstack/identity/v3/tokens/requests.go
+++ b/openstack/identity/v3/tokens/requests.go
@@ -30,7 +30,7 @@
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Password string `json:"password"`
- Domain *domainReq `json:"domain"`
+ Domain *domainReq `json:"domain,omitempty"`
}
type passwordReq struct {
@@ -43,7 +43,7 @@
type identityReq struct {
Methods []string `json:"methods"`
- Password *passwordReq `json:"token,omitempty"`
+ Password *passwordReq `json:"password,omitempty"`
Token *tokenReq `json:"token,omitempty"`
}
@@ -54,7 +54,7 @@
type authReq struct {
Identity identityReq `json:"identity"`
- Scope *scopeReq `json:"scope"`
+ Scope *scopeReq `json:"scope,omitempty"`
}
type request struct {
@@ -162,7 +162,7 @@
// Configure the request for UserID and Password authentication.
req.Auth.Identity.Password = &passwordReq{
- User: userReq{ID: &ao.UserID},
+ User: userReq{ID: &ao.UserID, Password: ao.Password},
}
}
}
diff --git a/openstack/identity/v3/tokens/requests_test.go b/openstack/identity/v3/tokens/requests_test.go
new file mode 100644
index 0000000..bbe1448
--- /dev/null
+++ b/openstack/identity/v3/tokens/requests_test.go
@@ -0,0 +1,46 @@
+package tokens
+
+import (
+ "fmt"
+ "net/http"
+ "testing"
+
+ "github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/testhelper"
+)
+
+func TestCreateUserIDAndPassword(t *testing.T) {
+ setup()
+ defer teardown()
+
+ client := gophercloud.ServiceClient{
+ Endpoint: endpoint(),
+ Options: gophercloud.AuthOptions{UserID: "me", Password: "squirrel!"},
+ }
+
+ mux.HandleFunc("/auth/tokens", func(w http.ResponseWriter, r *http.Request) {
+ testhelper.TestMethod(t, r, "POST")
+ testhelper.TestHeader(t, r, "Content-Type", "application/json")
+ testhelper.TestHeader(t, r, "Accept", "application/json")
+
+ testhelper.TestJSONRequest(t, r, `
+ {
+ "auth": {
+ "identity": {
+ "methods": ["password"],
+ "password": {
+ "user": { "id": "me", "password": "squirrel!" }
+ }
+ }
+ }
+ }
+ `)
+
+ fmt.Fprintf(w, `{}`)
+ })
+
+ _, err := Create(&client, nil)
+ if err != nil {
+ t.Errorf("Create returned an error: %v", err)
+ }
+}