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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// Copyright (C) 2016-2023 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 <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

using namespace std;

namespace isc {
namespace db {
namespace test {

// Connection strings.
// Database: keatest
// Host: localhost
// Username: keatest
// Password: keatest

const char* INVALID_TYPE = "type=unknown";
const char* VALID_NAME = "name=keatest";
const char* INVALID_NAME = "name=invalidname";
const char* VALID_HOST = "host=localhost";
const char* VALID_HOST_TCP = "host=127.0.0.1";
const char* INVALID_HOST = "host=invalidhost";
const char* INVALID_PORT_1 = "port=65536";
const char* VALID_USER = "user=keatest";
const char* VALID_READONLY_USER = "user=keatest_readonly";
const char* VALID_SECURE_USER = "user=keatest_secure";
const char* INVALID_USER = "user=invaliduser";
const char* VALID_PASSWORD = "password=keatest";
const char* INVALID_PASSWORD = "password=invalid";
const char* VALID_TIMEOUT = "connect-timeout=10";
const char* INVALID_TIMEOUT_1 = "connect-timeout=foo";
const char* INVALID_TIMEOUT_2 = "connect-timeout=-17";
const char* INVALID_TIMEOUT_3 = "connect-timeout=0";
const char* VALID_READ_TIMEOUT = "read-timeout=11";
const char* VALID_READ_TIMEOUT_ZERO = "read-timeout=0";
const char* INVALID_READ_TIMEOUT_1 = "read-timeout=bar";
const char* VALID_WRITE_TIMEOUT = "write-timeout=12";
const char* VALID_WRITE_TIMEOUT_ZERO = "write-timeout=0";
const char* INVALID_WRITE_TIMEOUT_1 = "write-timeout=baz";
const char* VALID_TCP_USER_TIMEOUT = "tcp-user-timeout=8";
const char* VALID_TCP_USER_TIMEOUT_ZERO = "tcp-user-timeout=0";
const char* INVALID_TCP_USER_TIMEOUT_1 = "-7";
const char* VALID_READONLY_DB = "readonly=true";
const char* INVALID_READONLY_DB = "readonly=5";
const char* VALID_CERT = "cert-file=" TEST_CA_DIR "/kea-client.crt";<--- There is an unknown macro here somewhere. Configuration is required. If TEST_CA_DIR is a macro then please configure it.
const char* VALID_KEY = "key-file=" TEST_CA_DIR "/kea-client.key";
const char* INVALID_KEY = "key-file=" TEST_CA_DIR "/kea-other.key";
const char* VALID_CA = "trust-anchor=" TEST_CA_DIR "/kea-ca.crt";
const char* VALID_CIPHER = "cipher-list=AES";

string connectionString(const char* type, const char* name, const char* host,
                        const char* user, const char* password,
                        const char* timeout, const char* readonly_db,
                        const char* cert_file, const char* key_file,
                        const char* trust_anchor, const char* cipher) {
    const string space = " ";
    string result = "";

    if (type) {
        result += string(type);
    }

    if (name) {
        if (! result.empty()) {
            result += space;
        }
        result += string(name);
    }

    if (host) {
        if (! result.empty()) {
            result += space;
        }
        result += string(host);
    }

    if (user) {
        if (! result.empty()) {
            result += space;
        }
        result += string(user);
    }

    if (password) {
        if (! result.empty()) {
            result += space;
        }
        result += string(password);
    }

    if (timeout) {
        if (! result.empty()) {
            result += space;
        }
        result += string(timeout);
    }

    if (readonly_db) {
        if (! result.empty()) {
            result += space;
        }
        result += string(readonly_db);
    }

    if (cert_file) {
        if (! result.empty()) {
            result += space;
        }
        result += string(cert_file);
    }

    if (key_file) {
        if (! result.empty()) {
            result += space;
        }
        result += string(key_file);
    }

    if (trust_anchor) {
        if (! result.empty()) {
            result += space;
        }
        result += string(trust_anchor);
    }

    if (cipher) {
        if (! result.empty()) {
            result += space;
        }
        result += string(cipher);
    }

    return (result);
}

bool
softWipeEnabled() {
    const char* const wipe_only = getenv("KEA_TEST_DB_WIPE_DATA_ONLY");
    if (wipe_only && (std::string(wipe_only) == std::string("false"))) {
        return (false);
    }

    return (true);
}

}
}
}