summaryrefslogtreecommitdiff
path: root/tests/network
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2019-12-13 10:56:19 -0800
committerJosh Bleecher Snyder <josharian@gmail.com>2020-01-09 13:32:03 -0800
commit7142964f38863276c087169cc74a2b2c1cb07854 (patch)
tree9b3b9f7bc3339f295dcb6c42eeeede4a5f4ed0cd /tests/network
parent258188ddb0e0bac99c2384b8730b916193784fff (diff)
downloadlibgit2-7142964f38863276c087169cc74a2b2c1cb07854.tar.gz
netops: handle intact query parameters in service_suffix removal
Some servers leave the query parameters intact in the Location header when responding with a redirect. The service_suffix removal check as written assumed that the server removed them. Handle both cases. Along with PR #5325, this fixes #5321. There are two new tests. The first already passed; the second previously failed.
Diffstat (limited to 'tests/network')
-rw-r--r--tests/network/redirect.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/network/redirect.c b/tests/network/redirect.c
index 3fc0b1826..ce0a080dd 100644
--- a/tests/network/redirect.c
+++ b/tests/network/redirect.c
@@ -111,3 +111,19 @@ void test_network_redirect__redirect_relative_ssl(void)
cl_assert_equal_p(conndata.username, NULL);
cl_assert_equal_p(conndata.password, NULL);
}
+
+void test_network_redirect__service_query_no_query_params_in_location(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata, "https://foo.com/bar/info/refs?service=git-upload-pack"));
+ cl_git_pass(gitno_connection_data_handle_redirect(&conndata,
+ "/baz/info/refs", "/info/refs?service=git-upload-pack"));
+ cl_assert_equal_s(conndata.path, "/baz");
+}
+
+void test_network_redirect__service_query_with_query_params_in_location(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata, "https://foo.com/bar/info/refs?service=git-upload-pack"));
+ cl_git_pass(gitno_connection_data_handle_redirect(&conndata,
+ "/baz/info/refs?service=git-upload-pack", "/info/refs?service=git-upload-pack"));
+ cl_assert_equal_s(conndata.path, "/baz");
+}