Imported Upstream version 2.5.1
[scm/test.git] / t / t-content-type.sh
1 #!/usr/bin/env bash
2
3 . "$(dirname "$0")/testlib.sh"
4
5 begin_test "content-type: is enabled by default"
6 (
7   set -e
8
9   reponame="content-type-enabled-default"
10   setup_remote_repo "$reponame"
11   clone_repo "$reponame" "$reponame"
12
13   git lfs track "*.tar.gz"
14   printf "aaaaaaaaaa" > a.txt
15   tar -czf a.tar.gz a.txt
16   rm a.txt
17
18   git add .gitattributes a.tar.gz
19   git commit -m "initial commit"
20   GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log
21
22   [ 1 -eq "$(grep -c "Content-Type: application/x-gzip" push.log)" ]
23 )
24 end_test
25
26 begin_test "content-type: is disabled by configuration"
27 (
28   set -e
29
30   reponame="content-type-disabled-by-configuration"
31   setup_remote_repo "$reponame"
32   clone_repo "$reponame" "$reponame"
33
34   git lfs track "*.tar.gz"
35   printf "aaaaaaaaaa" > a.txt
36   tar -czf a.tar.gz a.txt
37   rm a.txt
38
39   git add .gitattributes a.tar.gz
40   git commit -m "initial commit"
41   git config "lfs.$GITSERVER.contenttype" 0
42   GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log
43
44   [ 0 -eq "$(grep -c "Content-Type: application/x-gzip" push.log)" ]
45 )
46 end_test
47
48 begin_test "content-type: warning message"
49 (
50   set -e
51
52   reponame="content-type-warning-message"
53   setup_remote_repo "$reponame"
54   clone_repo "$reponame" "$reponame"
55
56   git lfs track "*.txt"
57   printf "status-storage-422" > a.txt
58
59   git add .gitattributes a.txt
60   git commit -m "initial commit"
61   git push origin master 2>&1 | tee push.log
62
63   grep "info: Uploading failed due to unsupported Content-Type header(s)." push.log
64   grep "info: Consider disabling Content-Type detection with:" push.log
65   grep "info:   $ git config lfs.contenttype false" push.log
66 )
67 end_test