Ejemplo n.º 1
0
    def test_connect_without_password(self):
        from deluge.ui import common
        username, password = common.get_localhost_auth()
        d = client.connect("localhost", 58846, username=username)

        def on_failure(failure):
            self.assertEqual(failure.trap(error.AuthenticationRequired),
                             error.AuthenticationRequired)
            self.assertEqual(failure.value.username, username)
            self.addCleanup(client.disconnect)

        d.addErrback(on_failure)
        return d
Ejemplo n.º 2
0
    def test_connect_localclient(self):
        from deluge.ui import common
        username, password = common.get_localhost_auth()
        d = client.connect(
            "localhost", 58846, username=username, password=password
        )

        def on_connect(result):
            self.assertEqual(client.get_auth_level(), AUTH_LEVEL_ADMIN)
            self.addCleanup(client.disconnect)
            return result

        d.addCallback(on_connect)
        return d
Ejemplo n.º 3
0
    def test_connect_localclient(self):
        from deluge.ui import common
        username, password = common.get_localhost_auth()
        d = client.connect("localhost",
                           58846,
                           username=username,
                           password=password)

        def on_connect(result):
            self.assertEqual(client.get_auth_level(), AUTH_LEVEL_ADMIN)
            self.addCleanup(client.disconnect)
            return result

        d.addCallback(on_connect)
        return d
Ejemplo n.º 4
0
    def test_connect_bad_password(self):
        from deluge.ui import common
        username, password = common.get_localhost_auth()
        d = client.connect("localhost",
                           58846,
                           username=username,
                           password=password + '1')

        def on_failure(failure):
            self.assertEqual(failure.trap(error.BadLoginError),
                             error.BadLoginError)
            self.addCleanup(client.disconnect)

        d.addErrback(on_failure)
        return d
Ejemplo n.º 5
0
    def test_connect_without_sending_client_version_fails(self):
        from deluge.ui import common
        username, password = common.get_localhost_auth()
        no_version_sending_client = NoVersionSendingClient()
        d = no_version_sending_client.connect("localhost",
                                              58846,
                                              username=username,
                                              password=password)

        def on_failure(failure):
            self.assertEqual(failure.trap(error.IncompatibleClient),
                             error.IncompatibleClient)
            self.addCleanup(no_version_sending_client.disconnect)

        d.addErrback(on_failure)
        return d
Ejemplo n.º 6
0
    def test_connect_bad_password(self):
        from deluge.ui import common
        username, password = common.get_localhost_auth()
        d = client.connect(
            "localhost", 58846, username=username, password=password+'1'
        )

        def on_failure(failure):
            self.assertEqual(
                failure.trap(error.BadLoginError),
                error.BadLoginError
            )
            self.addCleanup(client.disconnect)

        d.addErrback(on_failure)
        return d
Ejemplo n.º 7
0
    def test_connect_without_sending_client_version_fails(self):
        from deluge.ui import common
        username, password = common.get_localhost_auth()
        no_version_sending_client = NoVersionSendingClient()
        d = no_version_sending_client.connect(
            "localhost", 58846, username=username, password=password
        )

        def on_failure(failure):
            self.assertEqual(
                failure.trap(error.IncompatibleClient),
                error.IncompatibleClient
            )
            self.addCleanup(no_version_sending_client.disconnect)

        d.addErrback(on_failure)
        return d
Ejemplo n.º 8
0
    def test_connect_without_password(self):
        from deluge.ui import common
        username, password = common.get_localhost_auth()
        d = client.connect(
            "localhost", 58846, username=username
        )

        def on_failure(failure):
            self.assertEqual(
                failure.trap(error.AuthenticationRequired),
                error.AuthenticationRequired
            )
            self.assertEqual(failure.value.username, username)
            self.addCleanup(client.disconnect)

        d.addErrback(on_failure)
        return d
Ejemplo n.º 9
0
 def test_authorize(self):
     from deluge.ui import common
     self.assertEquals(self.auth.authorize(*common.get_localhost_auth()),
                       AUTH_LEVEL_ADMIN)
Ejemplo n.º 10
0
 def test_authorize(self):
     from deluge.ui import common
     self.assertEquals(
         self.auth.authorize(*common.get_localhost_auth()),
         AUTH_LEVEL_ADMIN
     )