@defer.inlineCallbacks
    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='test_password')
        ))

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

        cm.set('pipelines.test_pipeline', [{'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')
dataset/ETHPy150Open foundit/Piped/piped/providers/test/test_spread_provider.py/PBClientTest.test_manual_login/original