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