summaryrefslogtreecommitdiffstats
path: root/ydb/library/testlib/service_mocks/ldap_mock/ldap_defines.cpp
blob: 06170b7a1c1bbfeefd3f964c53cfdbfc88b59626 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "ldap_defines.h"

namespace LdapMock {

TBindRequestInfo::TBindRequestInfo(const TString& login, const TString& password)
    : Login(login)
    , Password(password)
{}

TBindRequestInfo::TBindRequestInfo(const TInitializeList& list)
    : TBindRequestInfo(list.Login, list.Password)
{}

bool TBindRequestInfo::operator==(const TBindRequestInfo& otherRequest) const {
    return (this->Login == otherRequest.Login && this->Password == otherRequest.Password);
}

TSearchRequestInfo::TSearchRequestInfo(const TString& baseDn,
                       size_t scope,
                       size_t derefAliases,
                       bool typesOnly,
                       const TSearchFilter& filter,
                       const std::vector<TString>& attributes)
    : BaseDn(baseDn)
    , Scope(scope)
    , DerefAliases(derefAliases)
    , TypesOnly(typesOnly)
    , Filter(filter)
    , Attributes(attributes)
{}

TSearchRequestInfo::TSearchRequestInfo(const TInitializeList& list)
    : TSearchRequestInfo(list.BaseDn,
                         list.Scope,
                         list.DerefAliases,
                         list.TypesOnly,
                         list.Filter,
                         list.Attributes)
{}

bool TSearchRequestInfo::operator==(const TSearchRequestInfo& otherRequest) const {
    if (this->BaseDn != otherRequest.BaseDn) {
        return false;
    }
    if (this->Scope != otherRequest.Scope) {
        return false;
    }
    if (this->DerefAliases != otherRequest.DerefAliases) {
        return false;
    }
    if (this->TypesOnly != otherRequest.TypesOnly) {
        return false;
    }
    const auto& filter = this->Filter;
    const auto& expectedFilter = otherRequest.Filter;
    if (filter.Type != expectedFilter.Type) {
        return false;
    }
    if (filter.Attribute != expectedFilter.Attribute) {
        return false;
    }
    if (filter.Value != expectedFilter.Value) {
        return false;
    }
    if (this->Attributes != otherRequest.Attributes) {
        return false;
    }
    return true;
}

}