From f6244586ba4f5a5e7575e1254be8c9bbe303fce9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 15 Feb 2017 22:35:18 +0000 Subject: repobrowse: switch to new URL format to avoid query strings Query strings make endpoint caching more difficult since they're order-independent. They are also more likely lost or truncated inadvertantly when copy+pasting, so try to avoid them for default endpoints. There's still some things which are broken and followup commits will be needed to fix them. --- t/repobrowse_git_atom.t | 6 +----- t/repobrowse_git_commit.t | 14 +------------- t/repobrowse_git_plain.t | 7 ++++--- t/repobrowse_git_tree.t | 6 +++--- 4 files changed, 9 insertions(+), 24 deletions(-) (limited to 't') diff --git a/t/repobrowse_git_atom.t b/t/repobrowse_git_atom.t index 1f8e95e3..6769bf9f 100644 --- a/t/repobrowse_git_atom.t +++ b/t/repobrowse_git_atom.t @@ -23,11 +23,7 @@ test_psgi($test->{app}, sub { like($body, qr!]+>\* header:\n add header!, 'body wrapped in
');
 
-	$res = $cb->(GET($req . '/'));
-	my $sl = dechunk($res);
-	is($body, $sl, 'slash returned identical to non-trailing slash');
-
-	$res = $cb->(GET($req . '/foo.txt'));
+	$res = $cb->(GET($req . '/master/foo.txt'));
 	is($res->code, 200, 'got 200');
 	$body = dechunk($res);
 	like($body, qr{\bhref="http://[^/]+/test\.git/}, 'hrefs OK');
diff --git a/t/repobrowse_git_commit.t b/t/repobrowse_git_commit.t
index ed2d6d56..f5913023 100644
--- a/t/repobrowse_git_commit.t
+++ b/t/repobrowse_git_commit.t
@@ -8,24 +8,12 @@ test_psgi($test->{app}, sub {
 	my ($cb) = @_;
 	my $path = '/path/to/something';
 	my $req = 'http://example.com/test.git/commit';
-	my $res = $cb->(GET($req . $path));
-	is($res->code, 301, 'got 301 to anchor');
-	is($res->header('Location'), "$req#path:to:something",
-		'redirected to anchor from path');
-
-	my $q = '?id=deadbeef';
-	$res = $cb->(GET($req . $path . $q));
-	is($res->code, 301, 'got 301 with query string');
-	is($res->header('Location'), "$req$q#path:to:something",
-		'redirected to anchor from path with query');
+	my $res;
 
 	$res = $cb->(GET($req));
 	is($res->code, 200, 'got proper 200 response for default');
 	my $body = dechunk($res);
 	like($body, qr!\z!, 'response body finished');
-
-	$res = $cb->(GET($req.$q));
-	is($res->code, 404, 'got 404 response for bad id');
 });
 
 done_testing();
diff --git a/t/repobrowse_git_plain.t b/t/repobrowse_git_plain.t
index 27347f70..a93fa10e 100644
--- a/t/repobrowse_git_plain.t
+++ b/t/repobrowse_git_plain.t
@@ -7,11 +7,12 @@ my $test = require './t/repobrowse_common_git.perl';
 test_psgi($test->{app}, sub {
 	my ($cb) = @_;
 
-	my $req = 'http://example.com/test.git/plain/dir';
+	my $req = 'http://example.com/test.git/plain/master/dir';
 	my $res = $cb->(GET($req));
 	is(200, $res->code, 'got 200 response from dir');
 	my $noslash_body = dechunk($res);
-	like($noslash_body, qr{href="dir/dur">dur}, 'path ok w/o slash');
+	like($noslash_body, qr{href="dir/dur">dur},
+		'path ok w/o slash');
 
 	my $slash = $req . '/';
 	my $r2 = $cb->(GET($slash));
@@ -19,7 +20,7 @@ test_psgi($test->{app}, sub {
 	my $slash_body = dechunk($r2);
 	like($slash_body, qr{href="\./dur\">dur}, 'path ok w/ slash');
 
-	$req = 'http://example.com/test.git/plain/foo.txt';
+	$req = 'http://example.com/test.git/plain/master/foo.txt';
 	my $blob = $cb->(GET($req));
 	like($blob->header('Content-Type'), qr!\Atext/plain\b!,
 		'got text/plain blob');
diff --git a/t/repobrowse_git_tree.t b/t/repobrowse_git_tree.t
index 531f914c..d91cfdc9 100644
--- a/t/repobrowse_git_tree.t
+++ b/t/repobrowse_git_tree.t
@@ -7,11 +7,11 @@ my $test = require './t/repobrowse_common_git.perl';
 test_psgi($test->{app}, sub {
 	my ($cb) = @_;
 
-	my $req = 'http://example.com/test.git/tree/dir';
+	my $req = 'http://example.com/test.git/tree/HEAD/dir';
 	my $res = $cb->(GET($req));
 	is(200, $res->code, 'got 200 response from dir');
 	my $noslash_body = dechunk($res);
-	like($noslash_body, qr{href="dir/dur\?id=\w+">dur/},
+	like($noslash_body, qr{href="dir/dur">dur/},
 		'path ok w/o slash');
 
 	my $slash = $req . '/';
@@ -19,7 +19,7 @@ test_psgi($test->{app}, sub {
 	is(301, $r2->code, 'got 301 response from dir with slash');
 	is($req, $r2->header('Location'), 'redirected w/o slash');
 
-	$req = 'http://example.com/test.git/tree/foo.txt';
+	$req = 'http://example.com/test.git/tree/master/foo.txt';
 	my $blob = $cb->(GET($req));
 	is($blob->header('Content-Type'), 'text/html; charset=UTF-8',
 		'got text/html blob');
-- 
cgit v1.2.3-24-ge0c7