|
OpenVPN 3 Core Library
|
Namespaces | |
| namespace | helpers |
Classes | |
| struct | Arbitrary< openvpn::IP::Addr::Version > |
| V4 or V6, the versions an address string can carry. More... | |
| struct | Arbitrary< openvpn::IP::AddrMaskPair > |
| 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. | |
| auto | genDnsDomain (const bool valid=true) -> Gen< openvpn::DnsDomain > |
| Generates a DnsDomain. | |
| auto | genDnsAddress (const bool valid=true) -> Gen< openvpn::DnsAddress > |
| Generates a DNS address. | |
| auto | genDnsAddressAsStr (const bool valid=true) -> Gen< std::string > |
| Generates a DNS address as a string. | |
| auto | genDnsServer () -> Gen< openvpn::DnsServer > |
| Generates a DNS server. | |
| auto | genDNSOptions () -> Gen< openvpn::DnsOptions > |
| Generates random DNS options. | |
| auto | genIPAddressString (const openvpn::IP::Addr::Version version, const bool valid=true) -> Gen< std::string > |
Generates an address string of version; valid is IPv4Address()/IPv6Address()'s. | |
| auto | genIPAddr (const openvpn::IP::Addr::Version version) -> Gen< openvpn::IP::Addr > |
| auto | genIPAddr () -> Gen< openvpn::IP::Addr > |
| auto | genPrefixLength (const openvpn::IP::Addr::Version version, const bool valid=true) -> Gen< unsigned int > |
Generates a prefix length for an address of version. | |
| auto | genAddrMaskPair (const openvpn::IP::Addr::Version version) -> Gen< openvpn::IP::AddrMaskPair > |
Generates a well-formed AddrMaskPair of version: an address and a contiguous netmask. | |
| auto | genNonCanonicalAddrMaskPair (const openvpn::IP::Addr::Version version) -> Gen< openvpn::IP::AddrMaskPair > |
Generates a pair of version whose address has a host bit set, so is_canonical() is false. | |
| auto | genNetmaskString (const openvpn::IP::Addr::Version version, const bool valid=true) -> Gen< std::string > |
Generates a netmask of version rendered as an address string. | |
| auto | genMaskToken (const openvpn::IP::Addr::Version version, const bool valid=true) -> Gen< std::string > |
Generates the netmask term of an AddrMaskPair input for an address of version. | |
| auto | genAddrMaskPairString (const openvpn::IP::Addr::Version version, const bool valid=true) -> Gen< std::string > |
Generates an AddrMaskPair::from_string input for an address of version. | |
Variables | |
| static const std::string | ALPHA_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| static const std::string | DIGITS = "1234567890" |
| using rc::RedirectGatewayFlagsValues = typedef openvpn::RedirectGatewayFlags::Flags |
Definition at line 402 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 506 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 556 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 159 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 44 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 658 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 325 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 581 of file test_generators.hpp.
|
inline |
Generates a well-formed AddrMaskPair of version: an address and a contiguous netmask.
Only valid pairs are drawn, so AddrMaskPair::operator<< can render a counterexample; a pair with a mismatched or non-contiguous netmask would throw from to_string() on the failure path.
Definition at line 1052 of file test_generators.hpp.
|
inline |
Generates an AddrMaskPair::from_string input for an address of version.
valid true selects a bare address or an address with an accepted mask term. valid false selects a malformed address, an address with a rejected mask term, three terms, the empty string or an alphabetic token.
Definition at line 1153 of file test_generators.hpp.
|
inline |
Generates a DNS address.
Creates a generator that produces instances of the openvpn::DnsAddress class. The generator can create either valid or invalid DNS addresses based on the provided parameter. It combines an IP address (either IPv4 or IPv6) with an optional port number. The port is randomly included or excluded, and its value is not validated during DnsAddress validation.
| valid | A boolean flag indicating whether to generate a valid (true ) or invalid (false ) DNS address. Defaults to true. |
openvpn::DnsAddress objects with either valid or invalid address values.Example usage:
Definition at line 855 of file test_generators.hpp.
|
inline |
Generates a DNS address as a string.
This function creates a generator that produces instances of the openvpn::DnsAddress class, where the address is represented as a string. The generator can create either valid or invalid DNS addresses based on the provided parameter. It combines an IP address (either IPv4 or IPv6) with an optional port number. The port is randomly included or excluded.
| valid | Flag indicating the address should be constrained to valid values. |
Definition at line 884 of file test_generators.hpp.
|
inline |
Generates a DnsDomain.
Creates a generator that produces instances of the openvpn::DnsDomain class. The generator can create either valid or invalid DNS domain names based on the provided parameter. It uses the helpers::genHost function to generate appropriate domain strings.
| valid | A boolean flag indicating whether to generate valid (true ) or invalid (false ) domain names. Defaults to true. |
openvpn::DnsDomain objects with either valid or invalid domain values.Example usage:
Definition at line 826 of file test_generators.hpp.
|
inline |
Generates random DNS options.
This function creates a generator for openvpn::DnsOptions objects with randomized values. It generates random DNS servers with priorities, search domains, and a boolean flag indicating whether the options should be derived from DHCP options.
The generator uses helper functions to create components of the DnsOptions structure including
from_dhcp_options flagDnsDomain objects for search domainsopenvpn::DnsOptions. Definition at line 948 of file test_generators.hpp.
|
inline |
Generates a DNS server.
Creates a generator that produces random openvpn::DnsServer instances with populated fields. The generator creates:
genDnsAddress )genDnsDomain )helpers::genDnsServerSecurity )helpers::genDnsServerTransport )The vector sizes for addresses and domains are limited to a maximum of 100 elements.
openvpn::DnsServer instances. Definition at line 917 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 78 of file test_generators.hpp.
|
inline |
|
inline |
Definition at line 1007 of file test_generators.hpp.
|
inline |
Generates an address string of version; valid is IPv4Address()/IPv6Address()'s.
Definition at line 998 of file test_generators.hpp.
|
inline |
Generates the netmask term of an AddrMaskPair input for an address of version.
The valid set is a legal prefix length, a contiguous netmask of version, and the empty token, which AddrMaskPair::from_string reads as an all-ones netmask. With valid false the token is one from_string rejects for an address of version: a prefix length above the address size, a non-contiguous netmask, or a netmask of the other version.
Definition at line 1126 of file test_generators.hpp.
|
inline |
Generates a netmask of version rendered as an address string.
valid selects a contiguous mask, which openvpn::IP::Addr::prefix_len() converts back to a prefix length, over a mask with one interior zero bit, which it rejects as malformed.
Definition at line 1105 of file test_generators.hpp.
|
inline |
Generates a pair of version whose address has a host bit set, so is_canonical() is false.
The prefix length stays below the address size so that a host bit exists to set.
Definition at line 1081 of file test_generators.hpp.
|
inline |
Generates a prefix length for an address of version.
valid selects [0, address size], the range openvpn::IP::Addr::netmask_from_prefix_len accepts, over values above it, with the bounds over-represented in the valid form. The invalid range stops below 2^32: above that openvpn::parse_number wraps the value modulo its destination type before any range guard sees it and AddrMaskPair::from_string accepts the input, so a wider bound admits "invalid" prefix lengths that parse.
Definition at line 1030 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 185 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 129 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 100 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 349 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 226 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 630 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 251 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 265 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 278 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 609 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 302 of file test_generators.hpp.
|
static |
Definition at line 538 of file test_generators.hpp.
|
static |
Definition at line 539 of file test_generators.hpp.