Make sure you can't add URL's unless the url store is enabled.
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
Kevin Atkinson committed
Jun 26, 2018 at 21:41 UTC
6a4b1262a5fde7025095fe9f26ab117dd27f2e3b
2 files changed
+24
-4
core/commands/urlstore.go
+11
@@ -56,6 +56,17 @@ time.
56
return
57
}
58
59
+ cfg, err := n.Repo.Config()
60
+ if err != nil {
61
+ res.SetError(err, cmdkit.ErrNormal)
62
+ return
63
+ }
64
+
65
+ if !cfg.Experimental.UrlstoreEnabled {
66
+ res.SetError(fmt.Errorf("URL store not enabled."), cmdkit.ErrNormal)
67
+ return
68
+ }
69
+
70
hreq, err := http.NewRequest("GET", url, nil)
71
if err != nil {
72
res.SetError(err, cmdkit.ErrNormal)
test/sharness/t0272-urlstore.sh
+13
-4
@@ -10,10 +10,6 @@ test_description="Test out the urlstore functionality"
10
11
test_init_ipfs
12
13
-test_expect_success "enable urlstore" '
14
- ipfs config --json Experimental.UrlstoreEnabled true
15
-'
16
-
13
test_expect_success "create some random files" '
14
random 2222 7 > file1 &&
15
random 500000 7 > file2 &&
@@ -36,6 +32,19 @@ test_expect_success "make sure files can be retrived via the gateway" '
32
test_cmp file3 file3.actual
33
'
34
35
+test_expect_success "add files without enabling url store" '
36
+ test_must_fail ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH1a &&
37
+ test_must_fail ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH2a
38
+'
39
+
40
+test_kill_ipfs_daemon
41
+
42
+test_expect_success "enable urlstore" '
43
+ ipfs config --json Experimental.UrlstoreEnabled true
44
+'
45
+
46
+test_launch_ipfs_daemon --offline
47
+
48
test_expect_success "add files using gateway address via url store" '
49
HASH1=$(ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH1a) &&
50
HASH2=$(ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH2a) &&