Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t5573-pull-verify-signatures.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t5573-pull-verify-signatures.sh` 153 lines ยท 5701 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='pull signature verification tests' 4 5 . ./test-lib.sh 6 . "$TEST_DIRECTORY/lib-gpg.sh" 7 8 test_expect_success GPG 'create repositories with signed commits' ' 9 echo 1 >a && git add a && 10 test_tick && git commit -m initial && 11 git tag initial && 12 13 git clone . signed && 14 ( 15 cd signed && 16 echo 2 >b && git add b && 17 test_tick && git commit -S -m "signed" 18 ) && 19 20 git clone . unsigned && 21 ( 22 cd unsigned && 23 echo 3 >c && git add c && 24 test_tick && git commit -m "unsigned" 25 ) && 26 27 git clone . bad && 28 ( 29 cd bad && 30 echo 4 >d && git add d && 31 test_tick && git commit -S -m "bad" && 32 git cat-file commit HEAD >raw && 33 sed -e "s/^bad/forged bad/" raw >forged && 34 git hash-object -w -t commit forged >forged.commit && 35 git checkout $(cat forged.commit) 36 ) && 37 38 git clone . untrusted && 39 ( 40 cd untrusted && 41 echo 5 >e && git add e && 42 test_tick && git commit -SB7227189 -m "untrusted" 43 ) 44 ' 45 46 test_expect_success GPG 'pull unsigned commit with --verify-signatures' ' 47 test_when_finished "git reset --hard && git checkout initial" && 48 test_must_fail git pull --ff-only --verify-signatures unsigned 2>pullerror && 49 test_grep "does not have a GPG signature" pullerror 50 ' 51 52 test_expect_success GPG 'pull commit with bad signature with --verify-signatures' ' 53 test_when_finished "git reset --hard && git checkout initial" && 54 test_must_fail git pull --ff-only --verify-signatures bad 2>pullerror && 55 test_grep "has a bad GPG signature" pullerror 56 ' 57 58 test_expect_success GPG 'pull commit with untrusted signature with --verify-signatures' ' 59 test_when_finished "git reset --hard && git checkout initial" && 60 test_must_fail git pull --ff-only --verify-signatures untrusted 2>pullerror && 61 test_grep "has an untrusted GPG signature" pullerror 62 ' 63 64 test_expect_success GPG 'pull commit with untrusted signature with --verify-signatures and minTrustLevel=ultimate' ' 65 test_when_finished "git reset --hard && git checkout initial" && 66 test_config gpg.minTrustLevel ultimate && 67 test_must_fail git pull --ff-only --verify-signatures untrusted 2>pullerror && 68 test_grep "has an untrusted GPG signature" pullerror 69 ' 70 71 test_expect_success GPG 'pull commit with untrusted signature with --verify-signatures and minTrustLevel=marginal' ' 72 test_when_finished "git reset --hard && git checkout initial" && 73 test_config gpg.minTrustLevel marginal && 74 test_must_fail git pull --ff-only --verify-signatures untrusted 2>pullerror && 75 test_grep "has an untrusted GPG signature" pullerror 76 ' 77 78 test_expect_success GPG 'pull commit with untrusted signature with --verify-signatures and minTrustLevel=undefined' ' 79 test_when_finished "git reset --hard && git checkout initial" && 80 test_config gpg.minTrustLevel undefined && 81 git pull --ff-only --verify-signatures untrusted >pulloutput && 82 test_grep "has a good GPG signature" pulloutput 83 ' 84 85 test_expect_success GPG 'pull signed commit with --verify-signatures' ' 86 test_when_finished "git reset --hard && git checkout initial" && 87 git pull --verify-signatures signed >pulloutput && 88 test_grep "has a good GPG signature" pulloutput 89 ' 90 91 test_expect_success GPG 'pull commit with bad signature without verification' ' 92 test_when_finished "git reset --hard && git checkout initial" && 93 git pull --ff-only bad 2>pullerror 94 ' 95 96 test_expect_success GPG 'pull commit with bad signature with --no-verify-signatures' ' 97 test_when_finished "git reset --hard && git checkout initial" && 98 test_config merge.verifySignatures true && 99 test_config pull.verifySignatures true && 100 git pull --ff-only --no-verify-signatures bad 2>pullerror 101 ' 102 103 test_expect_success GPG 'pull unsigned commit into unborn branch' ' 104 test_when_finished "rm -rf empty-repo" && 105 git init empty-repo && 106 test_must_fail \ 107 git -C empty-repo pull --verify-signatures .. 2>pullerror && 108 test_grep "does not have a GPG signature" pullerror 109 ' 110 111 test_expect_success GPG 'pull commit into unborn branch with bad signature and --verify-signatures' ' 112 test_when_finished "rm -rf empty-repo" && 113 git init empty-repo && 114 test_must_fail \ 115 git -C empty-repo pull --ff-only --verify-signatures ../bad 2>pullerror && 116 test_grep "has a bad GPG signature" pullerror 117 ' 118 119 test_expect_success GPG 'pull commit into unborn branch with untrusted signature and --verify-signatures' ' 120 test_when_finished "rm -rf empty-repo" && 121 git init empty-repo && 122 test_must_fail \ 123 git -C empty-repo pull --ff-only --verify-signatures ../untrusted 2>pullerror && 124 test_grep "has an untrusted GPG signature" pullerror 125 ' 126 127 test_expect_success GPG 'pull commit into unborn branch with untrusted signature and --verify-signatures and minTrustLevel=ultimate' ' 128 test_when_finished "rm -rf empty-repo" && 129 git init empty-repo && 130 test_config_global gpg.minTrustLevel ultimate && 131 test_must_fail \ 132 git -C empty-repo pull --ff-only --verify-signatures ../untrusted 2>pullerror && 133 test_grep "has an untrusted GPG signature" pullerror 134 ' 135 136 test_expect_success GPG 'pull commit into unborn branch with untrusted signature and --verify-signatures and minTrustLevel=marginal' ' 137 test_when_finished "rm -rf empty-repo" && 138 git init empty-repo && 139 test_config_global gpg.minTrustLevel marginal && 140 test_must_fail \ 141 git -C empty-repo pull --ff-only --verify-signatures ../untrusted 2>pullerror && 142 test_grep "has an untrusted GPG signature" pullerror 143 ' 144 145 test_expect_success GPG 'pull commit into unborn branch with untrusted signature and --verify-signatures and minTrustLevel=undefined' ' 146 test_when_finished "rm -rf empty-repo" && 147 git init empty-repo && 148 test_config_global gpg.minTrustLevel undefined && 149 git -C empty-repo pull --ff-only --verify-signatures ../untrusted >pulloutput && 150 test_grep "has a good GPG signature" pulloutput 151 ' 152 153 test_done