From a436773a9f69182b799d88f75eb3cbe14d5d37a1 Mon Sep 17 00:00:00 2001 From: Jesper Jensen Date: Mon, 5 Oct 2026 23:28:55 +0200 Subject: Authentication works --- test_lib/transport.c | 29 +++++++++++++++++++++++++++++ test_lib/transport_test.h | 15 +++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 test_lib/transport.c create mode 100644 test_lib/transport_test.h (limited to 'test_lib') diff --git a/test_lib/transport.c b/test_lib/transport.c new file mode 100644 index 0000000..004bace --- /dev/null +++ b/test_lib/transport.c @@ -0,0 +1,29 @@ +#include "transport_test.h" +#include + +struct ExpectedRequest *nextResult = NULL; + +enum ReturnCode transport_request(char *url, enum HttpMethod method, char *token, char *reqBody, struct SizedBlock *retBody) { + assert(nextResult != NULL); + assert(strcmp(nextResult->url, url) == 0); + if(nextResult->reqBody == NULL) { + assert(nextResult->reqBody == NULL); + } else { + assert(reqBody != NULL); + assert(strcmp(nextResult->reqBody, reqBody) == 0); + } + + if(nextResult->token == NULL) { + assert(nextResult->token == NULL); + } else { + assert(token != NULL); + assert(strcmp(nextResult->token, token) == 0); + } + + + memcpy(retBody, &nextResult->retBody, sizeof(struct SizedBlock)); + + enum ReturnCode rc = nextResult->rc; + nextResult++; + return rc; +} diff --git a/test_lib/transport_test.h b/test_lib/transport_test.h new file mode 100644 index 0000000..ed6783b --- /dev/null +++ b/test_lib/transport_test.h @@ -0,0 +1,15 @@ +#pragma once + +#include "transport.h" + +struct ExpectedRequest { + bool ignore; + char *url; + char *token; + char *reqBody; + + struct SizedBlock retBody; + enum ReturnCode rc; +}; + +extern struct ExpectedRequest *nextResult; -- cgit v1.2.3