diff options
author | Matt Burke <spraints@gmail.com> | 2015-09-10 20:18:26 +0300 |
---|---|---|
committer | Matt Burke <spraints@gmail.com> | 2015-09-10 20:18:26 +0300 |
commit | 3245896bb7527cb42d48faf68f33858c887f2b3d (patch) | |
tree | d951c8378890a3441d46e9f5d7456d3be8d79cc9 /tests/online | |
parent | 66d90e7098ee2da76ff3351a305a17a38fb9282b (diff) |
Add a test for custom header validation
Also, *some* custom headers actually are valid.
Diffstat (limited to 'tests/online')
-rw-r--r-- | tests/online/clone.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/online/clone.c b/tests/online/clone.c index 225b3abe2..b84be405c 100644 --- a/tests/online/clone.c +++ b/tests/online/clone.c @@ -213,6 +213,33 @@ void test_online_clone__custom_remote_callbacks(void) cl_assert(callcount > 0); } +void test_online_clone__custom_headers(void) +{ + char *empty_header = ""; + char *unnamed_header = "this is a header about nothing"; + char *newlines = "X-Custom: almost OK\n"; + char *conflict = "Accept: defined-by-git"; + char *ok = "X-Custom: this should be ok"; + + g_options.fetch_opts.custom_headers.count = 1; + + g_options.fetch_opts.custom_headers.strings = &empty_header; + cl_git_fail(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options)); + + g_options.fetch_opts.custom_headers.strings = &unnamed_header; + cl_git_fail(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options)); + + g_options.fetch_opts.custom_headers.strings = &newlines; + cl_git_fail(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options)); + + g_options.fetch_opts.custom_headers.strings = &conflict; + cl_git_fail(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options)); + + /* Finally, we got it right! */ + g_options.fetch_opts.custom_headers.strings = &ok; + cl_git_pass(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options)); +} + static int cred_failure_cb( git_cred **cred, const char *url, |