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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105 | // Copyright (C) 2017-2022 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
#include <exceptions/exceptions.h>
#include <hooks/hooks_manager.h>
#include <config/command_mgr.h>
#include <dhcpsrv/lease_mgr.h>
#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcpsrv/ncr_generator.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/resource_handler.h>
#include <cc/command_interpreter.h>
#include <cc/data.h>
#include <lease_cmds_unittest.h><--- Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <stats/stats_mgr.h>
#include <testutils/user_context_utils.h>
#include <testutils/multi_threading_utils.h>
#include <gtest/gtest.h><--- Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <errno.h><--- Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <set><--- Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results.
using namespace std;
using namespace isc;
using namespace isc::hooks;
using namespace isc::config;
using namespace isc::data;
using namespace isc::dhcp;
using namespace isc::dhcp_ddns;
using namespace isc::asiolink;
using namespace isc::stats;
using namespace isc::test;
namespace {
// Simple test that checks the library really registers the commands.
TEST_F(LeaseCmdsTest, commands) {
vector<string> cmds = {
"lease4-add", "lease6-add",
"lease4-get", "lease6-get",
"lease4-get-all", "lease6-get-all",
"lease4-get-page", "lease6-get-page",
"lease4-get-by-hw-address",
"lease4-get-by-client-id", "lease6-get-by-duid",
"lease4-get-by-hostname", "lease6-get-by-hostname",
"lease4-del", "lease6-del",
"lease4-update", "lease6-update",
"lease4-wipe", "lease6-wipe",
"lease4-resend-ddns", "lease6-resend-ddns"
};
setFamily(AF_INET);
testCommands(cmds);
}
void LeaseCmdsTest::testLeaseXDelBadUpdateDdnsParam() {
string cmd =
"{\n"
" \"command\": \"lease4-del\",\n"
" \"arguments\": {"
" \"ip-address\": \"192.0.1.0\","
" \"update-ddns\": 77"
" }\n"
"}";
string exp_rsp = "'update-ddns' is not a boolean";
testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp);
cmd =
"{\n"
" \"command\": \"lease6-del\",\n"
" \"arguments\": {"
" \"ip-address\": \"2001:db8:1::1\","
" \"update-ddns\": \"bogus\""
" }\n"
"}";
exp_rsp = "'update-ddns' is not a boolean";
testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp);
}
// Check that the library can be loaded and unloaded multiple times.
TEST_F(LeaseCmdsTest, multipleLoads) {<--- syntax error
setFamily(AF_INET);
testMultipleLoads();
}
TEST_F(LeaseCmdsTest, leaseXDelBadUpdateDdnsParam) {
setFamily(AF_INET);
testLeaseXDelBadUpdateDdnsParam();
}
TEST_F(LeaseCmdsTest, leaseXDelBadUpdateDdnsParamMultiThreading) {
MultiThreadingTest mt(true);
setFamily(AF_INET);
testLeaseXDelBadUpdateDdnsParam();
}
} // end of anonymous namespace
|