| 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 main 2>&1 | tee push.log |
| 21 | |
| 22 | [ 1 -eq "$(grep -c "Content-Type: application/x-gzip" push.log)" ] |
| 23 | [ 0 -eq "$(grep -c "Content-Type: application/octet-stream" push.log)" ] |
| 24 | ) |
| 25 | end_test |
| 26 | |
| 27 | begin_test "content-type: is disabled by configuration" |
| 28 | ( |
| 29 | set -e |
| 30 | |
| 31 | reponame="content-type-disabled-by-configuration" |
| 32 | setup_remote_repo "$reponame" |
| 33 | clone_repo "$reponame" "$reponame" |
| 34 | |
| 35 | git lfs track "*.tar.gz" |
| 36 | printf "aaaaaaaaaa" > a.txt |
| 37 | tar -czf a.tar.gz a.txt |
| 38 | rm a.txt |
| 39 | |
| 40 | git add .gitattributes a.tar.gz |
| 41 | git commit -m "initial commit" |
| 42 | git config "lfs.$GITSERVER.contenttype" 0 |
| 43 | GIT_CURL_VERBOSE=1 git push origin main 2>&1 | tee push.log |
| 44 | |
| 45 | [ 0 -eq "$(grep -c "Content-Type: application/x-gzip" push.log)" ] |
| 46 | [ 1 -eq "$(grep -c "Content-Type: application/octet-stream" push.log)" ] |
| 47 | ) |
| 48 | end_test |
| 49 | |
| 50 | begin_test "content-type: warning message" |
| 51 | ( |
| 52 | set -e |
| 53 | |
| 54 | reponame="content-type-warning-message" |
| 55 | setup_remote_repo "$reponame" |
| 56 | clone_repo "$reponame" "$reponame" |
| 57 | |
| 58 | git lfs track "*.txt" |
| 59 | printf "status-storage-422" > a.txt |
| 60 | |
| 61 | git add .gitattributes a.txt |
| 62 | git commit -m "initial commit" |
| 63 | git push origin main 2>&1 | tee push.log |
| 64 | |
| 65 | grep "info: Uploading failed due to unsupported Content-Type header(s)." push.log |
| 66 | grep "info: Consider disabling Content-Type detection with:" push.log |
| 67 | grep "info: $ git config lfs.contenttype false" push.log |
| 68 | ) |
| 69 | end_test |