]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t5701-git-serve.sh
Merge branch 'bc/sha-256-part-2'
[thirdparty/git.git] / t / t5701-git-serve.sh
index ffb9613885904eaf474a726f6124032d13db9753..a1f5fdc9fdcf522706d4ad74230bff3887bbf9f9 100755 (executable)
@@ -5,12 +5,17 @@ test_description='test protocol v2 server commands'
 . ./test-lib.sh
 
 test_expect_success 'test capability advertisement' '
+       test_oid_cache <<-EOF &&
+       wrong_algo sha1:sha256
+       wrong_algo sha256:sha1
+       EOF
        cat >expect <<-EOF &&
        version 2
        agent=git/$(git version | cut -d" " -f3)
        ls-refs
        fetch=shallow
        server-option
+       object-format=$(test_oid algo)
        0000
        EOF
 
@@ -45,6 +50,7 @@ test_expect_success 'request invalid capability' '
 test_expect_success 'request with no command' '
        test-tool pkt-line pack >in <<-EOF &&
        agent=git/test
+       object-format=$(test_oid algo)
        0000
        EOF
        test_must_fail test-tool serve-v2 --stateless-rpc 2>err <in &&
@@ -54,6 +60,7 @@ test_expect_success 'request with no command' '
 test_expect_success 'request invalid command' '
        test-tool pkt-line pack >in <<-EOF &&
        command=foo
+       object-format=$(test_oid algo)
        agent=git/test
        0000
        EOF
@@ -61,6 +68,17 @@ test_expect_success 'request invalid command' '
        test_i18ngrep "invalid command" err
 '
 
+test_expect_success 'wrong object-format' '
+       test-tool pkt-line pack >in <<-EOF &&
+       command=fetch
+       agent=git/test
+       object-format=$(test_oid wrong_algo)
+       0000
+       EOF
+       test_must_fail test-tool serve-v2 --stateless-rpc 2>err <in &&
+       test_i18ngrep "mismatched object format" err
+'
+
 # Test the basics of ls-refs
 #
 test_expect_success 'setup some refs and tags' '
@@ -74,6 +92,7 @@ test_expect_success 'setup some refs and tags' '
 test_expect_success 'basics of ls-refs' '
        test-tool pkt-line pack >in <<-EOF &&
        command=ls-refs
+       object-format=$(test_oid algo)
        0000
        EOF
 
@@ -96,6 +115,7 @@ test_expect_success 'basics of ls-refs' '
 test_expect_success 'basic ref-prefixes' '
        test-tool pkt-line pack >in <<-EOF &&
        command=ls-refs
+       object-format=$(test_oid algo)
        0001
        ref-prefix refs/heads/master
        ref-prefix refs/tags/one
@@ -116,6 +136,7 @@ test_expect_success 'basic ref-prefixes' '
 test_expect_success 'refs/heads prefix' '
        test-tool pkt-line pack >in <<-EOF &&
        command=ls-refs
+       object-format=$(test_oid algo)
        0001
        ref-prefix refs/heads/
        0000
@@ -136,6 +157,7 @@ test_expect_success 'refs/heads prefix' '
 test_expect_success 'peel parameter' '
        test-tool pkt-line pack >in <<-EOF &&
        command=ls-refs
+       object-format=$(test_oid algo)
        0001
        peel
        ref-prefix refs/tags/
@@ -157,6 +179,7 @@ test_expect_success 'peel parameter' '
 test_expect_success 'symrefs parameter' '
        test-tool pkt-line pack >in <<-EOF &&
        command=ls-refs
+       object-format=$(test_oid algo)
        0001
        symrefs
        ref-prefix refs/heads/
@@ -178,6 +201,7 @@ test_expect_success 'symrefs parameter' '
 test_expect_success 'sending server-options' '
        test-tool pkt-line pack >in <<-EOF &&
        command=ls-refs
+       object-format=$(test_oid algo)
        server-option=hello
        server-option=world
        0001
@@ -200,6 +224,7 @@ test_expect_success 'unexpected lines are not allowed in fetch request' '
 
        test-tool pkt-line pack >in <<-EOF &&
        command=fetch
+       object-format=$(test_oid algo)
        0001
        this-is-not-a-command
        0000