forked from Deuxfleurs/bottin
Disable reconnect in tests + some cosmetic changes
This commit is contained in:
parent
a08be6b395
commit
dbd9003714
4 changed files with 12 additions and 30 deletions
|
@ -147,14 +147,12 @@ func TestDeleteGroupsAfterAddedUsers(t *testing.T) {
|
||||||
|
|
||||||
//Example of paralellism Test
|
//Example of paralellism Test
|
||||||
func TestPrincipal(t *testing.T) {
|
func TestPrincipal(t *testing.T) {
|
||||||
|
t.Run("A=Add and delete", TestAddThenDelete)
|
||||||
t.Run("A=1", TestAddThenDelete)
|
t.Run("A=Modify", TestModifyRequest)
|
||||||
t.Run("A=2", TestModifyRequest)
|
|
||||||
if !testing.Short() {
|
if !testing.Short() {
|
||||||
t.Run("B=1", TestConfirmAddAttributes)
|
t.Run("B=Add attributes", TestConfirmAddAttributes)
|
||||||
t.Run("B=2", TestModifyRequestAndCheck)
|
t.Run("B=Modify and check", TestModifyRequestAndCheck)
|
||||||
t.Run("C=1", TestAddUserInGroup)
|
t.Run("C=Add user in group", TestAddUserInGroup)
|
||||||
t.Run("C=2", TestDeleteGroupsAfterAddedUsers)
|
t.Run("C=Delete group", TestDeleteGroupsAfterAddedUsers)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,18 +54,6 @@ func (inst *instance) GenerateName() (name string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handler to around the bug with MessageId
|
|
||||||
func (inst *instance) Reconnect() (err error) {
|
|
||||||
inst.logging.Close()
|
|
||||||
inst.logging, err = ldap.Dial("tcp", fmt.Sprintf("%s:%d", adresse, port))
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = inst.logging.Bind(bindusername, bindpassword)
|
|
||||||
//logging.Debug("Reconnect succesful")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//Transform attributes in map format to the struct attributes
|
//Transform attributes in map format to the struct attributes
|
||||||
func MapAttToStruct(att map[string][]string) []attributes {
|
func MapAttToStruct(att map[string][]string) []attributes {
|
||||||
resultat := []attributes{}
|
resultat := []attributes{}
|
||||||
|
@ -88,7 +76,7 @@ func Connect() (*ldap.Conn, error) {
|
||||||
if key, ok := os.LookupEnv("BOTTIN_DEFAULT_ADMIN_PW"); ok {
|
if key, ok := os.LookupEnv("BOTTIN_DEFAULT_ADMIN_PW"); ok {
|
||||||
bindpassword = key
|
bindpassword = key
|
||||||
}
|
}
|
||||||
|
//l.Debug.Enable(true)
|
||||||
err = l.Bind(bindusername, bindpassword)
|
err = l.Bind(bindusername, bindpassword)
|
||||||
logging.Debug("Connection succesful")
|
logging.Debug("Connection succesful")
|
||||||
return l, err
|
return l, err
|
||||||
|
|
|
@ -13,8 +13,6 @@ func (inst *instance) Add_Request(dn string, attributes map[string][]string) err
|
||||||
|
|
||||||
//Send the request
|
//Send the request
|
||||||
err := inst.logging.Add(req)
|
err := inst.logging.Add(req)
|
||||||
//@FIXME: Remove when you try to correct the bug MessageID
|
|
||||||
inst.Reconnect()
|
|
||||||
return err
|
return err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,8 +34,6 @@ func (inst *instance) Modify_Request(dn string, add_attributes, delete_attribute
|
||||||
}
|
}
|
||||||
|
|
||||||
err := inst.logging.Modify(modifyReq)
|
err := inst.logging.Modify(modifyReq)
|
||||||
//@FIXME: Remove when you try to correct the bug MessageID
|
|
||||||
inst.Reconnect()
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +41,6 @@ func (inst *instance) Delete_Request(dn string) error {
|
||||||
del := ldap.NewDelRequest(dn, nil)
|
del := ldap.NewDelRequest(dn, nil)
|
||||||
|
|
||||||
err := inst.logging.Del(del)
|
err := inst.logging.Del(del)
|
||||||
//@FIXME: Remove when you try to correct the bug MessageID
|
|
||||||
inst.Reconnect()
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +55,5 @@ func (inst *instance) Search_Request(dn, filter string, name_attributes []string
|
||||||
|
|
||||||
res, err := inst.logging.Search(searchReq)
|
res, err := inst.logging.Search(searchReq)
|
||||||
logging.Debugf("Search Request made with: dn: %s, filter: %s, attributes: %s. \n", dn, filter, name_attributes)
|
logging.Debugf("Search Request made with: dn: %s, filter: %s, attributes: %s. \n", dn, filter, name_attributes)
|
||||||
//@FIXME: Remove when you try to correct the bug MessageID
|
|
||||||
inst.Reconnect()
|
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,11 @@ echo $BOTTIN_DEFAULT_ADMIN_PW
|
||||||
consul agent -dev > /dev/null 2>&1 &
|
consul agent -dev > /dev/null 2>&1 &
|
||||||
sleep 2
|
sleep 2
|
||||||
cp test/config.json.test config.json
|
cp test/config.json.test config.json
|
||||||
./bottin > /dev/null 2>&1 &
|
./bottin > /tmp/bottin.log 2>&1 &
|
||||||
sleep 1
|
sleep 1
|
||||||
./test/test -test.v -test.failfast -test.short -test.run TestPrincipal
|
./test/test -test.v -test.failfast -test.short -test.run TestPrincipal
|
||||||
./test/test -test.v -test.failfast -test.run TestPrincipal/B=
|
./test/test -test.v -test.failfast -test.run TestPrincipal/B=
|
||||||
|
|
||||||
|
jobs
|
||||||
|
kill %2
|
||||||
|
kill %1
|
||||||
|
|
Loading…
Reference in a new issue