OpenTTD Source: src/tests/test_network_crypto.cpp File Reference

OpenTTD Source 15.3

Data Structures | Functions | Variables
test_network_crypto.cpp File Reference

Tests for network related crypto functions. More...

`#include "../stdafx.h"`
`#include "../3rdparty/catch2/catch.hpp"`
`#include "../core/format.hpp"`
`#include "../network/network_crypto_internal.h"`
`#include "../network/core/packet.h"`
`#include "../string_func.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Data Structures
class | MockNetworkSocketHandler
class | TestPasswordRequestHandler

## Functions
static std::tuple< Packet, bool > | CreatePacketForReading (Packet &source, MockNetworkSocketHandler *socket_handler)
static void | TestAuthentication (NetworkAuthenticationServerHandler &server, NetworkAuthenticationClientHandler &client, NetworkAuthenticationServerHandler::ResponseResult expected_response_result, NetworkAuthenticationClientHandler::RequestResult expected_request_result)
| TEST_CASE ("Authentication_KeyExchangeOnly")
static void | TestAuthenticationPAKE (std::string server_password, std::string client_password, NetworkAuthenticationServerHandler::ResponseResult expected_response_result)
| TEST_CASE ("Authentication_PAKE")
static void | TestAuthenticationAuthorizedKey (const X25519SecretKey &client_secret_key, const X25519PublicKey &server_expected_public_key, NetworkAuthenticationServerHandler::ResponseResult expected_response_result)
| TEST_CASE ("Authentication_AuthorizedKey")
| TEST_CASE ("Authentication_Combined")
static void | CheckEncryption (MockNetworkSocketHandler *sending_socket_handler, MockNetworkSocketHandler *receiving_socket_handler)
| TEST_CASE ("Encryption handling")

## Variables
static MockNetworkSocketHandler | mock_socket_handler

## Detailed Description

Tests for network related crypto functions.

Definition in file test_network_crypto.cpp.

## Function Documentation

## ◆ CheckEncryption()

static void CheckEncryption | ( | MockNetworkSocketHandler * | sending_socket_handler,
|  | MockNetworkSocketHandler * | receiving_socket_handler
| ) |  |
| static

Definition at line 217 of file test_network_crypto.cpp.

## ◆ CreatePacketForReading()

static std::tuple< Packet, bool > CreatePacketForReading | ( | Packet & | source,
|  | MockNetworkSocketHandler * | socket_handler
| ) |  |
| static

Definition at line 36 of file test_network_crypto.cpp.

## ◆ TEST_CASE() [1/5]

TEST_CASE | ( | "Authentication_AuthorizedKey" |  | ) |

Definition at line 134 of file test_network_crypto.cpp.

## ◆ TEST_CASE() [2/5]

TEST_CASE | ( | "Authentication_Combined" |  | ) |

Definition at line 150 of file test_network_crypto.cpp.

## ◆ TEST_CASE() [3/5]

TEST_CASE | ( | "Authentication_KeyExchangeOnly" |  | ) |

Definition at line 86 of file test_network_crypto.cpp.

## ◆ TEST_CASE() [4/5]

TEST_CASE | ( | "Authentication_PAKE" |  | ) |

Definition at line 105 of file test_network_crypto.cpp.

## ◆ TEST_CASE() [5/5]

TEST_CASE | ( | "Encryption handling" |  | ) |

Definition at line 248 of file test_network_crypto.cpp.

## ◆ TestAuthentication()

static void TestAuthentication | ( | NetworkAuthenticationServerHandler & | server,
|  | NetworkAuthenticationClientHandler & | client,
|  | NetworkAuthenticationServerHandler::ResponseResult | expected_response_result,
|  | NetworkAuthenticationClientHandler::RequestResult | expected_request_result
| ) |  |
| static

Definition at line 65 of file test_network_crypto.cpp.

## ◆ TestAuthenticationAuthorizedKey()

static void TestAuthenticationAuthorizedKey | ( | const X25519SecretKey & | client_secret_key,
|  | const X25519PublicKey & | server_expected_public_key,
|  | NetworkAuthenticationServerHandler::ResponseResult | expected_response_result
| ) |  |
| static

Definition at line 121 of file test_network_crypto.cpp.

## ◆ TestAuthenticationPAKE()

static void TestAuthenticationPAKE | ( | std::string | server_password,
|  | std::string | client_password,
|  | NetworkAuthenticationServerHandler::ResponseResult | expected_response_result
| ) |  |
| static

Definition at line 95 of file test_network_crypto.cpp.

## Variable Documentation

## ◆ mock_socket_handler

MockNetworkSocketHandler mock_socket_handler
| static

Definition at line 34 of file test_network_crypto.cpp.