mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-31 03:51:23 +01:00
commit
b83df87b79
@ -365,7 +365,13 @@ func GetDatabaseFromCfg(cfg map[string]interface{}) *models.Database {
|
||||
|
||||
// Valid LDAP Scope
|
||||
func validLdapScope(cfg map[string]interface{}, isMigrate bool) {
|
||||
ldapScope := cfg[ldapScopeKey].(int)
|
||||
ldapScope, ok := cfg[ldapScopeKey].(int)
|
||||
if !ok {
|
||||
ldapScopeFloat, ok := cfg[ldapScopeKey].(float64)
|
||||
if ok {
|
||||
ldapScope = int(ldapScopeFloat)
|
||||
}
|
||||
}
|
||||
if isMigrate && ldapScope > 0 && ldapScope < 3 {
|
||||
ldapScope = ldapScope - 1
|
||||
}
|
||||
|
@ -143,6 +143,8 @@ func TestGetDatabaseFromCfg(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidLdapScope(t *testing.T) {
|
||||
var dbValue float64
|
||||
dbValue = 2
|
||||
ldapScopeKey := "ldap_scope"
|
||||
testCfgs := []struct {
|
||||
config map[string]interface{}
|
||||
@ -167,6 +169,9 @@ func TestValidLdapScope(t *testing.T) {
|
||||
{map[string]interface{}{
|
||||
ldapScopeKey: -100,
|
||||
}, false, 0},
|
||||
{map[string]interface{}{
|
||||
ldapScopeKey: dbValue,
|
||||
}, false, 2},
|
||||
}
|
||||
|
||||
for i, item := range testCfgs {
|
||||
|
Loading…
Reference in New Issue
Block a user