def setUp(self): """ Create a L{PantheonRealm} pointed at a mock authentication service with some simple site and user information. """ FakeBackendMixin.setUp(self) self.realm = PantheonRealm( reactor, '127.0.0.1', self.server.port.getHost().port, SSL_KEY.path, SSL_CERT.path)
class PantheonRealmTests(FakeBackendMixin, TestCase): """ Tests for L{PantheonRealm} which authorizes clients by creating suitable local user objects for them. """ def setUp(self): """ Create a L{PantheonRealm} pointed at a mock authentication service with some simple site and user information. """ FakeBackendMixin.setUp(self) self.realm = PantheonRealm( reactor, '127.0.0.1', self.server.port.getHost().port, SSL_KEY.path, SSL_CERT.path) def test_interface(self): """ A L{PantheonRealm} instance provides L{IRealm}. """ self.assertTrue(verifyObject(IRealm, self.realm)) def test_requestAvatar(self): """ L{PantheonRealm.requestAvatar} returns a L{Deferred} which fires with a L{PantheonSite} configured with command execution parameters specific to the site requested. """ d = self.realm.requestAvatar('example.com', None, IConchUser) def cbAvatar((interface, avatar, logout)): self.assertIdentical(IConchUser, interface) self.assertIsInstance(avatar, PantheonSite) self.assertEqual(self.cwd, avatar.cwd) self.assertEqual(self.uid, avatar.uid) d.addCallback(cbAvatar) return d