-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow domain names or IDs in keystone connector
OpenStack Keystone allows a user to authenticate against a domain. That domain can be specified either as the domain ID or the domain name when authenticating. The domain ID is a UUID or the special "default" domain ID so key off of that when deciding what to submit to the keystone API. Collapsed the code to share the domainKeystone struct by utilizing omitempty to skip unset fields. Signed-off-by: Doug Goldstein <[email protected]>
- Loading branch information
Showing
3 changed files
with
69 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,13 @@ import ( | |
const ( | ||
invalidPass = "WRONG_PASS" | ||
|
||
testUser = "test_user" | ||
testPass = "test_pass" | ||
testEmail = "[email protected]" | ||
testGroup = "test_group" | ||
testDomain = "default" | ||
testUser = "test_user" | ||
testPass = "test_pass" | ||
testEmail = "[email protected]" | ||
testGroup = "test_group" | ||
testDomainID = "15554e5bbd4347e4960dc735dd7be4f3" | ||
testDomainName = "some-name" | ||
testDomainDefault = "default" | ||
) | ||
|
||
var ( | ||
|
@@ -49,7 +51,7 @@ func getAdminToken(t *testing.T, adminName, adminPass string) (token, id string) | |
Password: password{ | ||
User: user{ | ||
Name: adminName, | ||
Domain: domain{ID: testDomain}, | ||
Domain: domainKeystone{ID: testDomainDefault}, | ||
Password: adminPass, | ||
}, | ||
}, | ||
|
@@ -214,7 +216,7 @@ func TestIncorrectCredentialsLogin(t *testing.T) { | |
setupVariables(t) | ||
c := conn{ | ||
client: http.DefaultClient, | ||
Host: keystoneURL, Domain: testDomain, | ||
Host: keystoneURL, Domain: domainKeystone{ID: testDomainDefault}, | ||
AdminUsername: adminUser, AdminPassword: adminPass, | ||
} | ||
s := connector.Scopes{OfflineAccess: true, Groups: true} | ||
|
@@ -239,7 +241,7 @@ func TestValidUserLogin(t *testing.T) { | |
|
||
type tUser struct { | ||
username string | ||
domain string | ||
domain domainKeystone | ||
email string | ||
password string | ||
} | ||
|
@@ -259,7 +261,7 @@ func TestValidUserLogin(t *testing.T) { | |
name: "test with email address", | ||
input: tUser{ | ||
username: testUser, | ||
domain: testDomain, | ||
domain: domainKeystone{ID: testDomainDefault}, | ||
email: testEmail, | ||
password: testPass, | ||
}, | ||
|
@@ -273,7 +275,7 @@ func TestValidUserLogin(t *testing.T) { | |
name: "test without email address", | ||
input: tUser{ | ||
username: testUser, | ||
domain: testDomain, | ||
domain: domainKeystone{ID: testDomainDefault}, | ||
email: "", | ||
password: testPass, | ||
}, | ||
|
@@ -283,6 +285,34 @@ func TestValidUserLogin(t *testing.T) { | |
verifiedEmail: false, | ||
}, | ||
}, | ||
{ | ||
name: "test with domain ID", | ||
input: tUser{ | ||
username: testUser, | ||
domain: domainKeystone{ID: testDomainID}, | ||
email: testEmail, | ||
password: testPass, | ||
}, | ||
expected: expect{ | ||
username: testUser, | ||
email: testEmail, | ||
verifiedEmail: true, | ||
}, | ||
}, | ||
{ | ||
name: "test with domain Name", | ||
input: tUser{ | ||
username: testUser, | ||
domain: domainKeystone{ID: testDomainName}, | ||
email: testEmail, | ||
password: testPass, | ||
}, | ||
expected: expect{ | ||
username: testUser, | ||
email: testEmail, | ||
verifiedEmail: true, | ||
}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
|
@@ -330,7 +360,7 @@ func TestUseRefreshToken(t *testing.T) { | |
|
||
c := conn{ | ||
client: http.DefaultClient, | ||
Host: keystoneURL, Domain: testDomain, | ||
Host: keystoneURL, Domain: domainKeystone{ID: testDomainDefault}, | ||
AdminUsername: adminUser, AdminPassword: adminPass, | ||
} | ||
s := connector.Scopes{OfflineAccess: true, Groups: true} | ||
|
@@ -356,7 +386,7 @@ func TestUseRefreshTokenUserDeleted(t *testing.T) { | |
|
||
c := conn{ | ||
client: http.DefaultClient, | ||
Host: keystoneURL, Domain: testDomain, | ||
Host: keystoneURL, Domain: domainKeystone{ID: testDomainDefault}, | ||
AdminUsername: adminUser, AdminPassword: adminPass, | ||
} | ||
s := connector.Scopes{OfflineAccess: true, Groups: true} | ||
|
@@ -387,7 +417,7 @@ func TestUseRefreshTokenGroupsChanged(t *testing.T) { | |
|
||
c := conn{ | ||
client: http.DefaultClient, | ||
Host: keystoneURL, Domain: testDomain, | ||
Host: keystoneURL, Domain: domainKeystone{ID: testDomainDefault}, | ||
AdminUsername: adminUser, AdminPassword: adminPass, | ||
} | ||
s := connector.Scopes{OfflineAccess: true, Groups: true} | ||
|
@@ -424,7 +454,7 @@ func TestNoGroupsInScope(t *testing.T) { | |
|
||
c := conn{ | ||
client: http.DefaultClient, | ||
Host: keystoneURL, Domain: testDomain, | ||
Host: keystoneURL, Domain: domainKeystone{ID: testDomainDefault}, | ||
AdminUsername: adminUser, AdminPassword: adminPass, | ||
} | ||
s := connector.Scopes{OfflineAccess: true, Groups: false} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters