Tests redirect to err file when grepping stderr
[stgit.git] / t / t1009-gpg.sh
blobcd8399412a8b0e7ca6aebb245fb825ed7f5eea92
1 #!/bin/sh
3 test_description='Test gpg signatures'
5 . ./test-lib.sh
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}
12 stg init &&
13 git verify-commit refs/stacks/master
16 test_expect_success GPG \
17 'stg new creates a signed patch' '
18 stg new -m p0 &&
19 git verify-commit HEAD
22 test_expect_success GPG \
23 'stg refresh creates a signed patch' '
24 echo "hello world" > a.txt &&
25 stg add a.txt &&
26 stg refresh &&
27 git verify-commit HEAD
30 test_expect_success GPG \
31 'stg push creates a signed patch' '
32 stg new -m p1 &&
33 stg pop &&
34 git verify-commit $(stg id p1) &&
35 stg push &&
36 git verify-commit HEAD
39 test_expect_success GPG \
40 'Patch remains signed after stg sink ' '
41 stg new -m p2 &&
42 stg sink -t p0 &&
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 &&
52 stg pop -a &&
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 &&
61 git add b.txt &&
62 stg refresh &&
63 test_must_fail git verify-commit HEAD &&
64 git verify-commit HEAD~ &&
65 stg pop &&
66 git verify-commit HEAD &&
67 git config commit.gpgsign true &&
68 stg push &&
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 &&
77 stg push p0 &&
78 test_must_fail git verify-commit $(stg id p0) &&
79 git config commit.gpgsign true &&
80 stg push p1 &&
81 git verify-commit $(stg id p1)
84 test_expect_success GPG \
85 'Editing an unsigned patch causes it to be signed' '
86 stg edit --ack p0 &&
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"
97 test_done