3 test_description
='Test gpg signatures'
6 .
"$TEST_DIRECTORY/lib-gpg.sh"
8 test_expect_success GPG \
9 'Stack metadata is signed' '
10 git config commit.gpgsign true
11 git config user.signingkey ${GIT_COMMITTER_EMAIL}
13 git verify-commit refs/stacks/master
16 test_expect_success GPG \
17 'stg new creates a signed patch' '
19 git verify-commit HEAD
22 test_expect_success GPG \
23 'stg refresh creates a signed patch' '
24 echo "hello world" > a.txt &&
27 git verify-commit HEAD
30 test_expect_success GPG \
31 'stg push creates a signed patch' '
34 git verify-commit $(stg id p1) &&
36 git verify-commit HEAD
39 test_expect_success GPG \
40 'Patch remains signed after stg sink ' '
43 test "$(echo $(stg series --noprefix))" = "p2 p0 p1" &&
44 git verify-commit $(stg id p2) &&
45 git verify-commit $(stg id p0) &&
46 git verify-commit $(stg id p1)
49 test_expect_success GPG \
50 'Patch remains signed after stg commit' '
51 stg commit --allow-empty -n 1 &&
53 git verify-commit HEAD
56 test_expect_success GPG \
57 'Pushing an unsigned patch leaves patch unsigned' '
58 test_unconfig commit.gpgsign &&
59 stg new -m unsigned-patch &&
60 echo "hello again" > b.txt &&
63 test_must_fail git verify-commit HEAD &&
64 git verify-commit HEAD~ &&
66 git verify-commit HEAD &&
67 git config commit.gpgsign true &&
69 test_must_fail git verify-commit HEAD
72 test_expect_success GPG \
73 'Signed state of a reordering push of signed patch depends on commit.gpgsign' '
74 git verify-commit $(stg id p0) &&
75 git verify-commit $(stg id p1) &&
76 test_unconfig commit.gpgsign &&
78 test_must_fail git verify-commit $(stg id p0) &&
79 git config commit.gpgsign true &&
81 git verify-commit $(stg id p1)
84 test_expect_success GPG \
85 'Editing an unsigned patch causes it to be signed' '
87 git verify-commit $(stg id p0)
90 test_expect_success GPG \
91 'Using invalid user.signingkey causes failure' '
92 test_config user.signingkey invalid@example.com &&
93 command_error stg new -m p3 &&
94 test "$(stg top)" = "p1"