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
// Copyright (C) 2021-2022 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Kea Hooks Basic
// Commercial End User License Agreement v2.0. See COPYING file in the premium/
// directory.

#include <config.h>

#include <dns/name.h>
#include <gss_tsig_key.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <gss_tsig_api_utils.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <testutils/gtest_utils.h>
#include <gtest/gtest.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

using namespace std;
using namespace std::chrono;
using namespace isc;
using namespace isc::cryptolink;
using namespace isc::dns;
using namespace isc::gss_tsig;
using namespace isc::gss_tsig::test;

namespace {

/// @brief Test fixture for testing the GSS-TSIG key.
class GssTsigKeyTest : public GssApiBaseTest {
public:
    /// @brief Constructor.
    GssTsigKeyTest() : GssApiBaseTest() {
    }
};

/// @brief Check the constructor builds what is expected.
TEST_F(GssTsigKeyTest, basic) {<--- syntax error
    GssTsigKeyPtr key;
    string name = "1234.sig-foo.example.com.";
    ASSERT_NO_THROW(key.reset(new GssTsigKey(name)));
    ASSERT_TRUE(key);
    EXPECT_EQ(Name(name), key->getKeyName());
    EXPECT_EQ(name, key->getKeyName().toText());
    EXPECT_EQ(Name("gss-tsig."), key->getAlgorithmName());
    EXPECT_EQ(TSIGKey::GSSTSIG_NAME(), key->getAlgorithmName());
    EXPECT_EQ(UNKNOWN_HASH, key->getAlgorithm());
    EXPECT_EQ(0, key->getDigestbits());
    EXPECT_EQ(0, key->getSecretLength());
    EXPECT_FALSE(key->getSecret());
    string expected = name + "::gss-tsig.";
    EXPECT_EQ(expected, key->toText());
    EXPECT_FALSE(key->getSecCtx().get());
    system_clock::time_point epoch;
    system_clock::time_point now = system_clock::now();
    uint32_t now32 = static_cast<uint32_t>(system_clock::to_time_t(now));
    EXPECT_EQ(epoch, key->getInception());
    EXPECT_EQ(0, key->getInception32());
    EXPECT_EQ(epoch, key->getExpire());
    EXPECT_EQ(0, key->getExpire32());
    EXPECT_NO_THROW(key->setInception(now));
    EXPECT_EQ(now, key->getInception());
    EXPECT_EQ(now32, key->getInception32());
    std::chrono::hours day(24);
    system_clock::time_point tomorrow = now + day;
    uint32_t tomorrow32 = static_cast<uint32_t>(system_clock::to_time_t(tomorrow));
    EXPECT_NO_THROW(key->setExpire(tomorrow));
    EXPECT_EQ(tomorrow, key->getExpire());
    EXPECT_EQ(tomorrow32, key->getExpire32());
}

}