3 from twisted.trial import unittest
4 from cStringIO import StringIO
7 from allmydata.util import fileutil, hashutil
8 from allmydata import uri
10 # at least import the CLI scripts, even if we don't have any real tests for
12 from allmydata.scripts import tahoe_ls, tahoe_get, tahoe_put, tahoe_rm
13 from allmydata.scripts.common import DEFAULT_ALIAS, get_aliases
14 _hush_pyflakes = [tahoe_ls, tahoe_get, tahoe_put, tahoe_rm]
16 from allmydata.scripts import cli, debug, runner
17 from allmydata.test.common import SystemTestMixin
18 from twisted.internet import threads # CLI tests use deferToThread
20 class CLI(unittest.TestCase):
21 # this test case only looks at argument-processing and simple stuff.
22 def test_options(self):
23 fileutil.rm_dir("cli/test_options")
24 fileutil.make_dirs("cli/test_options")
25 fileutil.make_dirs("cli/test_options/private")
26 open("cli/test_options/node.url","w").write("http://localhost:8080/\n")
27 filenode_uri = uri.WriteableSSKFileURI(writekey="\x00"*16,
28 fingerprint="\x00"*32)
29 private_uri = uri.NewDirectoryURI(filenode_uri).to_string()
30 open("cli/test_options/private/root_dir.cap", "w").write(private_uri + "\n")
32 o.parseOptions(["--node-directory", "cli/test_options"])
33 self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
34 self.failUnlessEqual(o.aliases[DEFAULT_ALIAS], private_uri)
35 self.failUnlessEqual(o.where, "")
38 o.parseOptions(["--node-directory", "cli/test_options",
39 "--node-url", "http://example.org:8111/"])
40 self.failUnlessEqual(o['node-url'], "http://example.org:8111/")
41 self.failUnlessEqual(o.aliases[DEFAULT_ALIAS], private_uri)
42 self.failUnlessEqual(o.where, "")
45 o.parseOptions(["--node-directory", "cli/test_options",
47 self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
48 self.failUnlessEqual(o.aliases[DEFAULT_ALIAS], "root")
49 self.failUnlessEqual(o.where, "")
52 other_filenode_uri = uri.WriteableSSKFileURI(writekey="\x11"*16,
53 fingerprint="\x11"*32)
54 other_uri = uri.NewDirectoryURI(other_filenode_uri).to_string()
55 o.parseOptions(["--node-directory", "cli/test_options",
56 "--dir-cap", other_uri])
57 self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
58 self.failUnlessEqual(o.aliases[DEFAULT_ALIAS], other_uri)
59 self.failUnlessEqual(o.where, "")
62 o.parseOptions(["--node-directory", "cli/test_options",
63 "--dir-cap", other_uri, "subdir"])
64 self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
65 self.failUnlessEqual(o.aliases[DEFAULT_ALIAS], other_uri)
66 self.failUnlessEqual(o.where, "subdir")
68 def _dump_cap(self, *args):
69 config = debug.DumpCapOptions()
70 config.stdout,config.stderr = StringIO(), StringIO()
71 config.parseOptions(args)
72 debug.dump_cap(config)
73 self.failIf(config.stderr.getvalue())
74 output = config.stdout.getvalue()
77 def test_dump_cap_chk(self):
78 key = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
79 storage_index = hashutil.storage_index_hash(key)
80 uri_extension_hash = hashutil.uri_extension_hash("stuff")
84 u = uri.CHKFileURI(key=key,
85 uri_extension_hash=uri_extension_hash,
86 needed_shares=needed_shares,
87 total_shares=total_shares,
89 output = self._dump_cap(u.to_string())
90 self.failUnless("CHK File:" in output, output)
91 self.failUnless("key: aaaqeayeaudaocajbifqydiob4" in output, output)
92 self.failUnless("UEB hash: nf3nimquen7aeqm36ekgxomalstenpkvsdmf6fplj7swdatbv5oa" in output, output)
93 self.failUnless("size: 1234" in output, output)
94 self.failUnless("k/N: 25/100" in output, output)
95 self.failUnless("storage index: hdis5iaveku6lnlaiccydyid7q" in output, output)
97 output = self._dump_cap("--client-secret", "5s33nk3qpvnj2fw3z4mnm2y6fa",
99 self.failUnless("client renewal secret: znxmki5zdibb5qlt46xbdvk2t55j7hibejq3i5ijyurkr6m6jkhq" in output, output)
101 output = self._dump_cap(u.get_verifier().to_string())
102 self.failIf("key: " in output, output)
103 self.failUnless("UEB hash: nf3nimquen7aeqm36ekgxomalstenpkvsdmf6fplj7swdatbv5oa" in output, output)
104 self.failUnless("size: 1234" in output, output)
105 self.failUnless("k/N: 25/100" in output, output)
106 self.failUnless("storage index: hdis5iaveku6lnlaiccydyid7q" in output, output)
108 prefixed_u = "http://127.0.0.1/uri/%s" % urllib.quote(u.to_string())
109 output = self._dump_cap(prefixed_u)
110 self.failUnless("CHK File:" in output, output)
111 self.failUnless("key: aaaqeayeaudaocajbifqydiob4" in output, output)
112 self.failUnless("UEB hash: nf3nimquen7aeqm36ekgxomalstenpkvsdmf6fplj7swdatbv5oa" in output, output)
113 self.failUnless("size: 1234" in output, output)
114 self.failUnless("k/N: 25/100" in output, output)
115 self.failUnless("storage index: hdis5iaveku6lnlaiccydyid7q" in output, output)
117 def test_dump_cap_lit(self):
118 u = uri.LiteralFileURI("this is some data")
119 output = self._dump_cap(u.to_string())
120 self.failUnless("Literal File URI:" in output, output)
121 self.failUnless("data: this is some data" in output, output)
123 def test_dump_cap_ssk(self):
124 writekey = "\x01" * 16
125 fingerprint = "\xfe" * 32
126 u = uri.WriteableSSKFileURI(writekey, fingerprint)
128 output = self._dump_cap(u.to_string())
129 self.failUnless("SSK Writeable URI:" in output, output)
130 self.failUnless("writekey: aeaqcaibaeaqcaibaeaqcaibae" in output, output)
131 self.failUnless("readkey: nvgh5vj2ekzzkim5fgtb4gey5y" in output, output)
132 self.failUnless("storage index: nt4fwemuw7flestsezvo2eveke" in output, output)
133 self.failUnless("fingerprint: 737p57x6737p57x6737p57x6737p57x6737p57x6737p57x6737a" in output, output)
135 output = self._dump_cap("--client-secret", "5s33nk3qpvnj2fw3z4mnm2y6fa",
137 self.failUnless("file renewal secret: arpszxzc2t6kb4okkg7sp765xgkni5z7caavj7lta73vmtymjlxq" in output, output)
139 fileutil.make_dirs("cli/test_dump_cap/private")
140 f = open("cli/test_dump_cap/private/secret", "w")
141 f.write("5s33nk3qpvnj2fw3z4mnm2y6fa\n")
143 output = self._dump_cap("--client-dir", "cli/test_dump_cap",
145 self.failUnless("file renewal secret: arpszxzc2t6kb4okkg7sp765xgkni5z7caavj7lta73vmtymjlxq" in output, output)
147 output = self._dump_cap("--client-dir", "cli/test_dump_cap_BOGUS",
149 self.failIf("file renewal secret:" in output, output)
151 output = self._dump_cap("--nodeid", "tqc35esocrvejvg4mablt6aowg6tl43j",
153 self.failUnless("write_enabler: mgcavriox2wlb5eer26unwy5cw56elh3sjweffckkmivvsxtaknq" in output, output)
154 self.failIf("file renewal secret:" in output, output)
156 output = self._dump_cap("--nodeid", "tqc35esocrvejvg4mablt6aowg6tl43j",
157 "--client-secret", "5s33nk3qpvnj2fw3z4mnm2y6fa",
159 self.failUnless("write_enabler: mgcavriox2wlb5eer26unwy5cw56elh3sjweffckkmivvsxtaknq" in output, output)
160 self.failUnless("file renewal secret: arpszxzc2t6kb4okkg7sp765xgkni5z7caavj7lta73vmtymjlxq" in output, output)
161 self.failUnless("lease renewal secret: 7pjtaumrb7znzkkbvekkmuwpqfjyfyamznfz4bwwvmh4nw33lorq" in output, output)
164 output = self._dump_cap(u.to_string())
165 self.failUnless("SSK Read-only URI:" in output, output)
166 self.failUnless("readkey: nvgh5vj2ekzzkim5fgtb4gey5y" in output, output)
167 self.failUnless("storage index: nt4fwemuw7flestsezvo2eveke" in output, output)
168 self.failUnless("fingerprint: 737p57x6737p57x6737p57x6737p57x6737p57x6737p57x6737a" in output, output)
171 output = self._dump_cap(u.to_string())
172 self.failUnless("SSK Verifier URI:" in output, output)
173 self.failUnless("storage index: nt4fwemuw7flestsezvo2eveke" in output, output)
174 self.failUnless("fingerprint: 737p57x6737p57x6737p57x6737p57x6737p57x6737p57x6737a" in output, output)
176 def test_dump_cap_directory(self):
177 writekey = "\x01" * 16
178 fingerprint = "\xfe" * 32
179 u1 = uri.WriteableSSKFileURI(writekey, fingerprint)
180 u = uri.NewDirectoryURI(u1)
182 output = self._dump_cap(u.to_string())
183 self.failUnless("Directory Writeable URI:" in output, output)
184 self.failUnless("writekey: aeaqcaibaeaqcaibaeaqcaibae" in output,
186 self.failUnless("readkey: nvgh5vj2ekzzkim5fgtb4gey5y" in output, output)
187 self.failUnless("storage index: nt4fwemuw7flestsezvo2eveke" in output,
189 self.failUnless("fingerprint: 737p57x6737p57x6737p57x6737p57x6737p57x6737p57x6737a" in output, output)
191 output = self._dump_cap("--client-secret", "5s33nk3qpvnj2fw3z4mnm2y6fa",
193 self.failUnless("file renewal secret: arpszxzc2t6kb4okkg7sp765xgkni5z7caavj7lta73vmtymjlxq" in output, output)
195 output = self._dump_cap("--nodeid", "tqc35esocrvejvg4mablt6aowg6tl43j",
197 self.failUnless("write_enabler: mgcavriox2wlb5eer26unwy5cw56elh3sjweffckkmivvsxtaknq" in output, output)
198 self.failIf("file renewal secret:" in output, output)
200 output = self._dump_cap("--nodeid", "tqc35esocrvejvg4mablt6aowg6tl43j",
201 "--client-secret", "5s33nk3qpvnj2fw3z4mnm2y6fa",
203 self.failUnless("write_enabler: mgcavriox2wlb5eer26unwy5cw56elh3sjweffckkmivvsxtaknq" in output, output)
204 self.failUnless("file renewal secret: arpszxzc2t6kb4okkg7sp765xgkni5z7caavj7lta73vmtymjlxq" in output, output)
205 self.failUnless("lease renewal secret: 7pjtaumrb7znzkkbvekkmuwpqfjyfyamznfz4bwwvmh4nw33lorq" in output, output)
208 output = self._dump_cap(u.to_string())
209 self.failUnless("Directory Read-only URI:" in output, output)
210 self.failUnless("readkey: nvgh5vj2ekzzkim5fgtb4gey5y" in output, output)
211 self.failUnless("storage index: nt4fwemuw7flestsezvo2eveke" in output, output)
212 self.failUnless("fingerprint: 737p57x6737p57x6737p57x6737p57x6737p57x6737p57x6737a" in output, output)
215 output = self._dump_cap(u.to_string())
216 self.failUnless("Directory Verifier URI:" in output, output)
217 self.failUnless("storage index: nt4fwemuw7flestsezvo2eveke" in output, output)
218 self.failUnless("fingerprint: 737p57x6737p57x6737p57x6737p57x6737p57x6737p57x6737a" in output, output)
220 def _catalog_shares(self, *basedirs):
221 o = debug.CatalogSharesOptions()
222 o.stdout,o.stderr = StringIO(), StringIO()
223 args = list(basedirs)
225 debug.catalog_shares(o)
226 out = o.stdout.getvalue()
227 err = o.stderr.getvalue()
230 def test_catalog_shares_error(self):
231 nodedir1 = "cli/test_catalog_shares/node1"
232 sharedir = os.path.join(nodedir1, "storage", "shares", "mq", "mqfblse6m5a6dh45isu2cg7oji")
233 fileutil.make_dirs(sharedir)
234 f = open(os.path.join(sharedir, "8"), "wb")
235 # write a bogus share that looks a little bit like CHK
236 f.write("\x00\x00\x00\x01" + "\xff" * 200) # this triggers an assert
239 nodedir2 = "cli/test_catalog_shares/node2"
240 fileutil.make_dirs(nodedir2)
242 # now make sure that the 'catalog-shares' commands survives the error
243 out, err = self._catalog_shares(nodedir1, nodedir2)
244 self.failUnlessEqual(out, "", out)
245 self.failUnless("Error processing " in err,
246 "didn't see 'error processing' in '%s'" % err)
247 #self.failUnless(nodedir1 in err,
248 # "didn't see '%s' in '%s'" % (nodedir1, err))
249 # windows mangles the path, and os.path.join isn't enough to make
250 # up for it, so just look for individual strings
251 self.failUnless("node1" in err,
252 "didn't see 'node1' in '%s'" % err)
253 self.failUnless("mqfblse6m5a6dh45isu2cg7oji" in err,
254 "didn't see 'mqfblse6m5a6dh45isu2cg7oji' in '%s'" % err)
258 def do_cli(self, verb, *args, **kwargs):
260 "--node-directory", self.getdir("client0"),
262 argv = [verb] + nodeargs + list(args)
263 stdin = kwargs.get("stdin", "")
264 stdout, stderr = StringIO(), StringIO()
265 d = threads.deferToThread(runner.runner, argv, run_by_human=False,
266 stdin=StringIO(stdin),
267 stdout=stdout, stderr=stderr)
269 return stdout.getvalue(), stderr.getvalue()
273 class CreateAlias(SystemTestMixin, CLITestMixin, unittest.TestCase):
275 def _test_webopen(self, args, expected_url):
276 woo = cli.WebopenOptions()
277 all_args = ["--node-directory", self.getdir("client0")] + list(args)
278 woo.parseOptions(all_args)
280 rc = cli.webopen(woo, urls.append)
281 self.failUnlessEqual(rc, 0)
282 self.failUnlessEqual(len(urls), 1)
283 self.failUnlessEqual(urls[0], expected_url)
285 def test_create(self):
286 self.basedir = os.path.dirname(self.mktemp())
287 d = self.set_up_nodes()
288 d.addCallback(lambda res: self.do_cli("create-alias", "tahoe"))
289 def _done((stdout,stderr)):
290 self.failUnless("Alias 'tahoe' created" in stdout)
292 aliases = get_aliases(self.getdir("client0"))
293 self.failUnless("tahoe" in aliases)
294 self.failUnless(aliases["tahoe"].startswith("URI:DIR2:"))
296 d.addCallback(lambda res: self.do_cli("create-alias", "two"))
297 def _stash_urls(res):
298 aliases = get_aliases(self.getdir("client0"))
299 node_url_file = os.path.join(self.getdir("client0"), "node.url")
300 nodeurl = open(node_url_file, "r").read().strip()
301 uribase = nodeurl + "uri/"
302 self.tahoe_url = uribase + urllib.quote(aliases["tahoe"])
303 self.tahoe_subdir_url = self.tahoe_url + "/subdir"
304 self.two_url = uribase + urllib.quote(aliases["two"])
305 d.addCallback(_stash_urls)
307 def _test_urls(junk):
308 self._test_webopen([], self.tahoe_url)
309 self._test_webopen(["/"], self.tahoe_url)
310 self._test_webopen(["tahoe:"], self.tahoe_url)
311 self._test_webopen(["tahoe:/"], self.tahoe_url)
312 self._test_webopen(["tahoe:subdir"], self.tahoe_subdir_url)
313 self._test_webopen(["tahoe:subdir/"], self.tahoe_subdir_url + '/')
314 self._test_webopen(["tahoe:subdir/file"], self.tahoe_subdir_url + '/file')
315 # if "file" is indeed a file, then the url produced by webopen in this
316 # case is disallowed by the webui. but by design, webopen passes through
317 # the mistake from the user to the resultant webopened url
318 self._test_webopen(["tahoe:subdir/file/"], self.tahoe_subdir_url + '/file/')
319 self._test_webopen(["two:"], self.two_url)
320 d.addCallback(_test_urls)
324 class Put(SystemTestMixin, CLITestMixin, unittest.TestCase):
326 def test_unlinked_immutable_stdin(self):
327 # tahoe get `echo DATA | tahoe put`
328 # tahoe get `echo DATA | tahoe put -`
330 self.basedir = self.mktemp()
332 d = self.set_up_nodes()
333 d.addCallback(lambda res: self.do_cli("put", stdin=DATA))
335 (stdout, stderr) = res
336 self.failUnless("waiting for file data on stdin.." in stderr)
337 self.failUnless("200 OK" in stderr)
338 self.readcap = stdout
339 self.failUnless(self.readcap.startswith("URI:CHK:"))
340 d.addCallback(_uploaded)
341 d.addCallback(lambda res: self.do_cli("get", self.readcap))
342 def _downloaded(res):
343 (stdout, stderr) = res
344 self.failUnlessEqual(stderr, "")
345 self.failUnlessEqual(stdout, DATA)
346 d.addCallback(_downloaded)
347 d.addCallback(lambda res: self.do_cli("put", "-", stdin=DATA))
348 d.addCallback(lambda (stdout,stderr):
349 self.failUnlessEqual(stdout, self.readcap))
352 def test_unlinked_immutable_from_file(self):
354 # tahoe put ./file.txt
355 # tahoe put /tmp/file.txt
356 # tahoe put ~/file.txt
357 self.basedir = os.path.dirname(self.mktemp())
358 # this will be "allmydata.test.test_cli/Put/test_put_from_file/RANDOM"
359 # and the RANDOM directory will exist. Raw mktemp returns a filename.
361 rel_fn = os.path.join(self.basedir, "DATAFILE")
362 abs_fn = os.path.abspath(rel_fn)
363 # we make the file small enough to fit in a LIT file, for speed
364 f = open(rel_fn, "w")
365 f.write("short file")
367 d = self.set_up_nodes()
368 d.addCallback(lambda res: self.do_cli("put", rel_fn))
369 def _uploaded((stdout,stderr)):
371 self.failUnless(readcap.startswith("URI:LIT:"))
372 self.readcap = readcap
373 d.addCallback(_uploaded)
374 d.addCallback(lambda res: self.do_cli("put", "./" + rel_fn))
375 d.addCallback(lambda (stdout,stderr):
376 self.failUnlessEqual(stdout, self.readcap))
377 d.addCallback(lambda res: self.do_cli("put", abs_fn))
378 d.addCallback(lambda (stdout,stderr):
379 self.failUnlessEqual(stdout, self.readcap))
380 # we just have to assume that ~ is handled properly
383 def test_immutable_from_file(self):
384 # tahoe put file.txt uploaded.txt
385 # tahoe - uploaded.txt
386 # tahoe put file.txt subdir/uploaded.txt
387 # tahoe put file.txt tahoe:uploaded.txt
388 # tahoe put file.txt tahoe:subdir/uploaded.txt
389 # tahoe put file.txt DIRCAP:./uploaded.txt
390 # tahoe put file.txt DIRCAP:./subdir/uploaded.txt
391 self.basedir = os.path.dirname(self.mktemp())
393 rel_fn = os.path.join(self.basedir, "DATAFILE")
394 abs_fn = os.path.abspath(rel_fn)
395 # we make the file small enough to fit in a LIT file, for speed
397 DATA2 = "short file two"
398 f = open(rel_fn, "w")
402 d = self.set_up_nodes()
403 d.addCallback(lambda res: self.do_cli("create-alias", "tahoe"))
405 d.addCallback(lambda res:
406 self.do_cli("put", rel_fn, "uploaded.txt"))
407 def _uploaded((stdout,stderr)):
408 readcap = stdout.strip()
409 self.failUnless(readcap.startswith("URI:LIT:"))
410 self.failUnless("201 Created" in stderr, stderr)
411 self.readcap = readcap
412 d.addCallback(_uploaded)
413 d.addCallback(lambda res:
414 self.do_cli("get", "tahoe:uploaded.txt"))
415 d.addCallback(lambda (stdout,stderr):
416 self.failUnlessEqual(stdout, DATA))
418 d.addCallback(lambda res:
419 self.do_cli("put", "-", "uploaded.txt", stdin=DATA2))
420 def _replaced((stdout,stderr)):
421 readcap = stdout.strip()
422 self.failUnless(readcap.startswith("URI:LIT:"))
423 self.failUnless("200 OK" in stderr, stderr)
424 d.addCallback(_replaced)
426 d.addCallback(lambda res:
427 self.do_cli("put", rel_fn, "subdir/uploaded2.txt"))
428 d.addCallback(lambda res: self.do_cli("get", "subdir/uploaded2.txt"))
429 d.addCallback(lambda (stdout,stderr):
430 self.failUnlessEqual(stdout, DATA))
432 d.addCallback(lambda res:
433 self.do_cli("put", rel_fn, "tahoe:uploaded3.txt"))
434 d.addCallback(lambda res: self.do_cli("get", "tahoe:uploaded3.txt"))
435 d.addCallback(lambda (stdout,stderr):
436 self.failUnlessEqual(stdout, DATA))
438 d.addCallback(lambda res:
439 self.do_cli("put", rel_fn, "tahoe:subdir/uploaded4.txt"))
440 d.addCallback(lambda res:
441 self.do_cli("get", "tahoe:subdir/uploaded4.txt"))
442 d.addCallback(lambda (stdout,stderr):
443 self.failUnlessEqual(stdout, DATA))
445 def _get_dircap(res):
446 self.dircap = get_aliases(self.getdir("client0"))["tahoe"]
447 d.addCallback(_get_dircap)
449 d.addCallback(lambda res:
450 self.do_cli("put", rel_fn,
451 self.dircap+":./uploaded5.txt"))
452 d.addCallback(lambda res:
453 self.do_cli("get", "tahoe:uploaded5.txt"))
454 d.addCallback(lambda (stdout,stderr):
455 self.failUnlessEqual(stdout, DATA))
457 d.addCallback(lambda res:
458 self.do_cli("put", rel_fn,
459 self.dircap+":./subdir/uploaded6.txt"))
460 d.addCallback(lambda res:
461 self.do_cli("get", "tahoe:subdir/uploaded6.txt"))
462 d.addCallback(lambda (stdout,stderr):
463 self.failUnlessEqual(stdout, DATA))
467 def test_mutable_unlinked(self):
468 # FILECAP = `echo DATA | tahoe put --mutable`
469 # tahoe get FILECAP, compare against DATA
470 # echo DATA2 | tahoe put - FILECAP
471 # tahoe get FILECAP, compare against DATA2
472 # tahoe put file.txt FILECAP
473 self.basedir = os.path.dirname(self.mktemp())
476 rel_fn = os.path.join(self.basedir, "DATAFILE")
477 abs_fn = os.path.abspath(rel_fn)
478 DATA3 = "three" * 100
479 f = open(rel_fn, "w")
483 d = self.set_up_nodes()
485 d.addCallback(lambda res: self.do_cli("put", "--mutable", stdin=DATA))
487 (stdout, stderr) = res
488 self.failUnless("waiting for file data on stdin.." in stderr)
489 self.failUnless("200 OK" in stderr)
490 self.filecap = stdout
491 self.failUnless(self.filecap.startswith("URI:SSK:"))
492 d.addCallback(_created)
493 d.addCallback(lambda res: self.do_cli("get", self.filecap))
494 d.addCallback(lambda (out,err): self.failUnlessEqual(out, DATA))
496 d.addCallback(lambda res: self.do_cli("put", "-", self.filecap, stdin=DATA2))
498 (stdout, stderr) = res
499 self.failUnless("waiting for file data on stdin.." in stderr)
500 self.failUnless("200 OK" in stderr)
501 self.failUnlessEqual(self.filecap, stdout)
502 d.addCallback(_replaced)
503 d.addCallback(lambda res: self.do_cli("get", self.filecap))
504 d.addCallback(lambda (out,err): self.failUnlessEqual(out, DATA2))
506 d.addCallback(lambda res: self.do_cli("put", rel_fn, self.filecap))
508 (stdout, stderr) = res
509 self.failUnless("200 OK" in stderr)
510 self.failUnlessEqual(self.filecap, stdout)
511 d.addCallback(_replaced2)
512 d.addCallback(lambda res: self.do_cli("get", self.filecap))
513 d.addCallback(lambda (out,err): self.failUnlessEqual(out, DATA3))
517 def test_mutable(self):
518 # echo DATA1 | tahoe put --mutable - uploaded.txt
519 # echo DATA2 | tahoe put - uploaded.txt # should modify-in-place
520 # tahoe get uploaded.txt, compare against DATA2
522 self.basedir = os.path.dirname(self.mktemp())
524 fn1 = os.path.join(self.basedir, "DATA1")
529 fn2 = os.path.join(self.basedir, "DATA2")
534 d = self.set_up_nodes()
535 d.addCallback(lambda res: self.do_cli("create-alias", "tahoe"))
536 d.addCallback(lambda res:
537 self.do_cli("put", "--mutable", fn1, "tahoe:uploaded.txt"))
538 d.addCallback(lambda res:
539 self.do_cli("put", fn2, "tahoe:uploaded.txt"))
540 d.addCallback(lambda res:
541 self.do_cli("get", "tahoe:uploaded.txt"))
542 d.addCallback(lambda (out,err): self.failUnlessEqual(out, DATA2))