From b99a13cfa81b5e3db1acdb4a8e850df4fd2efbe2 Mon Sep 17 00:00:00 2001 From: stonezdj Date: Fri, 19 Jan 2018 11:46:24 +0800 Subject: [PATCH] Fix bug 4073 --- src/adminserver/systemcfg/systemcfg.go | 8 +++++++- src/adminserver/systemcfg/systemcfg_test.go | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/adminserver/systemcfg/systemcfg.go b/src/adminserver/systemcfg/systemcfg.go index 8d45cd654..b188fbfde 100644 --- a/src/adminserver/systemcfg/systemcfg.go +++ b/src/adminserver/systemcfg/systemcfg.go @@ -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 } diff --git a/src/adminserver/systemcfg/systemcfg_test.go b/src/adminserver/systemcfg/systemcfg_test.go index 000e4abdf..18c8099c0 100644 --- a/src/adminserver/systemcfg/systemcfg_test.go +++ b/src/adminserver/systemcfg/systemcfg_test.go @@ -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 {