diff options
author | MrArmonius <mrarmonius@gmail.com> | 2021-07-16 16:56:56 +0200 |
---|---|---|
committer | MrArmonius <mrarmonius@gmail.com> | 2021-07-19 18:57:40 +0200 |
commit | 9a8c19ec0f9b2f09daab244a49c67904c5c086aa (patch) | |
tree | f30c61228022493823ca812b292fee2285b2d233 /test/request.go | |
parent | da627ac39ad437bfb6be7e5f343933a0ca4e5073 (diff) | |
download | bottin-9a8c19ec0f9b2f09daab244a49c67904c5c086aa.tar.gz bottin-9a8c19ec0f9b2f09daab244a49c67904c5c086aa.zip |
Bottin's Test V2.0 with Framework Testing
V2 the test end-to-end,
Tests made similar to V1.0,
Add the possibility to pararellize the tests,
Create an environnement for easy integration of news test,
Diffstat (limited to 'test/request.go')
-rw-r--r-- | test/request.go | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/test/request.go b/test/request.go new file mode 100644 index 0000000..b693211 --- /dev/null +++ b/test/request.go @@ -0,0 +1,67 @@ +package main + +import ( + ldap "github.com/go-ldap/ldap/v3" +) + +func (inst *instance) Add_Request(dn string, attributes map[string][]string) error { + //Create the AddRequest + req := ldap.NewAddRequest(dn, nil) + for key, value := range attributes { + req.Attribute(key, value) + } + + //Send the request + err := inst.logging.Add(req) + //@FIXME: Remove when you try to correct the bug MessageID + inst.Reconnect() + return err + +} + +//Use enum to select Replace,Delete,Modify +func (inst *instance) Modify_Request(dn string, add_attributes, delete_attributes, replace_attributes map[string][]string) error { + modifyReq := ldap.NewModifyRequest(dn, nil) + + for key, value := range add_attributes { + modifyReq.Add(key, value) + } + + for key, value := range delete_attributes { + modifyReq.Delete(key, value) + } + + for key, value := range replace_attributes { + modifyReq.Replace(key, value) + } + + err := inst.logging.Modify(modifyReq) + //@FIXME: Remove when you try to correct the bug MessageID + inst.Reconnect() + return err +} + +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 +} + +func (inst *instance) Search_Request(dn, filter string, name_attributes []string) (*ldap.SearchResult, error) { + searchReq := ldap.NewSearchRequest( + dn, + ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, + filter, + name_attributes, + nil, + ) + + 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 +} |