X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=tests%2Ftests%2Ftrustingpolicy-replay;h=517f98a08014759fd13b22bb095472e59087cfd1;hp=57ef2866a601647d5f933b6214fb46d93a607c02;hb=d6be829bf56e699d27d388026d4af7ab710ba328;hpb=df2685b0b8364f6dfed541113478bbd23a175a01 diff --git a/tests/tests/trustingpolicy-replay b/tests/tests/trustingpolicy-replay index 57ef2866..517f98a0 100755 --- a/tests/tests/trustingpolicy-replay +++ b/tests/tests/trustingpolicy-replay @@ -15,21 +15,69 @@ git tag start t-dgit build t-dgit push --new -t-commit 'Prep v2 which will be rewound' +t-commit 'Prep v1.1 which will be rewound' t-dgit build t-dgit push t-rm-dput-dropping -git checkout debian/1.0 +git checkout test-dummy/1.0 t-dgit build t-dgit push --deliberately-fresh-repo remote="`git config dgit-distro.test-dummy.git-url`/$p.git" -t-expect-fail 'Replay of previously-rewound upload' \ +t-expect-push-fail 'Replay of previously-rewound upload' \ git push "$remote" \ - debian/1.1 \ - debian/1.1~0:refs/dgit/sid + test-dummy/1.1 \ + test-dummy/1.1~0:refs/dgit/sid + +git checkout master + + +: "More subtle replay prevention checks" + +prepare-replay () { + delib=$1 + + # We have to stop the pushes succeeding because if they work they + # record the tag, which prevents the replays. We are simulating + # abortive pushes (since we do want to avoid a situation where + # dangerous old signed tags can exist). + t-policy-nonexist + + t-commit "request with $delib that we will replay" + t-dgit build + t-expect-push-fail 'system: No such file or directory' \ + t-dgit push $delib + + t-policy dgit-repos-policy-trusting + + replayv=$v +} + +attempt-replay () { + local mpat=$1 + git show test-dummy/$replayv | grep -e $delib + t-expect-push-fail "$mpat" \ + git push "$remote" \ + test-dummy/$replayv \ + +test-dummy/$replayv~0:refs/dgit/sid +} + +prepare-replay --deliberately-fresh-repo + +# simulate some other thing that we shouldn't delete +git push $dgitrepo +master:refs/heads/for-testing + +attempt-replay 'does not declare previously heads/for-testing' + +prepare-replay --deliberately-not-fast-forward + +t-commit 'later version to stop not fast forward rewinding' +t-dgit build +t-dgit push + +attempt-replay "does not declare previously tags/test-dummy/$v" + echo ok. -echo xxx want to check replay prevention insufficient proofs in tag