chiark / gitweb /
test suite: Fix trustingpolicy-replay & dput-ng.
[dgit.git] / tests / tests / trustingpolicy-replay
1 #!/bin/bash
2 set -e
3 . tests/lib
4
5 t-tstunt-parsechangelog
6
7 t-git-config dgit.default.dep14tag no
8
9 t-dsd
10 t-policy dgit-repos-policy-trusting
11 t-prep-newpackage example 1.0
12
13 cd $p
14 revision=1
15 git tag start
16
17 t-dgit build
18 t-dgit push --new
19
20 t-rm-dput-dropping
21
22 t-commit 'Prep v1.1 which will be rewound'
23 t-dgit build
24 t-dgit push
25
26 git checkout $tagpfx/1.0
27 t-dgit build
28 t-dgit push --deliberately-fresh-repo
29
30 remote="`git config dgit-distro.test-dummy.git-url`/$p.git"
31
32 t-expect-push-fail 'Replay of previously-rewound upload' \
33 git push "$remote" \
34         $tagpfx/1.1 \
35         $tagpfx/1.1~0:refs/dgit/sid
36
37 git checkout master
38
39
40 : "More subtle replay prevention checks"
41
42 prepare-replay () {
43         delib=$1
44
45         # We have to stop the pushes succeeding because if they work they
46         # record the tag, which prevents the replays.  We are simulating
47         # abortive pushes (since we do want to avoid a situation where
48         # dangerous old signed tags can exist).
49         t-policy-nonexist
50
51         t-commit "request with $delib that we will replay"
52         t-dgit build
53         t-expect-push-fail 'system: No such file or directory' \
54         t-dgit push $delib
55
56         t-policy dgit-repos-policy-trusting
57
58         replayv=$v
59 }
60
61 attempt-replay () {
62         local mpat=$1
63         git show $tagpfx/$replayv | grep -e $delib
64         t-expect-push-fail "$mpat" \
65         git push "$remote" \
66                 $tagpfx/$replayv \
67                 +$tagpfx/$replayv~0:refs/dgit/sid
68 }
69
70 prepare-replay --deliberately-fresh-repo
71
72 # simulate some other thing that we shouldn't delete
73 git push $dgitrepo +master:refs/heads/for-testing
74
75 attempt-replay 'does not declare previously heads/for-testing'
76
77 prepare-replay --deliberately-not-fast-forward
78
79 t-commit 'later version to stop not fast forward rewinding'
80 t-dgit build
81 t-dgit push
82
83 attempt-replay "does not declare previously tags/$tagpfx/$v"
84
85
86 t-ok