|
|
@ -7,7 +7,7 @@ package cmd |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
"code.gitea.io/gitea/models/login" |
|
|
|
"code.gitea.io/gitea/services/auth/source/ldap" |
|
|
|
"code.gitea.io/gitea/services/auth/source/ldap" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert" |
|
|
|
"github.com/stretchr/testify/assert" |
|
|
@ -23,7 +23,7 @@ func TestAddLdapBindDn(t *testing.T) { |
|
|
|
// Test cases
|
|
|
|
// Test cases
|
|
|
|
var cases = []struct { |
|
|
|
var cases = []struct { |
|
|
|
args []string |
|
|
|
args []string |
|
|
|
loginSource *models.LoginSource |
|
|
|
loginSource *login.Source |
|
|
|
errMsg string |
|
|
|
errMsg string |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
// case 0
|
|
|
|
// case 0
|
|
|
@ -51,8 +51,8 @@ func TestAddLdapBindDn(t *testing.T) { |
|
|
|
"--synchronize-users", |
|
|
|
"--synchronize-users", |
|
|
|
"--page-size", "99", |
|
|
|
"--page-size", "99", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Name: "ldap (via Bind DN) source full", |
|
|
|
Name: "ldap (via Bind DN) source full", |
|
|
|
IsActive: false, |
|
|
|
IsActive: false, |
|
|
|
IsSyncEnabled: true, |
|
|
|
IsSyncEnabled: true, |
|
|
@ -91,8 +91,8 @@ func TestAddLdapBindDn(t *testing.T) { |
|
|
|
"--user-filter", "(memberOf=cn=user-group,ou=example,dc=min-domain-bind,dc=org)", |
|
|
|
"--user-filter", "(memberOf=cn=user-group,ou=example,dc=min-domain-bind,dc=org)", |
|
|
|
"--email-attribute", "mail-bind min", |
|
|
|
"--email-attribute", "mail-bind min", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Name: "ldap (via Bind DN) source min", |
|
|
|
Name: "ldap (via Bind DN) source min", |
|
|
|
IsActive: true, |
|
|
|
IsActive: true, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
@ -203,20 +203,20 @@ func TestAddLdapBindDn(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
for n, c := range cases { |
|
|
|
for n, c := range cases { |
|
|
|
// Mock functions.
|
|
|
|
// Mock functions.
|
|
|
|
var createdLoginSource *models.LoginSource |
|
|
|
var createdLoginSource *login.Source |
|
|
|
service := &authService{ |
|
|
|
service := &authService{ |
|
|
|
initDB: func() error { |
|
|
|
initDB: func() error { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}, |
|
|
|
}, |
|
|
|
createLoginSource: func(loginSource *models.LoginSource) error { |
|
|
|
createLoginSource: func(loginSource *login.Source) error { |
|
|
|
createdLoginSource = loginSource |
|
|
|
createdLoginSource = loginSource |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}, |
|
|
|
}, |
|
|
|
updateLoginSource: func(loginSource *models.LoginSource) error { |
|
|
|
updateLoginSource: func(loginSource *login.Source) error { |
|
|
|
assert.FailNow(t, "case %d: should not call updateLoginSource", n) |
|
|
|
assert.FailNow(t, "case %d: should not call updateLoginSource", n) |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}, |
|
|
|
}, |
|
|
|
getLoginSourceByID: func(id int64) (*models.LoginSource, error) { |
|
|
|
getLoginSourceByID: func(id int64) (*login.Source, error) { |
|
|
|
assert.FailNow(t, "case %d: should not call getLoginSourceByID", n) |
|
|
|
assert.FailNow(t, "case %d: should not call getLoginSourceByID", n) |
|
|
|
return nil, nil |
|
|
|
return nil, nil |
|
|
|
}, |
|
|
|
}, |
|
|
@ -247,7 +247,7 @@ func TestAddLdapSimpleAuth(t *testing.T) { |
|
|
|
// Test cases
|
|
|
|
// Test cases
|
|
|
|
var cases = []struct { |
|
|
|
var cases = []struct { |
|
|
|
args []string |
|
|
|
args []string |
|
|
|
loginSource *models.LoginSource |
|
|
|
loginSource *login.Source |
|
|
|
errMsg string |
|
|
|
errMsg string |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
// case 0
|
|
|
|
// case 0
|
|
|
@ -271,8 +271,8 @@ func TestAddLdapSimpleAuth(t *testing.T) { |
|
|
|
"--public-ssh-key-attribute", "publickey-simple full", |
|
|
|
"--public-ssh-key-attribute", "publickey-simple full", |
|
|
|
"--user-dn", "cn=%s,ou=Users,dc=full-domain-simple,dc=org", |
|
|
|
"--user-dn", "cn=%s,ou=Users,dc=full-domain-simple,dc=org", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Name: "ldap (simple auth) source full", |
|
|
|
Name: "ldap (simple auth) source full", |
|
|
|
IsActive: false, |
|
|
|
IsActive: false, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
@ -307,8 +307,8 @@ func TestAddLdapSimpleAuth(t *testing.T) { |
|
|
|
"--email-attribute", "mail-simple min", |
|
|
|
"--email-attribute", "mail-simple min", |
|
|
|
"--user-dn", "cn=%s,ou=Users,dc=min-domain-simple,dc=org", |
|
|
|
"--user-dn", "cn=%s,ou=Users,dc=min-domain-simple,dc=org", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Name: "ldap (simple auth) source min", |
|
|
|
Name: "ldap (simple auth) source min", |
|
|
|
IsActive: true, |
|
|
|
IsActive: true, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
@ -432,20 +432,20 @@ func TestAddLdapSimpleAuth(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
for n, c := range cases { |
|
|
|
for n, c := range cases { |
|
|
|
// Mock functions.
|
|
|
|
// Mock functions.
|
|
|
|
var createdLoginSource *models.LoginSource |
|
|
|
var createdLoginSource *login.Source |
|
|
|
service := &authService{ |
|
|
|
service := &authService{ |
|
|
|
initDB: func() error { |
|
|
|
initDB: func() error { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}, |
|
|
|
}, |
|
|
|
createLoginSource: func(loginSource *models.LoginSource) error { |
|
|
|
createLoginSource: func(loginSource *login.Source) error { |
|
|
|
createdLoginSource = loginSource |
|
|
|
createdLoginSource = loginSource |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}, |
|
|
|
}, |
|
|
|
updateLoginSource: func(loginSource *models.LoginSource) error { |
|
|
|
updateLoginSource: func(loginSource *login.Source) error { |
|
|
|
assert.FailNow(t, "case %d: should not call updateLoginSource", n) |
|
|
|
assert.FailNow(t, "case %d: should not call updateLoginSource", n) |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}, |
|
|
|
}, |
|
|
|
getLoginSourceByID: func(id int64) (*models.LoginSource, error) { |
|
|
|
getLoginSourceByID: func(id int64) (*login.Source, error) { |
|
|
|
assert.FailNow(t, "case %d: should not call getLoginSourceByID", n) |
|
|
|
assert.FailNow(t, "case %d: should not call getLoginSourceByID", n) |
|
|
|
return nil, nil |
|
|
|
return nil, nil |
|
|
|
}, |
|
|
|
}, |
|
|
@ -477,8 +477,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
var cases = []struct { |
|
|
|
var cases = []struct { |
|
|
|
args []string |
|
|
|
args []string |
|
|
|
id int64 |
|
|
|
id int64 |
|
|
|
existingLoginSource *models.LoginSource |
|
|
|
existingLoginSource *login.Source |
|
|
|
loginSource *models.LoginSource |
|
|
|
loginSource *login.Source |
|
|
|
errMsg string |
|
|
|
errMsg string |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
// case 0
|
|
|
|
// case 0
|
|
|
@ -507,15 +507,15 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--page-size", "99", |
|
|
|
"--page-size", "99", |
|
|
|
}, |
|
|
|
}, |
|
|
|
id: 23, |
|
|
|
id: 23, |
|
|
|
existingLoginSource: &models.LoginSource{ |
|
|
|
existingLoginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
IsActive: true, |
|
|
|
IsActive: true, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Enabled: true, |
|
|
|
Enabled: true, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Name: "ldap (via Bind DN) source full", |
|
|
|
Name: "ldap (via Bind DN) source full", |
|
|
|
IsActive: false, |
|
|
|
IsActive: false, |
|
|
|
IsSyncEnabled: true, |
|
|
|
IsSyncEnabled: true, |
|
|
@ -548,8 +548,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"ldap-test", |
|
|
|
"ldap-test", |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -560,8 +560,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--name", "ldap (via Bind DN) source", |
|
|
|
"--name", "ldap (via Bind DN) source", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Name: "ldap (via Bind DN) source", |
|
|
|
Name: "ldap (via Bind DN) source", |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Name: "ldap (via Bind DN) source", |
|
|
|
Name: "ldap (via Bind DN) source", |
|
|
@ -575,13 +575,13 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--not-active", |
|
|
|
"--not-active", |
|
|
|
}, |
|
|
|
}, |
|
|
|
existingLoginSource: &models.LoginSource{ |
|
|
|
existingLoginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
IsActive: true, |
|
|
|
IsActive: true, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
IsActive: false, |
|
|
|
IsActive: false, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -593,8 +593,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--security-protocol", "LDAPS", |
|
|
|
"--security-protocol", "LDAPS", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
SecurityProtocol: ldap.SecurityProtocol(1), |
|
|
|
SecurityProtocol: ldap.SecurityProtocol(1), |
|
|
|
}, |
|
|
|
}, |
|
|
@ -607,8 +607,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--skip-tls-verify", |
|
|
|
"--skip-tls-verify", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
SkipVerify: true, |
|
|
|
SkipVerify: true, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -621,8 +621,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--host", "ldap-server", |
|
|
|
"--host", "ldap-server", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Host: "ldap-server", |
|
|
|
Host: "ldap-server", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -635,8 +635,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--port", "389", |
|
|
|
"--port", "389", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Port: 389, |
|
|
|
Port: 389, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -649,8 +649,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--user-search-base", "ou=Users,dc=domain,dc=org", |
|
|
|
"--user-search-base", "ou=Users,dc=domain,dc=org", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
UserBase: "ou=Users,dc=domain,dc=org", |
|
|
|
UserBase: "ou=Users,dc=domain,dc=org", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -663,8 +663,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--user-filter", "(memberOf=cn=user-group,ou=example,dc=domain,dc=org)", |
|
|
|
"--user-filter", "(memberOf=cn=user-group,ou=example,dc=domain,dc=org)", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Filter: "(memberOf=cn=user-group,ou=example,dc=domain,dc=org)", |
|
|
|
Filter: "(memberOf=cn=user-group,ou=example,dc=domain,dc=org)", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -677,8 +677,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--admin-filter", "(memberOf=cn=admin-group,ou=example,dc=domain,dc=org)", |
|
|
|
"--admin-filter", "(memberOf=cn=admin-group,ou=example,dc=domain,dc=org)", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
AdminFilter: "(memberOf=cn=admin-group,ou=example,dc=domain,dc=org)", |
|
|
|
AdminFilter: "(memberOf=cn=admin-group,ou=example,dc=domain,dc=org)", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -691,8 +691,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--username-attribute", "uid", |
|
|
|
"--username-attribute", "uid", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
AttributeUsername: "uid", |
|
|
|
AttributeUsername: "uid", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -705,8 +705,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--firstname-attribute", "givenName", |
|
|
|
"--firstname-attribute", "givenName", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
AttributeName: "givenName", |
|
|
|
AttributeName: "givenName", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -719,8 +719,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--surname-attribute", "sn", |
|
|
|
"--surname-attribute", "sn", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
AttributeSurname: "sn", |
|
|
|
AttributeSurname: "sn", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -733,8 +733,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--email-attribute", "mail", |
|
|
|
"--email-attribute", "mail", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
AttributeMail: "mail", |
|
|
|
AttributeMail: "mail", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -747,8 +747,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--attributes-in-bind", |
|
|
|
"--attributes-in-bind", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
AttributesInBind: true, |
|
|
|
AttributesInBind: true, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -761,8 +761,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--public-ssh-key-attribute", "publickey", |
|
|
|
"--public-ssh-key-attribute", "publickey", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
AttributeSSHPublicKey: "publickey", |
|
|
|
AttributeSSHPublicKey: "publickey", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -775,8 +775,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--bind-dn", "cn=readonly,dc=domain,dc=org", |
|
|
|
"--bind-dn", "cn=readonly,dc=domain,dc=org", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
BindDN: "cn=readonly,dc=domain,dc=org", |
|
|
|
BindDN: "cn=readonly,dc=domain,dc=org", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -789,8 +789,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--bind-password", "secret", |
|
|
|
"--bind-password", "secret", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
BindPassword: "secret", |
|
|
|
BindPassword: "secret", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -803,8 +803,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--synchronize-users", |
|
|
|
"--synchronize-users", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
IsSyncEnabled: true, |
|
|
|
IsSyncEnabled: true, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -816,8 +816,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--page-size", "12", |
|
|
|
"--page-size", "12", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
SearchPageSize: 12, |
|
|
|
SearchPageSize: 12, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -845,8 +845,8 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
"ldap-test", |
|
|
|
"ldap-test", |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
}, |
|
|
|
}, |
|
|
|
existingLoginSource: &models.LoginSource{ |
|
|
|
existingLoginSource: &login.Source{ |
|
|
|
Type: models.LoginOAuth2, |
|
|
|
Type: login.OAuth2, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
errMsg: "Invalid authentication type. expected: LDAP (via BindDN), actual: OAuth2", |
|
|
|
errMsg: "Invalid authentication type. expected: LDAP (via BindDN), actual: OAuth2", |
|
|
@ -855,28 +855,28 @@ func TestUpdateLdapBindDn(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
for n, c := range cases { |
|
|
|
for n, c := range cases { |
|
|
|
// Mock functions.
|
|
|
|
// Mock functions.
|
|
|
|
var updatedLoginSource *models.LoginSource |
|
|
|
var updatedLoginSource *login.Source |
|
|
|
service := &authService{ |
|
|
|
service := &authService{ |
|
|
|
initDB: func() error { |
|
|
|
initDB: func() error { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}, |
|
|
|
}, |
|
|
|
createLoginSource: func(loginSource *models.LoginSource) error { |
|
|
|
createLoginSource: func(loginSource *login.Source) error { |
|
|
|
assert.FailNow(t, "case %d: should not call createLoginSource", n) |
|
|
|
assert.FailNow(t, "case %d: should not call createLoginSource", n) |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}, |
|
|
|
}, |
|
|
|
updateLoginSource: func(loginSource *models.LoginSource) error { |
|
|
|
updateLoginSource: func(loginSource *login.Source) error { |
|
|
|
updatedLoginSource = loginSource |
|
|
|
updatedLoginSource = loginSource |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}, |
|
|
|
}, |
|
|
|
getLoginSourceByID: func(id int64) (*models.LoginSource, error) { |
|
|
|
getLoginSourceByID: func(id int64) (*login.Source, error) { |
|
|
|
if c.id != 0 { |
|
|
|
if c.id != 0 { |
|
|
|
assert.Equal(t, c.id, id, "case %d: wrong id", n) |
|
|
|
assert.Equal(t, c.id, id, "case %d: wrong id", n) |
|
|
|
} |
|
|
|
} |
|
|
|
if c.existingLoginSource != nil { |
|
|
|
if c.existingLoginSource != nil { |
|
|
|
return c.existingLoginSource, nil |
|
|
|
return c.existingLoginSource, nil |
|
|
|
} |
|
|
|
} |
|
|
|
return &models.LoginSource{ |
|
|
|
return &login.Source{ |
|
|
|
Type: models.LoginLDAP, |
|
|
|
Type: login.LDAP, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
}, nil |
|
|
|
}, nil |
|
|
|
}, |
|
|
|
}, |
|
|
@ -908,8 +908,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
var cases = []struct { |
|
|
|
var cases = []struct { |
|
|
|
args []string |
|
|
|
args []string |
|
|
|
id int64 |
|
|
|
id int64 |
|
|
|
existingLoginSource *models.LoginSource |
|
|
|
existingLoginSource *login.Source |
|
|
|
loginSource *models.LoginSource |
|
|
|
loginSource *login.Source |
|
|
|
errMsg string |
|
|
|
errMsg string |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
// case 0
|
|
|
|
// case 0
|
|
|
@ -935,8 +935,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--user-dn", "cn=%s,ou=Users,dc=full-domain-simple,dc=org", |
|
|
|
"--user-dn", "cn=%s,ou=Users,dc=full-domain-simple,dc=org", |
|
|
|
}, |
|
|
|
}, |
|
|
|
id: 7, |
|
|
|
id: 7, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Name: "ldap (simple auth) source full", |
|
|
|
Name: "ldap (simple auth) source full", |
|
|
|
IsActive: false, |
|
|
|
IsActive: false, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
@ -964,8 +964,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"ldap-test", |
|
|
|
"ldap-test", |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -976,8 +976,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--name", "ldap (simple auth) source", |
|
|
|
"--name", "ldap (simple auth) source", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Name: "ldap (simple auth) source", |
|
|
|
Name: "ldap (simple auth) source", |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Name: "ldap (simple auth) source", |
|
|
|
Name: "ldap (simple auth) source", |
|
|
@ -991,13 +991,13 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--not-active", |
|
|
|
"--not-active", |
|
|
|
}, |
|
|
|
}, |
|
|
|
existingLoginSource: &models.LoginSource{ |
|
|
|
existingLoginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
IsActive: true, |
|
|
|
IsActive: true, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
IsActive: false, |
|
|
|
IsActive: false, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1009,8 +1009,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--security-protocol", "starttls", |
|
|
|
"--security-protocol", "starttls", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
SecurityProtocol: ldap.SecurityProtocol(2), |
|
|
|
SecurityProtocol: ldap.SecurityProtocol(2), |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1023,8 +1023,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--skip-tls-verify", |
|
|
|
"--skip-tls-verify", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
SkipVerify: true, |
|
|
|
SkipVerify: true, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1037,8 +1037,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--host", "ldap-server", |
|
|
|
"--host", "ldap-server", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Host: "ldap-server", |
|
|
|
Host: "ldap-server", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1051,8 +1051,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--port", "987", |
|
|
|
"--port", "987", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Port: 987, |
|
|
|
Port: 987, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1065,8 +1065,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--user-search-base", "ou=Users,dc=domain,dc=org", |
|
|
|
"--user-search-base", "ou=Users,dc=domain,dc=org", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
UserBase: "ou=Users,dc=domain,dc=org", |
|
|
|
UserBase: "ou=Users,dc=domain,dc=org", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1079,8 +1079,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--user-filter", "(&(objectClass=posixAccount)(cn=%s))", |
|
|
|
"--user-filter", "(&(objectClass=posixAccount)(cn=%s))", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Filter: "(&(objectClass=posixAccount)(cn=%s))", |
|
|
|
Filter: "(&(objectClass=posixAccount)(cn=%s))", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1093,8 +1093,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--admin-filter", "(memberOf=cn=admin-group,ou=example,dc=domain,dc=org)", |
|
|
|
"--admin-filter", "(memberOf=cn=admin-group,ou=example,dc=domain,dc=org)", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
AdminFilter: "(memberOf=cn=admin-group,ou=example,dc=domain,dc=org)", |
|
|
|
AdminFilter: "(memberOf=cn=admin-group,ou=example,dc=domain,dc=org)", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1107,8 +1107,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--username-attribute", "uid", |
|
|
|
"--username-attribute", "uid", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
AttributeUsername: "uid", |
|
|
|
AttributeUsername: "uid", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1121,8 +1121,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--firstname-attribute", "givenName", |
|
|
|
"--firstname-attribute", "givenName", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
AttributeName: "givenName", |
|
|
|
AttributeName: "givenName", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1135,8 +1135,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--surname-attribute", "sn", |
|
|
|
"--surname-attribute", "sn", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
AttributeSurname: "sn", |
|
|
|
AttributeSurname: "sn", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1149,8 +1149,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--email-attribute", "mail", |
|
|
|
"--email-attribute", "mail", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
|
|
|
|
|
|
|
|
AttributeMail: "mail", |
|
|
|
AttributeMail: "mail", |
|
|
@ -1164,8 +1164,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--public-ssh-key-attribute", "publickey", |
|
|
|
"--public-ssh-key-attribute", "publickey", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
AttributeSSHPublicKey: "publickey", |
|
|
|
AttributeSSHPublicKey: "publickey", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1178,8 +1178,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
"--user-dn", "cn=%s,ou=Users,dc=domain,dc=org", |
|
|
|
"--user-dn", "cn=%s,ou=Users,dc=domain,dc=org", |
|
|
|
}, |
|
|
|
}, |
|
|
|
loginSource: &models.LoginSource{ |
|
|
|
loginSource: &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
Cfg: &ldap.Source{ |
|
|
|
UserDN: "cn=%s,ou=Users,dc=domain,dc=org", |
|
|
|
UserDN: "cn=%s,ou=Users,dc=domain,dc=org", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1207,8 +1207,8 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
"ldap-test", |
|
|
|
"ldap-test", |
|
|
|
"--id", "1", |
|
|
|
"--id", "1", |
|
|
|
}, |
|
|
|
}, |
|
|
|
existingLoginSource: &models.LoginSource{ |
|
|
|
existingLoginSource: &login.Source{ |
|
|
|
Type: models.LoginPAM, |
|
|
|
Type: login.PAM, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
errMsg: "Invalid authentication type. expected: LDAP (simple auth), actual: PAM", |
|
|
|
errMsg: "Invalid authentication type. expected: LDAP (simple auth), actual: PAM", |
|
|
@ -1217,28 +1217,28 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
for n, c := range cases { |
|
|
|
for n, c := range cases { |
|
|
|
// Mock functions.
|
|
|
|
// Mock functions.
|
|
|
|
var updatedLoginSource *models.LoginSource |
|
|
|
var updatedLoginSource *login.Source |
|
|
|
service := &authService{ |
|
|
|
service := &authService{ |
|
|
|
initDB: func() error { |
|
|
|
initDB: func() error { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}, |
|
|
|
}, |
|
|
|
createLoginSource: func(loginSource *models.LoginSource) error { |
|
|
|
createLoginSource: func(loginSource *login.Source) error { |
|
|
|
assert.FailNow(t, "case %d: should not call createLoginSource", n) |
|
|
|
assert.FailNow(t, "case %d: should not call createLoginSource", n) |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}, |
|
|
|
}, |
|
|
|
updateLoginSource: func(loginSource *models.LoginSource) error { |
|
|
|
updateLoginSource: func(loginSource *login.Source) error { |
|
|
|
updatedLoginSource = loginSource |
|
|
|
updatedLoginSource = loginSource |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}, |
|
|
|
}, |
|
|
|
getLoginSourceByID: func(id int64) (*models.LoginSource, error) { |
|
|
|
getLoginSourceByID: func(id int64) (*login.Source, error) { |
|
|
|
if c.id != 0 { |
|
|
|
if c.id != 0 { |
|
|
|
assert.Equal(t, c.id, id, "case %d: wrong id", n) |
|
|
|
assert.Equal(t, c.id, id, "case %d: wrong id", n) |
|
|
|
} |
|
|
|
} |
|
|
|
if c.existingLoginSource != nil { |
|
|
|
if c.existingLoginSource != nil { |
|
|
|
return c.existingLoginSource, nil |
|
|
|
return c.existingLoginSource, nil |
|
|
|
} |
|
|
|
} |
|
|
|
return &models.LoginSource{ |
|
|
|
return &login.Source{ |
|
|
|
Type: models.LoginDLDAP, |
|
|
|
Type: login.DLDAP, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
Cfg: &ldap.Source{}, |
|
|
|
}, nil |
|
|
|
}, nil |
|
|
|
}, |
|
|
|
}, |
|
|
|