5639442c9963c0a3cbf748a60bb4b07657915423
[scm/test.git] / test / test-expired.sh
1 #!/usr/bin/env bash
2
3 . "test/testlib.sh"
4
5 declare -a expiration_types=("absolute" "relative" "both")
6
7 for typ in "${expiration_types[@]}"; do
8   begin_test "expired action ($typ time)"
9   (
10     set -e
11
12     reponame="expired-$typ"
13     setup_remote_repo "$reponame"
14     clone_repo "$reponame" "$reponame"
15
16     contents="contents"
17     contents_oid="$(calc_oid "$contents")"
18
19     git lfs track "*.dat"
20     git add .gitattributes
21     git commit -m "initial commit"
22
23     printf "$contents" > a.dat
24
25     git add a.dat
26     git commit -m "add a.dat"
27
28     GIT_TRACE=1 git push origin master 2>&1 | tee push.log
29     if [ "0" -eq "${PIPESTATUS[0]}" ]; then
30       echo >&2 "fatal: expected push to fail, didn't"
31       exit 1
32     fi
33
34     refute_server_object "$reponame" "$contents_oid"
35   )
36   end_test
37 done
38
39 for typ in "${expiration_types[@]}"; do
40   begin_test "ssh expired ($typ time)"
41   (
42     set -e
43
44     reponame="ssh-expired-$typ"
45     setup_remote_repo "$reponame"
46     clone_repo "$reponame" "$reponame"
47
48     sshurl="${GITSERVER/http:\/\//ssh://git@}/$reponame"
49     git config lfs.url "$sshurl"
50
51     contents="contents"
52     contents_oid="$(calc_oid "$contents")"
53
54     git lfs track "*.dat"
55     git add .gitattributes
56     git commit -m "initial commit"
57
58     printf "$contents" > a.dat
59
60     git add a.dat
61     git commit -m "add a.dat"
62
63     GIT_TRACE=1 git push origin master 2>&1 | tee push.log
64     grep "ssh cache expired" push.log
65   )
66   end_test
67 done