Debian Codegraph @

t/t-verify.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 . "$(dirnamescip-shell system . . dirname. "$0")/testlib.sh"
4
5 begin_test "verify with retries"
6 (
7 set -e
8
9 reponame="verify-fail-2-times"
10 setup_remote_repo "$reponame"
11 clone_repo "$reponame" "$reponame"
12
13 gitscip-shell system . . git. lfs track "*.dat"
14 gitscip-shell system . . git. add .gitattributes
15 gitscip-shell system . . git. commit -m "initial commit"
16
17 contents="send-verify-action"
18 contents_oid="$(calc_oid "$contents")"
19 contents_short_oid="$(echoscip-shell system . . echo. "$contents_oid" | headscip-shell system . . head. -c 7)"
20 printfscip-shell system . . printf. "%s" "$contents" > a.dat
21
22 gitscip-shell system . . git. add a.dat
23 gitscip-shell system . . git. commit -m "add a.dat"
24
25 GIT_TRACE=1 GIT_CURL_VERBOSE=1 gitscip-shell system . . git. push origin main 2>&1 | teescip-shell system . . tee. push.log
26
27 grepscip-shell system . . grep. "Authorization: Basic * * * * *" push.log
28
29 [scip-shell system . . `[`. "0" -eq "${PIPESTATUS[0]}" ]
30 [scip-shell system . . `[`. "2" -eq "$(grepscip-shell system . . grep. -c "verify $contents_short_oid attempt" push.log)" ]
31 )
32 end_test
33
34 begin_test "verify with retries (success without retry)"
35 (
36 set -e
37
38 reponame="verify-fail-0-times"
39 setup_remote_repo "$reponame"
40 clone_repo "$reponame" "$reponame"
41
42 gitscip-shell system . . git. lfs track "*.dat"
43 gitscip-shell system . . git. add .gitattributes
44 gitscip-shell system . . git. commit -m "initial commit"
45
46 contents="send-verify-action"
47 contents_oid="$(calc_oid "$contents")"
48 contents_short_oid="$(echoscip-shell system . . echo. "$contents_oid" | headscip-shell system . . head. -c 7)"
49 printfscip-shell system . . printf. "%s" "$contents" > a.dat
50
51 gitscip-shell system . . git. add a.dat
52 gitscip-shell system . . git. commit -m "add a.dat"
53
54 GIT_TRACE=1 GIT_CURL_VERBOSE=1 gitscip-shell system . . git. push origin main 2>&1 | teescip-shell system . . tee. push.log
55
56 grepscip-shell system . . grep. "Authorization: Basic * * * * *" push.log
57
58 [scip-shell system . . `[`. "0" -eq "${PIPESTATUS[0]}" ]
59 [scip-shell system . . `[`. "1" -eq "$(grepscip-shell system . . grep. -c "verify $contents_short_oid attempt" push.log)" ]
60 )
61 end_test
62
63 begin_test "verify with retries (insufficient retries)"
64 (
65 set -e
66
67 reponame="verify-fail-10-times"
68 setup_remote_repo "$reponame"
69 clone_repo "$reponame" "$reponame"
70
71 gitscip-shell system . . git. lfs track "*.dat"
72 gitscip-shell system . . git. add .gitattributes
73 gitscip-shell system . . git. commit -m "initial commit"
74
75 contents="send-verify-action"
76 contents_oid="$(calc_oid "$contents")"
77 contents_short_oid="$(echoscip-shell system . . echo. "$contents_oid" | headscip-shell system . . head. -c 7)"
78 printfscip-shell system . . printf. "%s" "$contents" > a.dat
79
80 gitscip-shell system . . git. add a.dat
81 gitscip-shell system . . git. commit -m "add a.dat"
82
83 set +e
84 GIT_TRACE=1 gitscip-shell system . . git. push origin main 2>&1 | teescip-shell system . . tee. push.log
85 if [scip-shell system . . `[`. "0" -eq "${PIPESTATUS[0]}" ]; then
86 echoscip-shell system . . echo. >&2 "verify: expected \"git push\" to fail, didn't ..."
87 exit 1
88 fi
89 set -e
90
91 [scip-shell system . . `[`. "3" -eq "$(grepscip-shell system . . grep. -c "verify $contents_short_oid attempt" push.log)" ]
92 )
93 end_test
94
95 begin_test "verify with retries (bad .gitconfig)"
96 (
97 set -e
98
99 reponame="bad-config-verify-fail-2-times"
100 setup_remote_repo "$reponame"
101 clone_repo "$reponame" "$reponame"
102
103 # Invalid `lfs.transfer.maxverifies` will default to 3.
104 gitscip-shell system . . git. config "lfs.transfer.maxverifies" "-1"
105
106 gitscip-shell system . . git. lfs track "*.dat"
107 gitscip-shell system . . git. add .gitattributes
108 gitscip-shell system . . git. commit -m "initial commit"
109
110 contents="send-verify-action"
111 contents_oid="$(calc_oid "$contents")"
112 contents_short_oid="$(echoscip-shell system . . echo. "$contents_oid" | headscip-shell system . . head. -c 7)"
113 printfscip-shell system . . printf. "%s" "$contents" > a.dat
114
115 gitscip-shell system . . git. add a.dat
116 gitscip-shell system . . git. commit -m "add a.dat"
117
118 GIT_TRACE=1 GIT_CURL_VERBOSE=1 gitscip-shell system . . git. push origin main 2>&1 | teescip-shell system . . tee. push.log
119
120 grepscip-shell system . . grep. "Authorization: Basic * * * * *" push.log
121
122 [scip-shell system . . `[`. "0" -eq "${PIPESTATUS[0]}" ]
123 [scip-shell system . . `[`. "2" -eq "$(grepscip-shell system . . grep. -c "verify $contents_short_oid attempt" push.log)" ]
124 )
125 end_test