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