Beispiel #1
0
 def test_getAppStore(self):
     """
     L{getAppStore} should return the Entropy application store.
     """
     appStore = (IRealm(self.siteStore).accountByAddress(
         u'Entropy', None).avatars.open())
     self.assertIdentical(appStore, getAppStore(self.siteStore))
Beispiel #2
0
    def testUserBaseInstall(self):
        dbdir = self.mktemp()
        axiomatic.main(['-d', dbdir, 'userbase', 'install'])

        s = Store(dbdir)
        IRealm(s)
        ICredentialsChecker(s)
        s.close()
Beispiel #3
0
 def test_anonymousSite(self):
     """
     An L{AnonymousSite} is created and installed on the site store.
     """
     resource = self.store.findUnique(AnonymousSite)
     self.assertEqual(list(self.store.interfacesFor(resource)),
                      [IResource, IMantissaSite, IWebViewer])
     self.assertIdentical(installedOn(resource), self.store)
     self.assertIdentical(resource.loginSystem, IRealm(self.store))
 def setUp(self):
     """
     Create a store with a LoginSystem and a portal wrapped around it.
     """
     store = Store()
     installOn(LoginSystem(store=store), store)
     realm = IRealm(store)
     checker = ICredentialsChecker(store)
     self.portal = Portal(realm, [checker])
Beispiel #5
0
        def _speedup():
            l = userbase.LoginSystem(store=s)
            l.installOn(s)
            s.checkpoint()
            p = Portal(IRealm(s), [ICredentialsChecker(s)])

            a = l.addAccount(username, 'localhost', SECRET)
            gph = GarbageProtocolHandler(store=a.avatars.open(), garbage=0)
            gph.installOn(gph.store)
            return p, gph
Beispiel #6
0
    def testUpgrade(self):
        p = Portal(IRealm(self.store), [ICredentialsChecker(self.store)])

        def loggedIn((interface, avatarAspect, logout)):
            # if we can login, i guess everything is fine
            self.assertEquals(avatarAspect.garbage, GARBAGE_LEVEL)

        creds = UsernamePassword('@'.join(CREDENTIALS[:-1]), CREDENTIALS[-1])
        d = p.login(creds, None, IGarbage)
        return d.addCallback(loggedIn)
    def testUpgrade(self):
        p = Portal(IRealm(self.store), [ICredentialsChecker(self.store)])

        def loggedIn((ifc, av, lgo)):
            assert av.garbage == 7
            # Bug in cooperator?  this triggers an exception.
            # return svc.stopService()

        d = p.login(UsernamePassword('*****@*****.**', SECRET), None,
                    IGarbage)
        return d.addCallback(loggedIn)
Beispiel #8
0
 def onOpen(self):
     print "connected"
     self.bot = self.factory.bot
     self.id = count().next
     self.appStore = (
         IRealm(self.bot.store)
         .accountByAddress(u'Eridanus', None)
         .avatars
         .open())
     self.pingTimer = None
     self.pingCall = LoopingCall(self.ping)
     self.pingCall.start(30)
Beispiel #9
0
 def getFactory(self):
     """
     Create an L{SSHFactory} which allows access to Mantissa accounts.
     """
     privateKey = Key.fromString(data=self.hostKey)
     public = privateKey.public()
     factory = SSHFactory()
     factory.publicKeys = {'ssh-rsa': public}
     factory.privateKeys = {'ssh-rsa': privateKey}
     factory.portal = Portal(IRealm(self.store),
                             [ICredentialsChecker(self.store)])
     return factory
Beispiel #10
0
 def test_listOffering(self):
     """
     Mantissa offerings are added as users with a 'username' but no domain.
     Check that the 'list' command prints these correctly.
     """
     name = 'offering-name'
     self.userbase('install')
     realm = IRealm(self.store)
     substoreItem = SubStore.createNew(self.store, ('app', name))
     realm.addAccount(name, None, None, internal=True, avatars=substoreItem)
     output = self.userbase('list')
     self.assertEquals(output, [name])
Beispiel #11
0
    def testUserCreation(self):
        dbdir = self.mktemp()
        axiomatic.main(
            ['-d', dbdir, 'userbase', 'create', 'alice', 'localhost', SECRET])

        s = Store(dbdir)
        cc = ICredentialsChecker(s)
        p = Portal(IRealm(s), [cc])

        def cb((interface, avatar, logout)):
            logout()

        return p.login(UsernamePassword('alice@localhost', SECRET), None,
                       lambda orig, default: orig).addCallback(cb)
Beispiel #12
0
 def claim(self):
     if not self.claimed:
         log.msg("Claiming a ticket for the first time for %r" %
                 (self.email, ))
         username, domain = self.email.split('@', 1)
         realm = IRealm(self.store)
         acct = realm.accountByAddress(username, domain)
         if acct is None:
             acct = realm.addAccount(username, domain, None)
         self.avatar = acct
         self.claimed += 1
         self.booth.ticketClaimed(self)
         self.product.installProductOn(IBeneficiary(self.avatar))
     else:
         log.msg("Ignoring re-claim of ticket for: %r" % (self.email, ))
     return self.avatar
Beispiel #13
0
    def locateChild(self, context, segments):
        """
        Delegate dispatch to a sharing resource if the request is for a user
        subdomain, otherwise fall back to the wrapped resource's C{locateChild}
        implementation.
        """
        request = IRequest(context)
        hostname = request.getHeader('host')

        info = self.subdomain(hostname)
        if info is not None:
            username, domain = info
            index = UserIndexPage(IRealm(self.siteStore), self.webViewer)
            resource = index.locateChild(None, [username])[0]
            return resource, segments
        return self.wrapped.locateChild(context, segments)
Beispiel #14
0
    def buildTerminalProtocol(self, viewer):
        """
        Create and return a L{TextServer} using a L{Player} owned by the store
        this item is in.

        This implementation is certainly wrong.  It probably reflects some
        current limitations of Mantissa.  Primarily, the limitation is
        interaction between different stores, in this case a user store and an
        application store.
        """
        # XXX Get the Imaginary app store.  Eventually this should just be
        # self.store.  See #2908.
        imaginary = IRealm(self.store.parent).accountByAddress(u'Imaginary', None).avatars.open()

        role = viewer.roleIn(imaginary)
        characters = self._charactersForViewer(imaginary, role)

        world = imaginary.findUnique(ImaginaryWorld)
        return CharacterSelectionTextServer(role, world, characters)
Beispiel #15
0
 def getStore(self, name, domain):
     """Convenience method for the REPL. I got tired of typing this string every time I logged in."""
     return IRealm(self.original.store.parent).accountByAddress(name, domain).avatars.open()
Beispiel #16
0
 def getLoginSystem(self):
     return IRealm(self.getStore())
Beispiel #17
0
 def test_powerup(self):
     """
     Test that L{LoginSystem} powers up the store for L{IRealm}.
     """
     self.assertIdentical(self.realm, IRealm(self.store))
Beispiel #18
0
 def _login(self, avatarId, password):
     cc = ICredentialsChecker(self.store)
     p = Portal(IRealm(self.store), [cc])
     return p.login(UsernamePassword(avatarId, password), None,
                    lambda orig, default: orig)
 def setUp(self):
     self.store = getPristineStore(self, createStore)
     self.mailbox = self.store.findUnique(POP3Up)
     realm = IRealm(self.store)
     checker = ICredentialsChecker(self.store)
     self.portal = Portal(realm, [checker])