| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # |
| 3 | # Copyright (c) 2022 Stefan Sperling <[email protected]> |
| 4 | # |
| 5 | # Permission to use, copy, modify, and distribute this software for any |
| 6 | # purpose with or without fee is hereby granted, provided that the above |
| 7 | # copyright notice and this permission notice appear in all copies. |
| 8 | # |
| 9 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | |
| 17 | . ../cmdline/common.shscip-shell source . . `../cmdline/common.sh`. |
| 18 | . ./common.shscip-shell source . . `./common.sh`. |
| 19 | |
| 20 | test_clone_basic_access_deniedscip-shell shell shell-project 0.0.0 test_clone_basic_access_denied().() { |
| 21 | local testroot=`test_init clone_basic_access_denied 1` |
| 22 | |
| 23 | cpscip-shell system . . cp. -r ${GOTD_TEST_REPO} $testroot/repo-copy |
| 24 | |
| 25 | got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone \ |
| 26 | 2> $testroot/stderr.raw |
| 27 | ret=$? |
| 28 | if [scip-shell system . . `[`. $ret -eq 0 ]; then |
| 29 | echoscip-shell system . . echo. "got clone succeeded unexpectedly" >&2 |
| 30 | test_done "$testroot" "1" |
| 31 | return 1 |
| 32 | fi |
| 33 | grepscip-shell system . . grep. ^got-fetch-pack: $testroot/stderr.raw > $testroot/stderr |
| 34 | |
| 35 | # Verify that the clone operation failed. |
| 36 | # The error returned will differ depending on whether read access |
| 37 | # is denied explicitly for GOTD_DEVUSER. |
| 38 | if grepscip-shell system . . grep. -q "permit.*${GOTD_DEVUSER}$" $GOTD_CONF; then |
| 39 | echoscip-shell system . . echo. 'got-fetch-pack: test-repo: Permission denied' \ |
| 40 | > $testroot/stderr.expected |
| 41 | else |
| 42 | echoscip-shell system . . echo. 'got-fetch-pack: no git repository found' \ |
| 43 | > $testroot/stderr.expected |
| 44 | fi |
| 45 | cmpscip-shell system . . cmp. -s $testroot/stderr.expected $testroot/stderr |
| 46 | ret=$? |
| 47 | if [scip-shell system . . `[`. $ret -ne 0 ]; then |
| 48 | diffscip-shell system . . diff. -u $testroot/stderr.expected $testroot/stderr |
| 49 | fi |
| 50 | test_done "$testroot" "$ret" |
| 51 | } |
| 52 | |
| 53 | test_parseargs "$@" |
| 54 | run_test test_clone_basic_access_denied |