diff options
Diffstat (limited to 'test.c')
-rw-r--r-- | test.c | 39 |
1 files changed, 38 insertions, 1 deletions
@@ -1,7 +1,9 @@ #include <stdio.h> +#include <string.h> #include "browse.h" #include "http.h" +#include "upload.h" /* minunit, see https://jera.com/techinfo/jtns/jtn002 */ #define mu_assert(message, test) do { if (!(test)) return message; } while (0) @@ -27,7 +29,6 @@ test_browse_invalid_traversal() /* ...should return an error */ mu_assert("error, browse allowed invalid traversal!", ret.code >= KHTTP_400); - return 0; } @@ -47,7 +48,42 @@ test_browse_path_too_long() mu_assert("error, browse allowed invalid traversal!", ret.code >= KHTTP_400); + return 0; +} + +static char * +test_upload_post() +{ + char *file_content; + struct kreq r; + struct http_ret ret; + struct kpair fields[2]; + + file_content = "text file"; + + fields[0] = (struct kpair) { + .key = "file", + .file = "bob.txt", + .val = file_content, + .valsz = strlen(file_content) + }; + fields[1] = (struct kpair) { + .key = "file", + .file = "alice.txt", + .val = file_content, + .valsz = strlen(file_content) + }; + + r = (struct kreq) { + .pname = "/vault", + .path = "", + .method = KMETHOD_POST, + .fieldsz = 2, + .fields = fields + }; + ret = upload(&r); + mu_assert("error, POST upload failed!", ret.code <= KHTTP_400); return 0; } @@ -56,6 +92,7 @@ all_tests() { mu_run_test(test_browse_invalid_traversal); mu_run_test(test_browse_path_too_long); + mu_run_test(test_upload_post); return 0; } |