Commit summary:
[platform/core/security/suspicious-activity-monitor.git] / utest / test_rest.cpp
1 /**
2  * Samsung Ukraine R&D Center (SRK under a contract between)
3  * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
4  * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License
17  */
18 #include <gtest/gtest.h>
19 #include "rest_request.h"
20 #include "restservice.h"
21 #include <stdexcept>
22 #include <thread>
23 #include <chrono>
24 #include <cctype>
25 #include <algorithm>
26
27 using namespace communication;
28
29 #define TAG "Tests"
30
31 /**
32  * Test checks device discovery use case
33  * 1. Search for unowned devices
34  * 2. Try API for device lists
35  * 3. Search for owned devices
36  * 4. Iterate thoughout the list and print devices info
37  */
38 TEST(Test_REST, DISABLED_test_get)
39 {
40     try {
41         RestRequest request("http://106.125.46.139:11000/swagger-ui.html#/rest-device");
42         std::string response;
43         RestRequest::QueryParameters params = {{"user", "anon"}, {"id", "3"}};
44         request.addHeader("TestRestHeader", "some text");
45         RestRequest::Result result = request.get(params, "/", response);
46         ASSERT_EQ(RestRequest::HTTP_OK, result);
47         EXPECT_FALSE(response.empty());
48         EXPECT_EQ(response, request.body());
49     } catch (std::exception& e) {
50         FAIL() << "Exception: " << e.what();
51     }
52 }