Exemplo n.º 1
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.assertEqual(output, [name])
Exemplo n.º 2
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
Exemplo n.º 3
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)
Exemplo n.º 4
0
        def _speedup():
            l = userbase.LoginSystem(store=s)
            dependency.installOn(l, s)
            s.checkpoint()
            p = Portal(IRealm(s),
                       [ICredentialsChecker(s)])

            a = l.addAccount(username, 'localhost', SECRET)
            gph = GarbageProtocolHandler(store=a.avatars.open(),
                                         garbage=0)
            dependency.installOn(gph, gph.store)
            return p, gph
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
0
 def getLoginSystem(self):
     return IRealm(self.getStore())
Exemplo n.º 8
0
 def test_powerup(self):
     """
     Test that L{LoginSystem} powers up the store for L{IRealm}.
     """
     self.assertIdentical(self.realm, IRealm(self.store))
Exemplo n.º 9
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)
Exemplo n.º 10
0
 def test_interface(self):
     self.assertTrue(IRealm.implementedBy(clientcred.ClientRealm))
Exemplo n.º 11
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()
Exemplo n.º 12
0
 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])