Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions josh-proxy/src/bin/josh-proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,11 @@ async fn do_filter(
r
}

async fn error_response() -> Response<hyper::Body> {
async fn error_response(body: hyper::Body) -> Response<hyper::Body> {
Response::builder()
.status(hyper::StatusCode::INTERNAL_SERVER_ERROR)
.body(hyper::Body::empty())
.header("Content-Type", "text/plain")
.body(body)
.expect("Can't build response")
}

Expand Down Expand Up @@ -685,16 +686,15 @@ async fn run_proxy() -> josh::JoshResult<i32> {

async move {
let r = if let Ok(req_auth) = josh_proxy::auth::strip_auth(_req) {
if let Ok(r) = call_service(proxy_service, req_auth)
match call_service(proxy_service, req_auth)
.instrument(s.clone())
.await
{
r
} else {
error_response().await
Ok(r) => r,
Err(e) => error_response(hyper::Body::from(format!("{}", e))).await,
}
} else {
error_response().await
error_response(hyper::Body::from("JoshError(strip_auth)")).await
};
let _e = s.enter();
trace_http_response_code(s.clone(), r.status());
Expand Down
58 changes: 58 additions & 0 deletions tests/proxy/clone_invalid_filter.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
$ . ${TESTDIR}/setup_test_env.sh
$ cd ${TESTTMP}


$ git clone -q http://localhost:8001/real_repo.git
warning: You appear to have cloned an empty repository.

$ curl -s http://localhost:8002/version
Version: 0.3.0

$ cd real_repo

$ git status
On branch master

No commits yet

nothing to commit (create/copy files and use "git add" to track)

$ mkdir -p sub1/subsub
$ echo contents1 > sub1/subsub/file1
$ git add .
$ git commit -m "add file1"
[master (root-commit) 03dfdf5] add file1
1 file changed, 1 insertion(+)
create mode 100644 sub1/subsub/file1

$ mkdir sub2
$ echo contents1 > sub2/file2
$ git add sub2
$ git commit -m "add file2"
[master 79e0ba4] add file2
1 file changed, 1 insertion(+)
create mode 100644 sub2/file2

$ tree
.
|-- sub1
| `-- subsub
| `-- file1
`-- sub2
`-- file2

3 directories, 2 files

$ git log --graph --pretty=%s
* add file2
* add file1

$ git push
To http://localhost:8001/real_repo.git
* [new branch] master -> master

$ cd ${TESTTMP}
$ git clone -q http://localhost:8002/real_repo.git:sub1.git
remote: JoshError(invalid filter)
fatal: unable to access 'http://localhost:8002/real_repo.git:sub1.git/': The requested URL returned error: 500
[128]