def test_add_directory_entry(self):
        """
        Adding a capability to a mutable directory
        """
        content = b"content " * 200
        http_client = create_tahoe_treq_client()
        tahoe_client = create_tahoe_client(
            DecodedURL.from_text(u"http://example.com/"),
            http_client,
        )

        # first create a mutable directory
        mut_cap = yield tahoe_client.create_mutable_directory()

        # create an immutable and link it into the directory
        file_cap = yield tahoe_client.create_immutable(content)
        yield tahoe_client.add_entry_to_mutable_directory(
            mut_cap, u"foo", file_cap)

        # prove we can access the expected file via a GET
        uri = DecodedURL.from_text(u"http://example.com/uri/")
        uri = uri.child(mut_cap.danger_real_capability_string(), u"foo")
        resp = http_client.get(uri.to_uri().to_text())

        self.assertThat(resp, succeeded(MatchesStructure(code=Equals(200), )))
        self.assertThat(
            resp.result.content(),
            succeeded(Equals(content)),
        )
示例#2
0
    def setUp(self):
        super(TestTahoeMonitor, self).setUp()

        self.root = create_fake_tahoe_root()
        self.http_client = create_tahoe_treq_client(self.root)
        self.tahoe_client = create_tahoe_client(
            DecodedURL.from_text(u"http://example.com"),
            self.http_client,
        )

        self.node = self.useFixture(NodeDirectory(FilePath(self.mktemp())))
        # when the "service" is run it wants to check shares-happy from Tahoe
        with self.node.tahoe_cfg.open("w") as f:
            f.write(b"[client]\nshares.happy = 1\n")
        self.basedir = FilePath(self.mktemp())
        self.config = create_global_configuration(
            self.basedir,
            u"tcp:0",
            self.node.path,
            u"tcp:localhost:0",
        )
        self.reactor = MemoryReactorClock()
        self.service = MagicFolderService(
            self.reactor,
            self.config,
            WebSocketStatusService(self.reactor, self.config),
            self.tahoe_client,
        )
示例#3
0
    def setUp(self):
        super(TestAdd, self).setUp()

        self.root = create_fake_tahoe_root()
        self.http_client = create_tahoe_treq_client(self.root)
        self.tahoe_client = create_tahoe_client(
            DecodedURL.from_text(u"http://example.com"),
            self.http_client,
        )
        self.magic_dir = FilePath(self.mktemp())
        self.magic_dir.makedirs()

        self.node = self.useFixture(NodeDirectory(FilePath(self.mktemp())))
        self.basedir = FilePath(self.mktemp())
        self.config = create_global_configuration(
            self.basedir,
            u"tcp:5555",
            self.node.path,
            u"tcp:localhost:5555",
        )
        clock = Clock()
        self.service = MagicFolderService(
            clock,
            self.config,
            WebSocketStatusService(clock, self.config),
            self.tahoe_client,
        )
示例#4
0
 def setup_example(self):
     self.root = create_fake_tahoe_root()
     self.http_client = create_tahoe_treq_client(self.root)
     self.tahoe_client = create_tahoe_client(
         DecodedURL.from_text(u"http://example.com"),
         self.http_client,
     )
     self.alice = create_local_author(u"alice")
     self.stash_dir = FilePath(mktemp())
     self.stash_dir.makedirs()  # 'trial' will delete this when done
示例#5
0
 def tahoe_client(self):
     config = self.global_config()
     return create_tahoe_client(
         config.tahoe_client_url,
         HTTPClient(Agent(self.reactor)),
     )