From 44245fe015decfb575357f7fea9795a933b86fbb Mon Sep 17 00:00:00 2001 From: rht Date: Fri, 3 Jul 2015 08:49:06 +0700 Subject: [PATCH] Add test to detect invalid path License: MIT Signed-off-by: rht --- core/pathresolver_test.go | 4 ++++ test/sharness/t0090-get.sh | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/core/pathresolver_test.go b/core/pathresolver_test.go index 489af4eb5..9db0bfbeb 100644 --- a/core/pathresolver_test.go +++ b/core/pathresolver_test.go @@ -24,4 +24,8 @@ func TestResolveNoComponents(t *testing.T) { t.Fatal("Should error with no components (/ipfs/).", err) } + _, err = core.Resolve(n.Context(), n, path.Path("/../..")) + if err != path.ErrBadPath { + t.Fatal("Should error with invalid path.", err) + } } diff --git a/test/sharness/t0090-get.sh b/test/sharness/t0090-get.sh index 393ba5b5b..4f9c4b581 100755 --- a/test/sharness/t0090-get.sh +++ b/test/sharness/t0090-get.sh @@ -112,6 +112,12 @@ test_get_cmd() { test_cmp dir/b/c "$HASH2"/b/c && rm -r "$HASH2" ' + + test_expect_success "ipfs get ../.. should fail" ' + echo "Error: invalid ipfs ref path" >expected && + test_must_fail ipfs get ../.. 2>actual && + test_cmp expected actual + ' } # should work offline