Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit bb30330

Browse files
committed
Support keystone v3 scoped token auth.
1 parent 6b9e1ae commit bb30330

File tree

2 files changed

+46
-10
lines changed

2 files changed

+46
-10
lines changed

openstack/identity/v3/tokens/requests.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ func Create(c *gophercloud.ServiceClient, options gophercloud.AuthOptions, scope
9696
if options.UserID != "" {
9797
return createErr(ErrUserIDWithToken)
9898
}
99-
if options.DomainID != "" {
100-
return createErr(ErrDomainIDWithToken)
101-
}
102-
if options.DomainName != "" {
103-
return createErr(ErrDomainNameWithToken)
104-
}
10599

106100
// Configure the request for Token authentication.
107101
req.Auth.Identity.Methods = []string{"token"}

openstack/identity/v3/tokens/requests_test.go

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,54 @@ func TestCreateFailureTokenIDUserID(t *testing.T) {
311311
authTokenPostErr(t, gophercloud.AuthOptions{UserID: "something"}, nil, true, ErrUserIDWithToken)
312312
}
313313

314-
func TestCreateFailureTokenIDDomainID(t *testing.T) {
315-
authTokenPostErr(t, gophercloud.AuthOptions{DomainID: "something"}, nil, true, ErrDomainIDWithToken)
314+
func TestCreateTokenIDDomainID(t *testing.T) {
315+
scope := &Scope{ProjectName: "world-domination", DomainID: "1000"}
316+
authTokenPost(t, gophercloud.AuthOptions{DomainID: "something"}, scope, `
317+
{
318+
"auth": {
319+
"identity": {
320+
"methods": [
321+
"token"
322+
],
323+
"token": {
324+
"id": "12345abcdef"
325+
}
326+
},
327+
"scope": {
328+
"project": {
329+
"domain": {
330+
"id": "1000"
331+
},
332+
"name": "world-domination"
333+
}
334+
}
335+
}
336+
}`)
316337
}
317338

318-
func TestCreateFailureTokenIDDomainName(t *testing.T) {
319-
authTokenPostErr(t, gophercloud.AuthOptions{DomainName: "something"}, nil, true, ErrDomainNameWithToken)
339+
func TestCreateTokenIDDomainName(t *testing.T) {
340+
scope := &Scope{ProjectName: "world-domination", DomainName: "evil-plans"}
341+
authTokenPost(t, gophercloud.AuthOptions{DomainName: "something"}, scope, `
342+
{
343+
"auth": {
344+
"identity": {
345+
"methods": [
346+
"token"
347+
],
348+
"token": {
349+
"id": "12345abcdef"
350+
}
351+
},
352+
"scope": {
353+
"project": {
354+
"domain": {
355+
"name": "evil-plans"
356+
},
357+
"name": "world-domination"
358+
}
359+
}
360+
}
361+
}`)
320362
}
321363

322364
func TestCreateFailureMissingUser(t *testing.T) {

0 commit comments

Comments
 (0)