Пример #1
0
 def test_bad_client_name(self):
     with self.assertRaises(ValueError) as ctx:
         FilesystemAuthenticatedOnionService(
             self.config, self.thedir, ["80 127.0.0.1:1234"],
             auth=AuthBasic(["bob can't have spaces"]),
         )
     self.assertIn(
         "can't have spaces",
         str(ctx.exception),
     )
Пример #2
0
 def test_unknown_auth_type(self):
     with self.assertRaises(ValueError) as ctx:
         FilesystemAuthenticatedOnionService(
             self.config, self.thedir, ["80 127.0.0.1:1234"],
             auth=object(),
         )
     self.assertIn(
         "must be one of AuthBasic or AuthStealth",
         str(ctx.exception),
     )
Пример #3
0
 def setUp(self):
     self.thedir = self.mktemp()
     os.mkdir(self.thedir)
     protocol = FakeControlProtocol([])
     self.config = TorConfig(protocol)
     self.hs = FilesystemAuthenticatedOnionService(
         config=self.config,
         thedir=self.thedir,
         ports=["80 127.0.0.1:1234"],
         auth=AuthBasic(['foo', 'bar']))
Пример #4
0
    def test_get_client_expected_not_found(self):
        self.hs = FilesystemAuthenticatedOnionService(
            self.config, self.thedir, ["80 127.0.0.1:1234"],
            auth=AuthBasic(["foo", "bar", "baz"]),
        )
        with open(join(self.thedir, "hostname"), "w") as f:
            f.write(
                "foo.onion fooauthtoken # client: foo\n"
                "bar.onion barauthtoken # client: bar\n"
            )

        with self.assertRaises(RuntimeError) as ctx:
            self.hs.get_client("baz")
        self.assertIn(
            "Didn't find expected client",
            str(ctx.exception),
        )