-
Notifications
You must be signed in to change notification settings - Fork 30
/
test_resolve_names.cpp
66 lines (59 loc) · 2.45 KB
/
test_resolve_names.cpp
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
// Copyright 2017 otris software AG
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This project is hosted at https://github.com/otris
#include "fixtures.hpp"
#include <cstring>
#include <string>
#include <vector>
#ifdef EWS_HAS_FILESYSTEM_HEADER
namespace tests
{
TEST_F(ResolveNamesTest, NoUserFound)
{
set_next_fake_response(read_file(assets_dir() / "resolve_names_error.xml"));
auto result =
service().resolve_names("name", ews::search_scope::active_directory);
EXPECT_TRUE(result.empty());
}
TEST_F(ResolveNamesTest, UserFound)
{
set_next_fake_response(
read_file(assets_dir() / "resolve_names_response.xml"));
auto response =
service().resolve_names("name", ews::search_scope::active_directory);
auto resolution_mailbox = response.resolutions[0].mailbox;
auto resolution_id = response.resolutions[0].directory_id;
auto resolution_contact = response.resolutions[0].contact;
EXPECT_EQ(resolution_mailbox.name(), "User2");
EXPECT_EQ(resolution_mailbox.value(), "[email protected]");
EXPECT_EQ(resolution_id.get_id(), "<GUID=abc-123-foo-bar>");
EXPECT_EQ(resolution_contact->get_display_name(), "User Number Two");
EXPECT_EQ(resolution_contact->get_user_smime_certificate(), "U01JTUVDZXJ0aWZpY2F0ZQ==");
EXPECT_EQ(resolution_contact->get_msexchange_certificate(), "RXhjaGFuZ2VDZXJ0aWZpY2F0ZQ==");
}
TEST_F(ResolveNamesTest, SendCorrectRequest)
{
auto response =
service().resolve_names("name", ews::search_scope::active_directory);
EXPECT_NE(get_last_request().request_string().find(
"<soap:Body>"
"<m:ResolveNames ReturnFullContactData=\"true\" "
"SearchScope=\"ActiveDirectory\" ContactDataShape=\"IdOnly\">"
"<m:UnresolvedEntry>name</m:UnresolvedEntry>"
"</m:ResolveNames>"),
std::string::npos);
}
} // namespace tests
#endif // EWS_HAS_FILESYSTEM_HEADER