OpenVPN 3 Core Library
|
Classes | |
struct | Arbitrary< openvpn::TunBuilderCapture::Route > |
Specialization of the Arbitrary template for TunBuilderCapture::Route. More... | |
struct | Arbitrary< openvpn::TunBuilderCapture::RouteAddress > |
Specialization of the Arbitrary struct for RouteAddress. More... | |
struct | Arbitrary< openvpn::TunBuilderCapture::RouteBase > |
Specialization of Arbitrary for the RouteBase type. More... | |
struct | Arbitrary< RedirectGatewayFlagsValues > |
Template specialization for generating arbitrary RedirectGatewayFlagsValues. More... | |
struct | Arbitrary< std::variant< T, Ts... > > |
Specialization of Arbitrary for creating arbitrary std::variant values. More... | |
Typedefs | |
using | RedirectGatewayFlagsValues = openvpn::RedirectGatewayFlags::Flags |
using | RouteBased = std::variant< openvpn::TunBuilderCapture::Route, openvpn::TunBuilderCapture::RouteAddress, openvpn::TunBuilderCapture::RouteBase > |
Alias representing a route-based variant type. | |
Functions | |
template<size_t N> | |
auto | atLeastOneFalse () -> Gen< std::array< bool, N > > |
Generates an array of booleans that contains at least one false . | |
template<size_t N> | |
auto | generateValidityFlags (const bool all_valid=true) -> Gen< std::array< bool, N > > |
Generates an array of validity flags for component testing. | |
auto | IPv4Octet (const bool valid=true) -> Gen< int > |
Generates a valid or invalid IPv4 octet value. | |
auto | IPv4Address (const bool valid=true) -> Gen< std::string > |
Generates a random IPv4 address. | |
auto | asciiPrintableCode () -> Gen< int > |
Generates a random printable ASCII character code. | |
auto | hexChar (const bool valid=true) -> Gen< std::string > |
Generates a valid or invalid hexadecimal character. | |
auto | IPv6HextetValue (const bool valid=true) -> Gen< std::string > |
Generates a hextet value of an IPv6 address. | |
std::string | removeLeadingZerosFromHextet (const std::string &hextet) |
Removes leading zeros from a hextet (IPv6 segment). | |
void | removeLeadingZerosFromHextets (std::vector< std::string > &hextets) |
Removes leading zeros from a vector of hextets. | |
void | replaceSequenceOfZerosWithDoubleColon (std::vector< std::string > &hextets) |
Replaces the longest sequence of consecutive "0" strings in a vector with "::". | |
std::string | stringifyHextetsToAddressWithColons (const std::vector< std::string > &hextets) |
Converts a vector of hextets to an IPv6 address string with colons. | |
std::string | compressIPv6Address (std::vector< std::string > hextets) |
Compress an IPv6 address by simplifying its representation. | |
auto | IPv6Address (const bool valid=true) -> Gen< std::string > |
Generates a random IPv6 address. | |
auto | alpha (const bool valid=true) -> Gen< char > |
Generates alphabetic or non-alphabetic characters. | |
auto | from_allowed_chars (const std::string_view &allowed_chars, const bool valid=true) -> Gen< char > |
Generates characters based on an allowed character set. | |
auto | string_from_allowed_chars (const std::string_view &allowed_chars, const bool valid=true) -> Gen< std::string > |
Generates strings based on allowed characters. | |
auto | port (const bool valid=true) -> Gen< int > |
Generates a port number value. | |
auto | calculateIPPrefixRange (const std::string &ipAddress) -> std::tuple< int, int > |
Calculates the valid IP prefix range for a given IP address. | |
Variables | |
static const std::string | ALPHA_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" |
static const std::string | DIGITS = "1234567890" |
using rc::RedirectGatewayFlagsValues = typedef openvpn::RedirectGatewayFlags::Flags |
Definition at line 398 of file test_generators.hpp.
using rc::RouteBased = typedef std::variant<openvpn::TunBuilderCapture::Route, openvpn::TunBuilderCapture::RouteAddress, openvpn::TunBuilderCapture::RouteBase> |
Alias representing a route-based variant type.
This alias holds one of three possible route-related types: openvpn::TunBuilderCapture::Route
, openvpn::TunBuilderCapture::RouteAddress
, or openvpn::TunBuilderCapture::RouteBase
.
Definition at line 502 of file test_generators.hpp.
|
inline |
Generates alphabetic or non-alphabetic characters.
Creates a generator that produces either valid alphabetic characters (A-Z, a-z) or non-alphabetic characters, depending on the input parameter. When generating valid alphabetic characters, it selects from a predefined set of characters. For invalid characters, it uses a character generator with a predicate that ensures the character is not alphabetic.
valid | If true (default), generates valid alphabetic characters. If false , generates non-alphabetic characters. |
Definition at line 552 of file test_generators.hpp.
|
inline |
Generates a random printable ASCII character code.
This function generates an integer value representing printable ASCII character, ranging from 32 (space) to 126 (tilde) without 37 (percent sign)
Example usage:
Definition at line 155 of file test_generators.hpp.
auto rc::atLeastOneFalse | ( | ) | -> Gen<std::array<bool, N>> |
Generates an array of booleans that contains at least one false
.
This template function generates an array of booleans of size N
such that at least one of the elements in the array is false
.
N | The size of the array to be generated. |
false
.Example usage:
Definition at line 40 of file test_generators.hpp.
|
inline |
Calculates the valid IP prefix range for a given IP address.
This function takes an IPv4 address as a string and calculates the minimum and maximum valid prefix lengths. It converts the address to its integer representation and determines the smallest prefix that can correctly represent the network containing this address based on the position of the least significant '1' bit.
For example:
ipAddress | An IPv4 address in dotted decimal notation (e.g., "192.168.1.0") |
Definition at line 654 of file test_generators.hpp.
|
inline |
Compress an IPv6 address by simplifying its representation.
This function takes a list of hextets (hexadecimal segments of an IPv6 address), removes leading zeros from each hextet, replaces the largest contiguous sequence of zeroed hextets with a double colon (::), and converts the simplified hextets back into a string representation of the IPv6 address.
hextets | A vector of strings, where each string represents one hextet of an IPv6 address. |
Definition at line 321 of file test_generators.hpp.
|
inline |
Generates characters based on an allowed character set.
Creates a generator that either produces characters from a specified set of allowed characters, or characters that are specifically not in that set, depending on the valid
parameter. When valid
is true
, it generates only characters from the allowed set. When valid
is false
, it generates only characters that are not in the allowed set.
allowed_chars | A string_view containing the set of allowed characters |
valid | Boolean flag to determine whether to generate characters from the allowed set (true ) or characters not in the allowed set (false ). Defaults to true . |
allowed_chars
set Definition at line 577 of file test_generators.hpp.
auto rc::generateValidityFlags | ( | const bool | all_valid = true | ) | -> Gen<std::array<bool, N>> |
Generates an array of validity flags for component testing.
N | Number of validity flags to generate |
all_valid | If true , generates all flags as valid (true ). If false , generates flags with at least one invalid (false ) value. |
N
boolean flags. When all_valid is true
: returns array with all elements set to true
When all_valid is false
: returns array with at least one element set to false
Example usage:
Definition at line 74 of file test_generators.hpp.
|
inline |
Generates a valid or invalid hexadecimal character.
This function generates a single hexadecimal character. If valid
is true
, it generates a value within the valid ranges of 0-9
, A-F
, and a-f
. If valid
is false
, it generates a character outside of these ranges to represent an invalid hexadecimal character.
valid | A boolean flag indicating whether to generate a valid or invalid hexadecimal character. Default is true . |
Example usage:
Definition at line 181 of file test_generators.hpp.
|
inline |
Generates a random IPv4 address.
This function generates a random IPv4 address. The validity of the octets can be controlled by the valid
parameter. If valid
is true
, all four octets will be valid. Otherwise, at least one octet will be invalid. The resulting IPv4 address is formatted as X.X.X.X
where X
is a number between 0 and 255 (or an invalid value if valid
is false
).
valid | A boolean flag indicating whether the generated address should be valid. Defaults to true . |
Example usage:
Definition at line 125 of file test_generators.hpp.
|
inline |
Generates a valid or invalid IPv4 octet value.
This function generates a value that represents an IPv4 octet. If valid
is true
, it generates a value within the valid range of 0 to 255. If valid
is false
, it generates values outside this range to represent an invalid octet.
valid | A boolean flag indicating whether to generate a valid or invalid octet value. Default is true . |
Example usage:
Definition at line 96 of file test_generators.hpp.
|
inline |
Generates a random IPv6 address.
This function generates a random IPv6 address. The validity of the hextets can be controlled by the valid
parameter. If valid
is true
, all eight hextets will be valid. Otherwise, at least one hextet will be invalid. The resulting IPv6 address is formatted as X:X:X:X:X:X:X:X
where X
is a hextet (4 hex chars) within the valid ranges of 0-9
, A-F
, and a-f
.
This function generates either a valid or an invalid IPv6 address.
valid | A boolean flag indicating whether the generated IPv6 address should be valid. Defaults to true . |
Example usage:
Definition at line 345 of file test_generators.hpp.
|
inline |
Generates a hextet value of an IPv6 address.
This function generates a hextet (4 characters) value of an IPv6 address, which may consist of valid or invalid hexadecimal characters based on the valid
parameter.
valid | A boolean indicating whether the generated hextet should only contain valid hexadecimal characters. If set to true , all characters will be valid. If set to false , at least one character will be invalid. Default is true . |
Example usage:
Definition at line 222 of file test_generators.hpp.
|
inline |
Generates a port number value.
Creates a generator that produces either valid or invalid port numbers. If valid
is true
, generates numbers in the valid port range [0, 65535]. If valid
is false
, generates numbers outside the valid port range.
valid | Boolean flag to determine if valid (true ) or invalid (false ) port numbers should be generated. Defaults to true . |
valid
parameter. Definition at line 626 of file test_generators.hpp.
|
inline |
Removes leading zeros from a hextet (IPv6 segment).
This function trims all leading zeros from a given hextet string. If the hextet only contains zeros (or is empty), it returns "0".
hextet | The input string representing a hextet (e.g., "0001", "0ABC"). |
Definition at line 247 of file test_generators.hpp.
|
inline |
Removes leading zeros from a vector of hextets.
This function modifies a vector of IPv6 hextets by removing leading zeros from each hextet using the removeLeadingZerosFromHextet
transformation. The operation is performed in-place.
hextets | A reference to a vector of strings representing IPv6 hextets. Each hextet will be stripped of its leading zeros. |
Definition at line 261 of file test_generators.hpp.
|
inline |
Replaces the longest sequence of consecutive "0" strings in a vector with "::".
This function finds the longest contiguous sequence of "0" strings in the provided hextets
vector, replaces it with a single "::", and removes the other "0" strings in the sequence. If there are multiple sequences of the same length, it acts on the first one found.
hextets | A vector of strings representing the hextets (subdivisions) of an IPv6 address. |
Definition at line 274 of file test_generators.hpp.
|
inline |
Generates strings based on allowed characters.
Creates a generator that produces strings either containing only allowed characters or containing at least one character not in the allowed set. When valid
is true
, it generates strings using only allowed characters. When valid
is false
, it generates strings that contain at least one character not present in allowed_chars
.
allowed_chars | A string_view containing the set of allowed characters |
valid | Boolean flag to control generation mode:
|
std::string
values according to the specified constraints Definition at line 605 of file test_generators.hpp.
|
inline |
Converts a vector of hextets to an IPv6 address string with colons.
This function takes a vector of strings representing hextets (parts of an IPv6 address) and constructs a colon-separated IPv6 address. The function ensures that colons are correctly placed between the hextets, and it avoids adding redundant colons around "::" which represents a compressed sequence of zeroes in an IPv6 address.
hextets | A vector of strings, where each string represents a hextet or "::". |
Definition at line 298 of file test_generators.hpp.
|
static |
Definition at line 534 of file test_generators.hpp.
|
static |
Definition at line 535 of file test_generators.hpp.