Exemplo n.º 1
0
    def test_manual_login(self):
        self.runtime_environment.configure()
        cm = self.runtime_environment.configuration_manager
        dm = self.runtime_environment.dependency_manager

        self.create_pb_server(checker=dict(
            name = 'twisted.cred.checkers.InMemoryUsernamePasswordDatabaseDontUse',
            arguments = dict(test_username='******')
        ))

        cm.set('pb.clients.test_no_login', dict(
            endpoint = 'tcp:host=localhost:port=%i'%self.port,
        ))

        cm.set('pipelines.test_pipeline', [{'processor':'eval-lambda', 'lambda': 'baton: baton["deferred"].callback("logged in as %s"%baton["avatar_id"])'}])
        pp = pipeline_provider.PipelineProvider()
        pp.configure(self.runtime_environment)

        self.application.startService()
        self.addCleanup(self.application.stopService)

        client_provider = spread_provider.PBClientProvider()
        client_provider.configure(self.runtime_environment)

        client_no_login_root_dependency = dm.add_dependency(self, dict(provider='pb.client.test_no_login.root_object'))
        dm.resolve_initial_states()

        # if the client does not login, it will get a RemoteReference to a PortalWrapper
        # which can be used to perform the login "manually"
        no_login_root = yield client_no_login_root_dependency.wait_for_resource()

        challenge, challenger = yield no_login_root.callRemote('login', 'test_username')
        perspective = yield challenger.callRemote('respond', pb.respond(challenge, 'test_password'), mind=None)
        result = yield perspective.callRemote('any')
        self.assertEquals(result, 'logged in as test_username')
Exemplo n.º 2
0
    def testWrongPassword(self):
        # client is asked to respond, so generate the response
        response = tpb.respond(self.challenge, 'wrong')
        d = self.challenger.remote_respond(response, None)

        def wrongPasswordErrback(wrongpasserror):
            self.assert_(isinstance(wrongpasserror.type(),
                                    errors.NotAuthenticatedError))

        d.addErrback(wrongPasswordErrback)
        return d
Exemplo n.º 3
0
    def testWrongPassword(self):
        # client is asked to respond, so generate the response
        response = tpb.respond(self.challenge, 'wrong')
        d = self.challenger.remote_respond(response, None)

        def wrongPasswordErrback(wrongpasserror):
            self.assert_(
                isinstance(wrongpasserror.type(),
                           errors.NotAuthenticatedError))

        d.addErrback(wrongPasswordErrback)
        return d
Exemplo n.º 4
0
    def testRightPassword(self):
        # client is asked to respond, so generate the response
        response = tpb.respond(self.challenge, 'password')

        self.challenger.remote_respond(response, None)
Exemplo n.º 5
0
    def testRightPassword(self):
        # client is asked to respond, so generate the response
        response = tpb.respond(self.challenge, 'password')

        self.challenger.remote_respond(response, None)