Commit 6a4b1262 authored by Kevin Atkinson's avatar Kevin Atkinson

Make sure you can't add URL's unless the url store is enabled.

License: MIT
Signed-off-by: default avatarKevin Atkinson <k@kevina.org>
parent 0c2efb90
...@@ -56,6 +56,17 @@ time. ...@@ -56,6 +56,17 @@ time.
return return
} }
cfg, err := n.Repo.Config()
if err != nil {
res.SetError(err, cmdkit.ErrNormal)
return
}
if !cfg.Experimental.UrlstoreEnabled {
res.SetError(fmt.Errorf("URL store not enabled."), cmdkit.ErrNormal)
return
}
hreq, err := http.NewRequest("GET", url, nil) hreq, err := http.NewRequest("GET", url, nil)
if err != nil { if err != nil {
res.SetError(err, cmdkit.ErrNormal) res.SetError(err, cmdkit.ErrNormal)
......
...@@ -10,10 +10,6 @@ test_description="Test out the urlstore functionality" ...@@ -10,10 +10,6 @@ test_description="Test out the urlstore functionality"
test_init_ipfs test_init_ipfs
test_expect_success "enable urlstore" '
ipfs config --json Experimental.UrlstoreEnabled true
'
test_expect_success "create some random files" ' test_expect_success "create some random files" '
random 2222 7 > file1 && random 2222 7 > file1 &&
random 500000 7 > file2 && random 500000 7 > file2 &&
...@@ -36,6 +32,19 @@ test_expect_success "make sure files can be retrived via the gateway" ' ...@@ -36,6 +32,19 @@ test_expect_success "make sure files can be retrived via the gateway" '
test_cmp file3 file3.actual test_cmp file3 file3.actual
' '
test_expect_success "add files without enabling url store" '
test_must_fail ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH1a &&
test_must_fail ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH2a
'
test_kill_ipfs_daemon
test_expect_success "enable urlstore" '
ipfs config --json Experimental.UrlstoreEnabled true
'
test_launch_ipfs_daemon --offline
test_expect_success "add files using gateway address via url store" ' test_expect_success "add files using gateway address via url store" '
HASH1=$(ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH1a) && HASH1=$(ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH1a) &&
HASH2=$(ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH2a) && HASH2=$(ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH2a) &&
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment