File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed
Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -467,6 +467,22 @@ async fn call_service(
467467 return Ok ( builder. body ( hyper:: Body :: empty ( ) ) ?) ;
468468 }
469469
470+ let block = std:: env:: var ( "JOSH_REPO_BLOCK" ) . unwrap_or ( "" . to_owned ( ) ) ;
471+ let block = block. split ( ";" ) . collect :: < Vec < _ > > ( ) ;
472+
473+ for b in block {
474+ if b == parsed_url. upstream_repo {
475+ return Ok ( make_response (
476+ hyper:: Body :: from ( formatdoc ! (
477+ r#"
478+ Access to this repo is blocked via JOSH_REPO_BLOCK
479+ "#
480+ ) ) ,
481+ hyper:: StatusCode :: UNPROCESSABLE_ENTITY ,
482+ ) ) ;
483+ }
484+ }
485+
470486 match fetch_upstream (
471487 serv. clone ( ) ,
472488 parsed_url. upstream_repo . to_owned ( ) ,
Original file line number Diff line number Diff line change 1+ $ . $ {TESTDIR}/ setup_test_env. sh
2+ $ cd $ {TESTTMP}
3+
4+ $ git clone -q http: // localhost: 8002 / blocked_repo. git
5+ remote: Access to this repo is blocked via JOSH_REPO_BLOCK
6+ fatal : unable to access ' http://localhost:8002/blocked_repo.git/' : The requested URL returned error: 422
7+ [128 ]
8+
9+ $ bash $ {TESTDIR}/ destroy_test_env. sh
10+ refs
11+ | -- heads
12+ `-- tags
13+
14+ 2 directories, 0 files
15+
Original file line number Diff line number Diff line change @@ -5,12 +5,15 @@ killall hyper-cgi-test-server >/dev/null 2>&1 || true
55
66git init --bare ${TESTTMP} /remote/real_repo.git/ 1> /dev/null
77git config -f ${TESTTMP} /remote/real_repo.git/config http.receivepack true
8+ git init --bare ${TESTTMP} /remote/blocked_repo.git/ 1> /dev/null
9+ git config -f ${TESTTMP} /remote/blocked_repo.git/config http.receivepack true
810git init --bare ${TESTTMP} /remote/real/repo2.git/ 1> /dev/null
911git config -f ${TESTTMP} /remote/real/repo2.git/config http.receivepack true
1012export RUST_LOG=trace
1113
1214export GIT_CONFIG_NOSYSTEM=1
1315export JOSH_SERVICE_NAME=" josh-proxy-test"
16+ export JOSH_REPO_BLOCK=" /blocked_repo.git"
1417
1518GIT_DIR=${TESTTMP} /remote/ GIT_PROJECT_ROOT=${TESTTMP} /remote/ GIT_HTTP_EXPORT_ALL=1 hyper-cgi-test-server\
1619 --port=8001\
You can’t perform that action at this time.
0 commit comments