diff options
| author | Steffen Ernst <steffen.ernst@mullvad.net> | 2025-02-26 14:25:47 +0100 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2025-04-22 11:57:25 +0200 |
| commit | 5616f687e685cf430f2fe6a97a851f5d2b0c6874 (patch) | |
| tree | d8bb1ec8700a564fd1296cf3ac0a09131c42d70d /ios/MullvadRustRuntime/include | |
| parent | 1e4b35f1dd7386a710b6b5bf9b2543fdeaa9c0e6 (diff) | |
| download | mullvadvpn-5616f687e685cf430f2fe6a97a851f5d2b0c6874.tar.xz mullvadvpn-5616f687e685cf430f2fe6a97a851f5d2b0c6874.zip | |
Add test for mullvad api
Diffstat (limited to 'ios/MullvadRustRuntime/include')
| -rw-r--r-- | ios/MullvadRustRuntime/include/mullvad_rust_runtime.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h b/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h index 36774f2d4e..4de4a02b37 100644 --- a/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h +++ b/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h @@ -56,6 +56,12 @@ typedef struct CompletionCookie { void *inner; } CompletionCookie; +typedef struct SwiftServerMock { + const void *server_ptr; + const void *mock_ptr; + uint16_t port; +} SwiftServerMock; + typedef struct ProblemReportMetadata { struct Map *inner; } ProblemReportMetadata; @@ -108,6 +114,23 @@ extern const uint16_t CONFIG_SERVICE_PORT; * * This function is safe. */ +struct SwiftApiContext mullvad_api_init_new_tls_disabled(const uint8_t *host, + const uint8_t *address); + +/** + * # Safety + * + * `host` must be a pointer to a null terminated string representing a hostname for Mullvad API host. + * This hostname will be used for TLS validation but not used for domain name resolution. + * + * `address` must be a pointer to a null terminated string representing a socket address through which + * the Mullvad API can be reached directly. + * + * If a context cannot be constructed this function will panic since the call site would not be able + * to proceed in a meaningful way anyway. + * + * This function is safe. + */ struct SwiftApiContext mullvad_api_init_new(const uint8_t *host, const uint8_t *address); @@ -238,6 +261,49 @@ extern void mullvad_api_completion_finish(struct SwiftMullvadApiResponse respons struct CompletionCookie completion_cookie); /** + * # Safety + * + * `method` must be a pointer to a null terminated string representing the http method. + * + * `path` must be a pointer to a null terminated string representing the url path. + * + * `response_code` must be a usize representing the http response code. + * + * `response_body` must be a pointer to a null terminated string representing the body. + * + * This function is safe. + */ +struct SwiftServerMock mullvad_api_mock_get(const char *path, + uintptr_t response_code, + const uint8_t *response_body); + +/** + * # Safety + * + * `path` must be a pointer to a null terminated string representing the url path. + * + * `response_code` must be a usize representing the http response code. + * + * `match_body` must be a pointer to a null terminated json string representing the body the server expects. + * + * This function is safe. + */ +struct SwiftServerMock mullvad_api_mock_post(const char *path, + uintptr_t response_code, + const char *match_body); + +/** + * Called by the Swift side to signal that the Rust `SwiftServerMock` can be safely + * dropped from memory. + * + * # Safety + * + * `mock_ptr` must be pointing to a valid instance of `SwiftServerMock`. This function + * is not safe to call multiple times with the same `SwiftServerMock`. + */ +void mullvad_api_mock_drop(struct SwiftServerMock mock_ptr); + +/** * Send a problem report via the Mullvad API client. * * # Safety |
