def test_baseOffering(self): """ L{Mantissa.installSite} installs the Mantissa base offering. """ options = Mantissa() options.installSite(self.siteStore, u"example.com", u"", False) self.assertEqual(IOfferingTechnician(self.siteStore).getInstalledOfferingNames(), [baseOffering.name])
def test_hostname(self): """ L{Mantissa.installSite} sets the C{hostname} of the L{SiteConfiguration} to the domain name it is called with. """ options = Mantissa() options.installSite(self.siteStore, u"example.net", u"", False) site = self.siteStore.findUnique(SiteConfiguration) self.assertEqual(site.hostname, u"example.net")
def test_baseOffering(self): """ L{Mantissa.installSite} installs the Mantissa base offering. """ options = Mantissa() options.installSite(self.siteStore, u"example.com", u"", False) self.assertEqual( IOfferingTechnician(self.siteStore).getInstalledOfferingNames(), [baseOffering.name])
def test_rotate(self): """ The C{keyrotate} subcommand replaces the host key with a new one. """ options = Mantissa() options.parent = self options.installSite(self.store, u'example.com', u'', False) oldKey = self.store.findUnique(SecureShellConfiguration).hostKey options.parseOptions(['ssh', 'keyrotate']) newKey = self.store.findUnique(SecureShellConfiguration).hostKey self.assertNotEqual(oldKey, newKey)
def setUp(self): """ Create a site store containing an admin user, then do implementation-specific setup. """ self.siteStore = Store(filesdir=self.mktemp()) m = Mantissa() m.installSite(self.siteStore, u"localhost", u"", False) m.installAdmin(self.siteStore, u'admin', u'localhost', u'asdf') self.loginSystem = self.siteStore.findUnique(LoginSystem) self.adminStore = self.loginSystem.accountByAddress( u'admin', u'localhost').avatars.open() self.setupPageFactory()
def test_sshPorts(self): """ L{Mantissa.installSite} creates a TCP port for the L{SecureShellConfiguration} which comes with the base offering it installs. """ options = Mantissa() options.installSite(self.siteStore, u"example.com", u"", False) shell = self.siteStore.findUnique(SecureShellConfiguration) tcps = list(self.siteStore.query(TCPPort, TCPPort.factory == shell)) self.assertEqual(len(tcps), 1) self.assertEqual(tcps[0].portNumber, 8022)
def test_adminRedirect(self): """ When the admin redirect is installed on a store, it should return an URL which should redirect to /private. """ s = Store(self.mktemp()) s.powerUp(self.adminpage.RedirectPlugin(store=s)) m = Mantissa() m.installSite(s, u'localhost', u'', False) root = IMantissaSite(s) viewer = StubViewer() result, segments = root.siteProduceResource(FakeRequest(), tuple(['admin.php']), viewer) self.assertEquals(result, URL.fromString("http://localhost/private"))
def test_produceAboutResource(self): """ When C{AboutPlugin} is installed on a site store created by 'axiomatic mantissa', requests for 'about.php' will be responded to by a helpful message wrapped in a shell page. """ s = Store(self.mktemp()) s.powerUp(self.aboutpage.AboutPlugin(store=s)) m = Mantissa() m.installSite(s, u"localhost", u"", False) root = IMantissaSite(s) viewer = StubViewer() result, segments = root.siteProduceResource(FakeRequest(), tuple(['about.php']), viewer) self.assertIdentical(result, viewer.shell) self.assertIsInstance(result.model, self.aboutpage.AboutText)
def test_httpPorts(self): """ L{Mantissa.installSite} creates a TCP port and an SSL port for the L{SiteConfiguration} which comes with the base offering it installs. """ options = Mantissa() options.installSite(self.siteStore, u"example.com", u"", False) site = self.siteStore.findUnique(SiteConfiguration) tcps = list(self.siteStore.query(TCPPort, TCPPort.factory == site)) ssls = list(self.siteStore.query(SSLPort, SSLPort.factory == site)) self.assertEqual(len(tcps), 1) self.assertEqual(tcps[0].portNumber, 8080) self.assertEqual(len(ssls), 1) self.assertEqual(ssls[0].portNumber, 8443) self.assertNotEqual(ssls[0].certificatePath, None)