@@ -115,7 +115,8 @@ func (c *Config) Open(id string, logger log.Logger) (connector.Connector, error)
|
||||
c.Host,
|
||||
c.AdminUsername,
|
||||
c.AdminPassword,
|
||||
logger}, nil
|
||||
logger,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *conn) Close() error { return nil }
|
||||
@@ -137,7 +138,7 @@ func (p *conn) Login(ctx context.Context, scopes connector.Scopes, username, pas
|
||||
return identity, false, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
var tokenResp = new(tokenResponse)
|
||||
tokenResp := new(tokenResponse)
|
||||
err = json.Unmarshal(data, &tokenResp)
|
||||
if err != nil {
|
||||
return identity, false, fmt.Errorf("keystone: invalid token response: %v", err)
|
||||
@@ -295,7 +296,7 @@ func (p *conn) getUserGroups(ctx context.Context, userID string, token string) (
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var groupsResp = new(groupsResponse)
|
||||
groupsResp := new(groupsResponse)
|
||||
|
||||
err = json.Unmarshal(data, &groupsResp)
|
||||
if err != nil {
|
||||
|
@@ -84,7 +84,7 @@ func getAdminToken(t *testing.T, adminName, adminPass string) (token, id string)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var tokenResp = new(tokenResponse)
|
||||
tokenResp := new(tokenResponse)
|
||||
err = json.Unmarshal(data, &tokenResp)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -128,7 +128,7 @@ func createUser(t *testing.T, token, userName, userEmail, userPass string) strin
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var userResp = new(userResponse)
|
||||
userResp := new(userResponse)
|
||||
err = json.Unmarshal(data, &userResp)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -189,7 +189,7 @@ func createGroup(t *testing.T, token, description, name string) string {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var groupResp = new(groupResponse)
|
||||
groupResp := new(groupResponse)
|
||||
err = json.Unmarshal(data, &groupResp)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -219,8 +219,10 @@ func addUserToGroup(t *testing.T, token, groupID, userID string) error {
|
||||
|
||||
func TestIncorrectCredentialsLogin(t *testing.T) {
|
||||
setupVariables(t)
|
||||
c := conn{Host: keystoneURL, Domain: testDomain,
|
||||
AdminUsername: adminUser, AdminPassword: adminPass}
|
||||
c := conn{
|
||||
Host: keystoneURL, Domain: testDomain,
|
||||
AdminUsername: adminUser, AdminPassword: adminPass,
|
||||
}
|
||||
s := connector.Scopes{OfflineAccess: true, Groups: true}
|
||||
_, validPW, err := c.Login(context.Background(), s, adminUser, invalidPass)
|
||||
|
||||
@@ -254,7 +256,7 @@ func TestValidUserLogin(t *testing.T) {
|
||||
verifiedEmail bool
|
||||
}
|
||||
|
||||
var tests = []struct {
|
||||
tests := []struct {
|
||||
name string
|
||||
input tUser
|
||||
expected expect
|
||||
@@ -294,8 +296,10 @@ func TestValidUserLogin(t *testing.T) {
|
||||
userID := createUser(t, token, tt.input.username, tt.input.email, tt.input.password)
|
||||
defer deleteResource(t, token, userID, usersURL)
|
||||
|
||||
c := conn{Host: keystoneURL, Domain: tt.input.domain,
|
||||
AdminUsername: adminUser, AdminPassword: adminPass}
|
||||
c := conn{
|
||||
Host: keystoneURL, Domain: tt.input.domain,
|
||||
AdminUsername: adminUser, AdminPassword: adminPass,
|
||||
}
|
||||
s := connector.Scopes{OfflineAccess: true, Groups: true}
|
||||
identity, validPW, err := c.Login(context.Background(), s, tt.input.username, tt.input.password)
|
||||
if err != nil {
|
||||
@@ -329,8 +333,10 @@ func TestUseRefreshToken(t *testing.T) {
|
||||
addUserToGroup(t, token, groupID, adminID)
|
||||
defer deleteResource(t, token, groupID, groupsURL)
|
||||
|
||||
c := conn{Host: keystoneURL, Domain: testDomain,
|
||||
AdminUsername: adminUser, AdminPassword: adminPass}
|
||||
c := conn{
|
||||
Host: keystoneURL, Domain: testDomain,
|
||||
AdminUsername: adminUser, AdminPassword: adminPass,
|
||||
}
|
||||
s := connector.Scopes{OfflineAccess: true, Groups: true}
|
||||
|
||||
identityLogin, _, err := c.Login(context.Background(), s, adminUser, adminPass)
|
||||
@@ -352,8 +358,10 @@ func TestUseRefreshTokenUserDeleted(t *testing.T) {
|
||||
token, _ := getAdminToken(t, adminUser, adminPass)
|
||||
userID := createUser(t, token, testUser, testEmail, testPass)
|
||||
|
||||
c := conn{Host: keystoneURL, Domain: testDomain,
|
||||
AdminUsername: adminUser, AdminPassword: adminPass}
|
||||
c := conn{
|
||||
Host: keystoneURL, Domain: testDomain,
|
||||
AdminUsername: adminUser, AdminPassword: adminPass,
|
||||
}
|
||||
s := connector.Scopes{OfflineAccess: true, Groups: true}
|
||||
|
||||
identityLogin, _, err := c.Login(context.Background(), s, testUser, testPass)
|
||||
@@ -380,8 +388,10 @@ func TestUseRefreshTokenGroupsChanged(t *testing.T) {
|
||||
userID := createUser(t, token, testUser, testEmail, testPass)
|
||||
defer deleteResource(t, token, userID, usersURL)
|
||||
|
||||
c := conn{Host: keystoneURL, Domain: testDomain,
|
||||
AdminUsername: adminUser, AdminPassword: adminPass}
|
||||
c := conn{
|
||||
Host: keystoneURL, Domain: testDomain,
|
||||
AdminUsername: adminUser, AdminPassword: adminPass,
|
||||
}
|
||||
s := connector.Scopes{OfflineAccess: true, Groups: true}
|
||||
|
||||
identityLogin, _, err := c.Login(context.Background(), s, testUser, testPass)
|
||||
@@ -414,8 +424,10 @@ func TestNoGroupsInScope(t *testing.T) {
|
||||
userID := createUser(t, token, testUser, testEmail, testPass)
|
||||
defer deleteResource(t, token, userID, usersURL)
|
||||
|
||||
c := conn{Host: keystoneURL, Domain: testDomain,
|
||||
AdminUsername: adminUser, AdminPassword: adminPass}
|
||||
c := conn{
|
||||
Host: keystoneURL, Domain: testDomain,
|
||||
AdminUsername: adminUser, AdminPassword: adminPass,
|
||||
}
|
||||
s := connector.Scopes{OfflineAccess: true, Groups: false}
|
||||
|
||||
groupID := createGroup(t, token, "Test group", testGroup)
|
||||
|
Reference in New Issue
Block a user