Skip to content

File tree

auth_options.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ type AuthScope struct {
9898
ProjectName string
9999
DomainID string
100100
DomainName string
101+
System bool
101102
}
102103

103104
// ToTokenV2CreateMap allows AuthOptions to satisfy the AuthOptionsBuilder
@@ -364,6 +365,14 @@ func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) {
364365
}
365366
}
366367

368+
if opts.Scope.System {
369+
return map[string]interface{}{
370+
"system": map[string]interface{}{
371+
"all": true,
372+
},
373+
}, nil
374+
}
375+
367376
if opts.Scope.ProjectName != "" {
368377
// ProjectName provided: either DomainID or DomainName must also be supplied.
369378
// ProjectID may not be supplied.

openstack/identity/v3/tokens/requests.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type Scope struct {
88
ProjectName string
99
DomainID string
1010
DomainName string
11+
System bool
1112
}
1213

1314
// AuthOptionsBuilder provides the ability for extensions to add additional

openstack/identity/v3/tokens/testing/requests_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,31 @@ func TestCreateProjectNameAndDomainNameScope(t *testing.T) {
275275
`)
276276
}
277277

278+
func TestCreateSystemScope(t *testing.T) {
279+
options := tokens.AuthOptions{UserID: "fenris", Password: "g0t0h311"}
280+
scope := &tokens.Scope{System: true}
281+
authTokenPost(t, options, scope, `
282+
{
283+
"auth": {
284+
"identity": {
285+
"methods": ["password"],
286+
"password": {
287+
"user": {
288+
"id": "fenris",
289+
"password": "g0t0h311"
290+
}
291+
}
292+
},
293+
"scope": {
294+
"system": {
295+
"all": true
296+
}
297+
}
298+
}
299+
}
300+
`)
301+
}
302+
278303
func TestCreateApplicationCredentialIDAndSecret(t *testing.T) {
279304
authTokenPost(t, tokens.AuthOptions{ApplicationCredentialID: "12345abcdef", ApplicationCredentialSecret: "mysecret"}, nil, `
280305
{

0 commit comments

Comments
 (0)