Disable reconnect in tests + some cosmetic changes
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details

This commit is contained in:
Quentin 2021-09-16 13:52:46 +02:00
parent a08be6b395
commit dbd9003714
Signed by: quentin
GPG Key ID: A98E9B769E4FF428
4 changed files with 12 additions and 30 deletions

View File

@ -147,14 +147,12 @@ func TestDeleteGroupsAfterAddedUsers(t *testing.T) {
//Example of paralellism Test
func TestPrincipal(t *testing.T) {
t.Run("A=1", TestAddThenDelete)
t.Run("A=2", TestModifyRequest)
t.Run("A=Add and delete", TestAddThenDelete)
t.Run("A=Modify", TestModifyRequest)
if !testing.Short() {
t.Run("B=1", TestConfirmAddAttributes)
t.Run("B=2", TestModifyRequestAndCheck)
t.Run("C=1", TestAddUserInGroup)
t.Run("C=2", TestDeleteGroupsAfterAddedUsers)
t.Run("B=Add attributes", TestConfirmAddAttributes)
t.Run("B=Modify and check", TestModifyRequestAndCheck)
t.Run("C=Add user in group", TestAddUserInGroup)
t.Run("C=Delete group", TestDeleteGroupsAfterAddedUsers)
}
}

View File

@ -54,18 +54,6 @@ func (inst *instance) GenerateName() (name string) {
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
func MapAttToStruct(att map[string][]string) []attributes {
resultat := []attributes{}
@ -88,7 +76,7 @@ func Connect() (*ldap.Conn, error) {
if key, ok := os.LookupEnv("BOTTIN_DEFAULT_ADMIN_PW"); ok {
bindpassword = key
}
//l.Debug.Enable(true)
err = l.Bind(bindusername, bindpassword)
logging.Debug("Connection succesful")
return l, err

View File

@ -13,8 +13,6 @@ func (inst *instance) Add_Request(dn string, attributes map[string][]string) err
//Send the request
err := inst.logging.Add(req)
//@FIXME: Remove when you try to correct the bug MessageID
inst.Reconnect()
return err
}
@ -36,8 +34,6 @@ func (inst *instance) Modify_Request(dn string, add_attributes, delete_attribute
}
err := inst.logging.Modify(modifyReq)
//@FIXME: Remove when you try to correct the bug MessageID
inst.Reconnect()
return err
}
@ -45,8 +41,6 @@ func (inst *instance) Delete_Request(dn string) error {
del := ldap.NewDelRequest(dn, nil)
err := inst.logging.Del(del)
//@FIXME: Remove when you try to correct the bug MessageID
inst.Reconnect()
return err
}
@ -61,7 +55,5 @@ func (inst *instance) Search_Request(dn, filter string, name_attributes []string
res, err := inst.logging.Search(searchReq)
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
}

View File

@ -6,7 +6,11 @@ echo $BOTTIN_DEFAULT_ADMIN_PW
consul agent -dev > /dev/null 2>&1 &
sleep 2
cp test/config.json.test config.json
./bottin > /dev/null 2>&1 &
./bottin > /tmp/bottin.log 2>&1 &
sleep 1
./test/test -test.v -test.failfast -test.short -test.run TestPrincipal
./test/test -test.v -test.failfast -test.run TestPrincipal/B=
jobs
kill %2
kill %1