コード例 #1
0
 def test_appStoreLinkTo(self):
     """
     When L{websharing.linkTo} is called on a shared item in an app store,
     it returns an URL with a single path segment consisting of the app's
     name.
     """
     s = Store(dbdir=self.mktemp())
     Mantissa().installSite(s, u"localhost", u"", False)
     Mantissa().installAdmin(s, u'admin', u'localhost', u'asdf')
     off = offering.Offering(
         name=u'test_offering',
         description=u'Offering for creating a sample app store',
         siteRequirements=[],
         appPowerups=[TestAppPowerup],
         installablePowerups=[],
         loginInterfaces=[],
         themes=[],
     )
     userbase = s.findUnique(LoginSystem)
     adminAccount = userbase.accountByAddress(u'admin', u'localhost')
     conf = adminAccount.avatars.open().findUnique(
         offering.OfferingConfiguration)
     conf.installOffering(off, None)
     ss = userbase.accountByAddress(off.name, None).avatars.open()
     sharedItem = sharing.getEveryoneRole(ss).getShare(
         websharing.getDefaultShareID(ss))
     linkURL = websharing.linkTo(sharedItem)
     self.failUnless(
         isinstance(linkURL, url.URL),
         "linkTo should return a nevow.url.URL, not %r" % (type(linkURL)))
     self.assertEquals(str(linkURL), '/test_offering/')
コード例 #2
0
    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])
コード例 #3
0
 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")
コード例 #4
0
ファイル: test_mantissacmd.py プロジェクト: twisted/mantissa
 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")
コード例 #5
0
    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])
コード例 #6
0
 def setUp(self):
     self.siteStore = Store(filesdir=self.mktemp())
     Mantissa().installSite(self.siteStore, u"localhost", u"", False)
     Mantissa().installAdmin(self.siteStore, u'admin', u'localhost', '')
     self.loginSystem = self.siteStore.findUnique(LoginSystem)
     self.adminStore = self.loginSystem.accountByAddress(
         u'admin', u'localhost').avatars.open()
     sc = self.adminStore.findUnique(signup.SignupConfiguration)
     self.signup = sc.createSignup(
         u'testuser@localhost', signup.UserInfoSignup, {'prefixURL': u''},
         product.Product(store=self.siteStore, types=[]), u'', u'')
コード例 #7
0
ファイル: test_mantissacmd.py プロジェクト: twisted/mantissa
 def test_commonName(self):
     """
     C{axiomatic mantissa} generates an SSL certificate with the domain part
     of the admin username as its common name.
     """
     m = Mantissa()
     m.parent = self
     self.dbdir = self.mktemp()
     self.store = Store(filesdir=FilePath(self.dbdir).child("files").path)
     m.parseOptions(['--admin-user', '*****@*****.**', '--admin-password', 'foo'])
     cert = self._getCert()
     self.assertEqual(cert.getSubject().commonName, "example.com")
コード例 #8
0
ファイル: test_webshell.py プロジェクト: fusionapp/mantissa
 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()
コード例 #9
0
 def test_commonName(self):
     """
     C{axiomatic mantissa} generates an SSL certificate with the domain part
     of the admin username as its common name.
     """
     m = Mantissa()
     m.parent = self
     self.dbdir = self.mktemp()
     self.store = Store(filesdir=FilePath(self.dbdir).child("files").path)
     m.parseOptions(
         ['--admin-user', '*****@*****.**', '--admin-password', 'foo'])
     cert = self._getCert()
     self.assertEqual(cert.getSubject().commonName, "example.com")
コード例 #10
0
 def setUp(self):
     """
     Create a store as described in the test case docstring.
     """
     site = Store(self.mktemp())
     Mantissa().installSite(site, u"example.com", u"", False)
     Mantissa().installAdmin(site, u'admin', u'example.com', u'asdf')
     anonsite = site.findUnique(AnonymousSite)
     user = site.findUnique(LoginSystem).accountByAddress(
         u"admin", u"example.com").avatars.open()
     self.website = user.findUnique(WebSite)
     self.privapp = user.findUnique(PrivateApplication)
     self.site = site
コード例 #11
0
    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)
コード例 #12
0
ファイル: test_mantissacmd.py プロジェクト: twisted/mantissa
    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)
コード例 #13
0
 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"))
コード例 #14
0
 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"))
コード例 #15
0
    def setUp(self):
        """
        Create a L{Store} with a L{WebSite} in it.  Get a protocol factory from
        the website and save it for tests to use.  Patch L{twisted.web.http}
        and L{nevow.guard} so that they don't create garbage timed calls that
        have to be cleaned up.
        """
        self.store = Store(filesdir=self.mktemp())  # See #2484
        Mantissa().installSite(self.store, self.domain, u'',
                               False)  # See #2483
        self.site = self.store.findUnique(SiteConfiguration)
        self.login = self.store.findUnique(LoginSystem)

        # Ports should be offering installation parameters.  This assumes a
        # TCPPort and an SSLPort are created by Mantissa.installSite. See
        # #538.  -exarkun
        self.store.query(SSLPort,
                         SSLPort.factory == self.site).deleteFromStore()

        self.factory = self.site.getFactory()

        self.origFunctions = (http._logDateTimeStart,
                              GuardSession.checkExpired.im_func,
                              athena.ReliableMessageDelivery)
        http._logDateTimeStart = lambda: None
        GuardSession.checkExpired = lambda self: None
        athena.ReliableMessageDelivery = lambda *a, **kw: None
コード例 #16
0
ファイル: test_admin.py プロジェクト: jonathanj/mantissa
    def setUp(self):
        """
        Construct a site and user store with an administrator that can invoke the
        web administrative tools, setting the instance variables described in
        this class's docstring.
        """
        self.siteStore = Store(filesdir=self.mktemp())
        Mantissa().installSite(self.siteStore, u"localhost", u"", False)
        Mantissa().installAdmin(self.siteStore, u'admin', u'localhost', u'asdf')

        self.siteMethod = self.siteStore.findUnique(
            LoginMethod, LoginMethod.localpart == u'admin')
        self.siteAccount = self.siteMethod.account
        userStore = self.siteAccount.avatars.open()
        lub = userStore.findUnique(LocalUserBrowser)
        self.localUserBrowserFragment = LocalUserBrowserFragment(lub)
コード例 #17
0
    def test_buildTerminalProtocol(self):
        """
        L{ImaginaryApp.buildTerminalProtocol} returns a
        L{CharacterSelectionTextServer} instance with a role representing the
        store it is in, a reference to the L{ImaginaryWorld} installed on the
        Imaginary application store, and a list of L{Thing} items shared to the
        role.
        """
        # XXX This is too many stores for a unit test to need to create.
        siteStore = Store(filesdir=FilePath(self.mktemp()))
        Mantissa().installSite(siteStore, u'example.com', u'', False)
        installOffering(siteStore, imaginaryOffering, {})
        login = siteStore.findUnique(LoginSystem)
        account = login.addAccount(u'alice', u'example.com', u'password')
        userStore = account.avatars.open()

        app = ImaginaryApp(store=userStore)
        installOn(app, userStore)

        imaginary = login.accountByAddress(u'Imaginary', None).avatars.open()
        world = imaginary.findUnique(ImaginaryWorld)

        # Alice connects to her own ImaginaryApp (all that is possible at the
        # moment).
        viewer = _AuthenticatedShellViewer(getAccountNames(userStore))
        proto = app.buildTerminalProtocol(viewer)
        self.assertIdentical(proto.world, world)
        self.assertEqual(proto.role.externalID, u'*****@*****.**')
        self.assertEqual(proto.choices, [])
コード例 #18
0
 def makeLivePage(self):
     """
     Create a MantissaLivePage instance for testing.
     """
     siteStore = Store(filesdir=self.mktemp())
     Mantissa().installSite(siteStore, self.hostname.decode('ascii'), u"",
                            False)
     return MantissaLivePage(ISiteURLGenerator(siteStore))
コード例 #19
0
ファイル: test_mantissacmd.py プロジェクト: twisted/mantissa
    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)
コード例 #20
0
 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)
コード例 #21
0
    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)
コード例 #22
0
 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)
コード例 #23
0
        def siteStoreTxn():
            Mantissa().installSite(self.siteStore, self.userinfo[1], u"",
                                   False)
            ticketed = signup.FreeTicketSignup(store=self.siteStore,
                                               prefixURL=self.signupURL,
                                               prompt=self.signupPrompt)
            signup._SignupTracker(store=self.siteStore, signupItem=ticketed)

            return Create().addAccount(self.siteStore, self.userinfo[0],
                                       self.userinfo[1],
                                       u'password').avatars.open()
コード例 #24
0
    def setUp(self):
        self.siteStore = Store(filesdir=self.mktemp())
        Mantissa().installSite(self.siteStore, u"example.com", u"", False)

        self.userAccount = Create().addAccount(
            self.siteStore, u'testuser', u'example.com', u'password')
        self.userStore = self.userAccount.avatars.open()

        self.privapp = PrivateApplication(store=self.userStore)
        installOn(self.privapp, self.userStore)
        self.webViewer = IWebViewer(self.userStore)
コード例 #25
0
ファイル: test_offering.py プロジェクト: jonathanj/mantissa
 def setUp(self):
     self.store = Store(filesdir=self.mktemp())
     Mantissa().installSite(self.store, u"localhost", u"", False)
     Mantissa().installAdmin(self.store, u'admin', u'localhost', u'asdf')
     self.userbase = self.store.findUnique(userbase.LoginSystem)
     self.adminAccount = self.userbase.accountByAddress(
         u'admin', u'localhost')
     off = offering.Offering(
         name=u'test_offering',
         description=u'This is an offering which tests the offering '
         'installation mechanism',
         siteRequirements=[(ITestInterface, TestSiteRequirement)],
         appPowerups=[TestAppPowerup],
         installablePowerups=[],
         loginInterfaces=[],
         themes=[],
     )
     self.offering = off
     # Add this somewhere that the plugin system is going to see it.
     self._originalGetOfferings = offering.getOfferings
     offering.getOfferings = self.fakeGetOfferings
コード例 #26
0
ファイル: test_web.py プロジェクト: jonathanj/mantissa
        def _tx():
            Mantissa().installSite(self.store, self.domain, u'', False)
            self.site = self.store.findUnique(SiteConfiguration)
            self.login = self.store.findUnique(LoginSystem)

            # Ports should be offering installation parameters.  This assumes a
            # TCPPort and an SSLPort are created by Mantissa.installSite. See
            # #538.  -exarkun
            self.store.query(SSLPort,
                             SSLPort.factory == self.site).deleteFromStore()

            self.factory = self.site.getFactory()
コード例 #27
0
 def setUp(self):
     """
     Create a L{Store}, L{WebSite} and necessary request-related objects to
     test L{LoginPage}.
     """
     self.siteStore = Store(filesdir=self.mktemp())
     Mantissa().installSite(self.siteStore, self.domain, u"", False)
     self.site = self.siteStore.findUnique(SiteConfiguration)
     installOn(
         TCPPort(store=self.siteStore, factory=self.site, portNumber=80),
         self.siteStore)
     self.context = WebContext()
     self.request = FakeRequest()
     self.context.remember(self.request)
コード例 #28
0
    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)
コード例 #29
0
    def setUp(self):
        """
        Create a site store and a user store with the L{Focus} powerup.
        """
        # Make the site store within which the test user will be created.
        self.dbdir = self.mktemp()
        self.siteStore = Store(self.dbdir)
        Mantissa().installSite(self.siteStore, u'example.com', u"", False)

        # Create a store for the user which is set up appropriately.
        self.userAccount = Create().addAccount(self.siteStore, u'testuser',
                                               u'example.com', u'password')
        self.userStore = self.userAccount.avatars.open()
        self.focus = Focus(store=self.userStore)
        installOn(self.focus, self.userStore)
コード例 #30
0
def createDatabase(store):
    """
    Initialize the given Store for use as a Mantissa webserver.
    """
    Mantissa().installSite(store, u'')
    site = store.findUnique(WebSite)
    site.portNumber = 8088
    site.securePortNumber = 6443
    site.certificateFile = 'server.pem'
    store.dbdir.child('server.pem').setContent(cert)
    site.httpLog = 'path/to/httpd.log'
    site.hitCount = 123
    site.hostname = u'example.net'
    loginSystem = store.findUnique(LoginSystem)
    account = loginSystem.addAccount(u'testuser', u'localhost', None)
    subStore = account.avatars.open()
    installOn(WebSite(store=subStore, hitCount=321), subStore)
コード例 #31
0
    def test_stylesheetLocation(self):
        """
        L{XHTMLDirectoryTheme.head} returns a link tag which gives the location
        of the stylesheet given by I{stylesheetLocation} if there is one.
        """
        siteStore = Store(filesdir=self.mktemp())
        Mantissa().installSite(siteStore, u"example.com", u"", False)
        site = ISiteURLGenerator(siteStore)

        self.theme.stylesheetLocation = ['foo', 'bar']
        request = FakeRequest()
        link = self.theme.head(request, site)
        self.assertEqual(link.tagName, 'link')
        self.assertEqual(link.attributes['rel'], 'stylesheet')
        self.assertEqual(link.attributes['type'], 'text/css')
        self.assertEqual(
            site.rootURL(request).child('foo').child('bar'),
            link.attributes['href'])
コード例 #32
0
def createDatabase(store):
    """
    Initialize the given Store for use as a Mantissa webserver.
    """
    Mantissa().installSite(store, u'example.net')
    site = store.findUnique(WebSite)
    site.httpLog = store.filesdir.child('httpd.log').path
    site.hitCount = 123
    site.hostname = u'example.net'
    tcp = store.findUnique(TCPPort, TCPPort.factory == site)
    tcp.portNumber = 8088
    ssl = store.findUnique(SSLPort, SSLPort.factory == site)
    ssl.portNumber = 6443
    ssl.certificatePath.setContent(cert)
    loginSystem = store.findUnique(LoginSystem)
    account = loginSystem.addAccount(u'testuser', u'localhost', None)
    subStore = account.avatars.open()
    installOn(WebSite(store=subStore, hitCount=321), subStore)
コード例 #33
0
ファイル: test_mantissacmd.py プロジェクト: twisted/mantissa
    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)
コード例 #34
0
    def setUp(self):
        self.siteStore = Store(filesdir=self.mktemp())
        Mantissa().installSite(self.siteStore, u'example.com', u"", False)
        self.loginSystem = self.siteStore.findUnique(LoginSystem)

        userAccount = self.loginSystem.addAccount(u'alice', u'example.com',
                                                  u'password')
        self.userStore = userAccount.avatars.open()

        product = Product(
            store=self.siteStore,
            types=[qual(hyperbola_model.HyperbolaPublicPresence)])
        product.installProductOn(self.userStore)
        self.publicPresence = self.userStore.findUnique(
            hyperbola_model.HyperbolaPublicPresence)

        self.me = Role(store=self.userStore,
                       externalID=u'*****@*****.**',
                       description=u'foobar')
        self.you = Role(store=self.userStore,
                        externalID=u'*****@*****.**',
                        description=u'rad yo')

        blog = self.blog = hyperblurb.Blurb(store=self.userStore,
                                            title=u"Hello World",
                                            body=u"Hello World!~!!",
                                            author=self.me,
                                            hits=0,
                                            dateCreated=Time(),
                                            dateLastEdited=Time(),
                                            flavor=hyperblurb.FLAVOR.BLOG)

        blog.permitChildren(self.me, hyperblurb.FLAVOR.BLOG_POST,
                            ihyperbola.ICommentable)
        blog.permitChildren(self.me, hyperblurb.FLAVOR.BLOG_COMMENT,
                            ihyperbola.ICommentable)
        blog.permitChildren(self.you, hyperblurb.FLAVOR.BLOG_POST,
                            ihyperbola.ICommentable)
        blog.permitChildren(self.you, hyperblurb.FLAVOR.BLOG_COMMENT,
                            ihyperbola.ICommentable)
        shareItem(blog,
                  getEveryoneRole(self.userStore),
                  shareID=u'blog',
                  interfaces=[ihyperbola.IViewable])
コード例 #35
0
 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()
コード例 #36
0
ファイル: util.py プロジェクト: Aeroglyphic/twisted-quotient
    def setUpMailStuff(self, extraPowerups=(), dbdir=None, generateCert=False):
        filesdir = None
        if dbdir is None:
            filesdir = self.mktemp()
        self.siteStore = store.Store(dbdir=dbdir, filesdir=filesdir)
        Mantissa().installSite(self.siteStore, u"example.com", u"", generateCert)
        IOfferingTechnician(self.siteStore).installOffering(quotientOffering)

        loginSystem = self.siteStore.findUnique(LoginSystem)
        account = loginSystem.addAccount(u'testuser', u'example.com', None)
        self.substore = account.avatars.open()

        product = Product(
            store=self.siteStore,
            types=[qual(Inbox)] + map(qual, extraPowerups))
        product.installProductOn(self.substore)

        self.deliveryAgent = self.substore.findUnique(DeliveryAgent)
        return self.createMIMEReceiver()
コード例 #37
0
def createDatabase(store):
    """
    Initialize the given Store for use as a Mantissa webserver.
    """
    Mantissa().installSite(store, u'')
    ws = store.findUnique(WebSite)
    ws.portNumber = 8088
    ws.securePortNumber = 6443
    ws.certificateFile = 'path/to/cert.pem'
    certPath = store.dbdir.child('path').child('to').child('cert.pem')
    certPath.parent().makedirs()
    fObj = certPath.open('w')
    fObj.write(cert)
    fObj.close()
    ws.httpLog = 'path/to/httpd.log'
    ws.hitCount = 123

    loginSystem = store.findUnique(LoginSystem)
    account = loginSystem.addAccount(u'testuser', u'localhost', None)
    subStore = account.avatars.open()
    WebSite(store=subStore, hitCount=321).installOn(subStore)
コード例 #38
0
    def test_uniqueSerial(self):
        """
        Test that 'axiomatic mantissa' generates SSL certificates with a
        different unique serial on each invocation.
        """
        m = Mantissa()
        m.parent = self

        self.dbdir = self.mktemp()
        self.store = Store(self.dbdir)
        m.parseOptions(['--admin-password', 'foo'])
        cert1 = self._getCert()

        self.dbdir = self.mktemp()
        self.store = Store(self.dbdir)
        m.parseOptions(['--admin-password', 'foo'])
        cert2 = self._getCert()

        self.assertNotEqual(cert1.serialNumber(), cert2.serialNumber())
コード例 #39
0
    def setUp(self):
        """
        Set up a fake objects and methods for the password reset tests.
        """
        siteStore = Store(filesdir=self.mktemp())
        Mantissa().installSite(siteStore, u"divmod.com", u"", False)
        self.loginSystem = siteStore.findUnique(userbase.LoginSystem)
        self.site = siteStore.findUnique(SiteConfiguration)

        la = self.loginSystem.addAccount(
            u'joe', u'divmod.com', u'secret', internal=True)

        la.addLoginMethod(
            u'joe', u'external.com',
            protocol=u'zombie dance',
            verified=False,
            internal=False)

        # create an account with no external mail address
        account = self.loginSystem.addAccount(
            u'jill', u'divmod.com', u'secret', internal=True)

        account.addLoginMethod(
            u'jill', u'divmod.com',
            protocol=u'zombie dance',
            verified=True,
            internal=True)

        self.siteStore = siteStore

        # Set up the user store to have all the elements necessary to redirect
        # in the case where the user is already logged in.
        substore = la.avatars.open()
        installOn(PrivateApplication(store=substore), substore)

        self.userStore = substore
        self.loginAccount = la
        self.nonExternalAccount = account
        self.reset = PasswordResetResource(self.siteStore)
コード例 #40
0
ファイル: test_mantissacmd.py プロジェクト: twisted/mantissa
    def test_uniqueSerial(self):
        """
        Test that 'axiomatic mantissa' generates SSL certificates with a
        different unique serial on each invocation.
        """
        m = Mantissa()
        m.parent = self

        self.dbdir = self.mktemp()
        self.store = Store(self.dbdir)
        m.parseOptions(['--admin-password', 'foo'])
        cert1 = self._getCert()

        self.dbdir = self.mktemp()
        self.store = Store(self.dbdir)
        m.parseOptions(['--admin-password', 'foo'])
        cert2 = self._getCert()

        self.assertNotEqual(cert1.serialNumber(), cert2.serialNumber())