Beispiel #1
0
 def installed(self):
     """
     Share this item once installed.
     """
     shareid = u'test'
     sharing.getEveryoneRole(self.store).shareItem(self, shareID=shareid)
     websharing.addDefaultShareID(self.store, shareid, 0)
Beispiel #2
0
 def test_identifierFromSharedItemNoMethods(self):
     """
     L{sharing.Identifier.fromSharedItem} should raise L{NoSuchShare} if the given
     item's store contains no L{LoginMethod} objects.
     """
     self.method.deleteFromStore()
     t = PrivateThing(store=self.store)
     sharing.getEveryoneRole(self.store).shareItem(t, shareID=u'asdf')
     self.assertRaises(sharing.NoSuchShare, sharing.Identifier.fromSharedItem, t)
Beispiel #3
0
 def installed(self):
     """
     Share this item once installed.
     """
     shareid = u'test'
     sharing.getEveryoneRole(self.store
                     ).shareItem(self,
                       shareID=shareid)
     websharing.addDefaultShareID(self.store, shareid, 0)
Beispiel #4
0
 def test_identifierFromSharedItem(self):
     """
     L{sharing.Identifier.fromSharedItem} should identify a shared Item's shareID.
     """
     t = PrivateThing(store=self.store)
     sharing.getEveryoneRole(self.store).shareItem(t, shareID=u'asdf')
     sid = sharing.Identifier.fromSharedItem(t)
     self.assertEquals(sid.shareID, u'asdf')
     self.assertEquals(sid.localpart, u'username')
     self.assertEquals(sid.domain, u'domain.example.com')
Beispiel #5
0
 def test_identifierFromSharedItemMulti(self):
     """
     L{sharing.Identifier.fromSharedItem} should identify a shared Item's
     shareID even if it is shared multiple times.
     """
     t = PrivateThing(store=self.store)
     sharing.getEveryoneRole(self.store).shareItem(t, shareID=u'asdf')
     sharing.getAuthenticatedRole(self.store).shareItem(t, shareID=u'jkl;')
     sid = sharing.Identifier.fromSharedItem(t)
     self.assertIn(sid.shareID, [u'asdf', u'jkl;'])
     self.assertEquals(sid.localpart, u'username')
     self.assertEquals(sid.domain, u'domain.example.com')
Beispiel #6
0
 def test_roleIn(self):
     """
     L{_AnonymousWebViewer} should provide the Everyone role in the store it
     is asked about.
     """
     theRole = getEveryoneRole(self.adminStore)
     self.assertIdentical(self.pageFactory.roleIn(self.adminStore), theRole)
Beispiel #7
0
 def test_roleIn(self):
     """
     L{_AnonymousWebViewer} should provide the Everyone role in the store it
     is asked about.
     """
     theRole = getEveryoneRole(self.adminStore)
     self.assertIdentical(self.pageFactory.roleIn(self.adminStore), theRole)
Beispiel #8
0
    def test_defaultUserSharedResource(self):
        """
        The resource for the default share can be accessed by an
        unauthenticated user.
        """
        # Make a user to own the shared item.
        username = u"alice"
        aliceAccount = self.login.addAccount(username, self.domain, u"password", internal=True)
        aliceStore = aliceAccount.avatars.open()

        # Make an item to share.
        sharedContent = u"content owned by alice and shared to everyone"
        shareID = getEveryoneRole(aliceStore).shareItem(DummyItem(store=aliceStore, markup=sharedContent)).shareID

        # Make it the default share.
        addDefaultShareID(aliceStore, shareID, 0)

        # Get it.
        page = getWithSession(
            self.factory, 3, "/users/%s" % (username.encode("ascii"),), {"host": self.domain.encode("ascii")}
        )

        def rendered(request):
            self.assertIn(sharedContent.encode("ascii"), request.accumulator)

        page.addCallback(rendered)
        return page
Beispiel #9
0
    def test_defaultUserSharedResource(self):
        """
        The resource for the default share can be accessed by an authenticated
        user.
        """
        # Make an item and share it.
        sharedContent = u"content owned by alice and shared to everyone"
        shareID = (
            getEveryoneRole(self.userStore).shareItem(DummyItem(store=self.userStore, markup=sharedContent)).shareID
        )

        # Make it the default.
        addDefaultShareID(self.userStore, shareID, 0)

        # Get it.
        page = getWithSession(
            self.factory,
            1,
            "/users/%s" % (self.username.encode("ascii"),),
            {"host": self.domain.encode("ascii")},
            self.cookies,
        )

        def rendered(request):
            self.assertIn(sharedContent, request.accumulator)

        page.addCallback(rendered)
        return page
Beispiel #10
0
    def test_defaultUserSharedResource(self):
        """
        The resource for the default share can be accessed by an
        unauthenticated user.
        """
        # Make a user to own the shared item.
        username = u'alice'
        aliceAccount = self.login.addAccount(username,
                                             self.domain,
                                             u'password',
                                             internal=True)
        aliceStore = aliceAccount.avatars.open()

        # Make an item to share.
        sharedContent = u'content owned by alice and shared to everyone'
        shareID = getEveryoneRole(aliceStore).shareItem(
            DummyItem(store=aliceStore, markup=sharedContent)).shareID

        # Make it the default share.
        addDefaultShareID(aliceStore, shareID, 0)

        # Get it.
        page = getWithSession(self.factory, 3,
                              '/users/%s' % (username.encode('ascii'), ),
                              {'host': self.domain.encode('ascii')})

        def rendered(request):
            self.assertIn(sharedContent.encode('ascii'), request.accumulator)

        page.addCallback(rendered)
        return page
Beispiel #11
0
 def installApp(self, ss1):
     """
     Create a public item and share it as the default.
     """
     fpi = FakePublicItem(store=ss1)
     shareItem(fpi, toRole=getEveryoneRole(ss1),
               shareID=getDefaultShareID(ss1))
Beispiel #12
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/')
Beispiel #13
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/')
Beispiel #14
0
    def test_userSharedResource(self):
        """
        An item shared by a user to everybody can be accessed by an
        unauthenticated user.
        """
        # Make a user to own the shared item.
        username = u'alice'
        aliceAccount = self.login.addAccount(
            username, self.domain, u'password', internal=True)
        aliceStore = aliceAccount.avatars.open()

        # Make an item to share.
        sharedContent = u'content owned by alice and shared to everyone'
        shareID = getEveryoneRole(aliceStore).shareItem(
            DummyItem(store=aliceStore, markup=sharedContent)).shareID

        # Get it.
        page = getWithSession(
            self.factory, 2, '/users/%s/%s' % (
                username.encode('ascii'), shareID.encode('ascii')),
            {'host': self.domain.encode('ascii')})
        def rendered(request):
            self.assertIn(sharedContent.encode('ascii'), request.accumulator)
        page.addCallback(rendered)
        return page
    def createBlog(self, title, description):
        """
        Create a top-level BLOG-flavored Blurb with the given title and
        description, shared for edit with the owner of this store and for
        viewing with everyone, and return it.

        @param title: the blog title
        @type title: C{unicode}

        @param description: the blog description
        @type description: C{unicode}
        """
        store = self.store

        now = Time()
        blog = Blurb(store=self.store,
                     dateCreated=now,
                     dateLastEdited=now,
                     title=title,
                     body=description,
                     flavor=FLAVOR.BLOG,
                     author=sharing.getSelfRole(self.store))

        authorsRole = sharing.getPrimaryRole(store, title + u' blog', True)
        sharing.getSelfRole(store).becomeMemberOf(authorsRole)

        sharing.shareItem(blog, authorsRole, shareID=u'blog')

        everyoneRole = sharing.getEveryoneRole(store)
        sharing.shareItem(blog, everyoneRole, shareID=u'blog',
                          interfaces=[IViewable])

        # this should be configurable
        blog.permitChildren(everyoneRole, FLAVOR.BLOG_POST, IViewable)
Beispiel #16
0
 def test_linkToProxy(self):
     """
     Test that L{xmantissa.websharing.linkTo} generates a URL that I can
     link to.
     """
     self._verifyPath(
         websharing.linkTo(sharing.getShare(self.s, sharing.getEveryoneRole(
                     self.s), u'loginsystem')))
Beispiel #17
0
 def installApp(self, ss1):
     """
     Create a public item and share it as the default.
     """
     fpi = FakePublicItem(store=ss1)
     shareItem(fpi,
               toRole=getEveryoneRole(ss1),
               shareID=getDefaultShareID(ss1))
Beispiel #18
0
 def test_linkToProxy(self):
     """
     Test that L{xmantissa.websharing.linkTo} generates a URL that I can
     link to.
     """
     self._verifyPath(
         websharing.linkTo(
             sharing.getShare(self.s, sharing.getEveryoneRole(self.s),
                              u'loginsystem')))
 def getRole(self):
     """
     Retrieve the role currently viewing this blurb viewer.
     """
     store = sharing.itemFromProxy(self.original).store
     if self.customizedFor is None:
         # If this hasn't been customized, it's public.
         return sharing.getEveryoneRole(store)
     else:
         # Otherwise, get the primary role of the current observer.
         return sharing.getPrimaryRole(store, self.customizedFor)
Beispiel #20
0
 def test_defaultShareIDInteractionNoMatch(self):
     """
     Verify that L{websharing.linkTo} explicitly includes a share ID in the
     URL if the ID of the share it is passed doesn't match the default.
     """
     websharing.addDefaultShareID(self.s, u'share-id', 0)
     shareable = Shareable(store=self.s)
     sharing.shareItem(Shareable(store=self.s), shareID=u'not-the-share-id')
     share = sharing.getShare(
         self.s, sharing.getEveryoneRole(self.s), u'not-the-share-id')
     url = websharing.linkTo(share)
     self.assertEqual(str(url), '/users/right/not-the-share-id')
Beispiel #21
0
 def test_defaultShareIDInteractionNoMatch(self):
     """
     Verify that L{websharing.linkTo} explicitly includes a share ID in the
     URL if the ID of the share it is passed doesn't match the default.
     """
     websharing.addDefaultShareID(self.s, u'share-id', 0)
     shareable = Shareable(store=self.s)
     sharing.shareItem(Shareable(store=self.s), shareID=u'not-the-share-id')
     share = sharing.getShare(self.s, sharing.getEveryoneRole(self.s),
                              u'not-the-share-id')
     url = websharing.linkTo(share)
     self.assertEqual(str(url), '/users/right/not-the-share-id')
Beispiel #22
0
 def test_getSelfRole(self):
     """
     The self-role of a store should be determined by its L{LoginMethod}s.
     """
     self.assertEquals(list(self.store.query(sharing.Role)), [])
     me = sharing.getSelfRole(self.store)
     self.assertEquals(me.externalID, u'*****@*****.**')
     self.assertEquals(me.store, self.store)
     self.assertEquals(list(me.allRoles()),
                       [me,
                        sharing.getAuthenticatedRole(self.store),
                        sharing.getEveryoneRole(self.store)])
Beispiel #23
0
 def test_defaultShareIDInteractionMatching(self):
     """
     Verify that L{websharing.linkTo} does not explicitly include a share
     ID in the URL if the ID of the share it is passed matches the default.
     """
     websharing.addDefaultShareID(self.s, u'share-id', 0)
     sharing.shareItem(Shareable(store=self.s), shareID=u'share-id')
     share = sharing.getShare(
         self.s, sharing.getEveryoneRole(self.s), u'share-id')
     url = websharing.linkTo(share)
     self.assertEqual(str(url), '/users/right/')
     # and if we call child()
     self.assertEqual(str(url.child('child')), '/users/right/share-id/child')
Beispiel #24
0
    def _shareAndGetProxy(self, blurb):
        """
        Share C{blurb} to everyone and return a shared proxy

        @param blurb: a blurb
        @type blurb: L{hyperbola.hyperblurb.Blurb}

        @rtype: L{xmantissa.sharing.SharedProxy}
        """
        share = sharing.shareItem(blurb)
        return sharing.getShare(self.userStore,
                                sharing.getEveryoneRole(self.userStore),
                                share.shareID)
Beispiel #25
0
 def test_defaultShareIDInteractionMatching(self):
     """
     Verify that L{websharing.linkTo} does not explicitly include a share
     ID in the URL if the ID of the share it is passed matches the default.
     """
     websharing.addDefaultShareID(self.s, u'share-id', 0)
     sharing.shareItem(Shareable(store=self.s), shareID=u'share-id')
     share = sharing.getShare(self.s, sharing.getEveryoneRole(self.s),
                              u'share-id')
     url = websharing.linkTo(share)
     self.assertEqual(str(url), '/users/right/')
     # and if we call child()
     self.assertEqual(str(url.child('child')),
                      '/users/right/share-id/child')
Beispiel #26
0
    def _shareAndGetProxy(self, blurb):
        """
        Share C{blurb} to everyone and return a shared proxy

        @param blurb: a blurb
        @type blurb: L{hyperbola.hyperblurb.Blurb}

        @rtype: L{xmantissa.sharing.SharedProxy}
        """
        share = sharing.shareItem(blurb)
        return sharing.getShare(
            self.userStore,
            sharing.getEveryoneRole(self.userStore),
            share.shareID)
 def test_viewability(self):
     """
     Verify that a blog may be viewed publicly, by retrieving it
     through the web sharing index and inspecting the result to
     verify that it will have appropriate properties set.
     """
     er = getEveryoneRole(self.userStore)
     si = SharingIndex(self.userStore, IWebViewer(self.siteStore))
     child, segs = si.locateChild(None, ['blog'])
     self.assertEquals(len(segs), 0)
     self.failUnless(isinstance(child, PublicAthenaLivePage))
     viewer = child.fragment
     self.failUnless(isinstance(viewer, BlurbViewer))
     blurbish = viewer.original
     self.failUnless(blurbish.title, self.blog.title)
     self.assertEquals(viewer.getRole(), er)
Beispiel #28
0
 def test_viewability(self):
     """
     Verify that a blog may be viewed publicly, by retrieving it
     through the web sharing index and inspecting the result to
     verify that it will have appropriate properties set.
     """
     er = getEveryoneRole(self.userStore)
     si = SharingIndex(self.userStore, IWebViewer(self.siteStore))
     child, segs = si.locateChild(None, ['blog'])
     self.assertEquals(len(segs), 0)
     self.failUnless(isinstance(child, PublicAthenaLivePage))
     viewer = child.fragment
     self.failUnless(isinstance(viewer, BlurbViewer))
     blurbish = viewer.original
     self.failUnless(blurbish.title, self.blog.title)
     self.assertEquals(viewer.getRole(), er)
Beispiel #29
0
    def setUp(self):
        """
        Create a user account and share an item from it to everyone.
        """
        IntegrationTestsMixin.setUp(self)

        # Make an account to go with this virtual host.
        self.username = u"alice"
        self.userAccount = self.login.addAccount(self.username, self.domain, u"password", internal=True)
        self.userStore = self.userAccount.avatars.open()
        self.virtualHost = u".".join((self.username, self.domain))

        # Share something that we'll try to load.
        self.sharedContent = u"content owned by alice and shared to everyone"
        self.share = getEveryoneRole(self.userStore).shareItem(
            DummyItem(store=self.userStore, markup=self.sharedContent)
        )
    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])
Beispiel #31
0
    def setUp(self):
        """
        Create a user account and share an item from it to everyone.
        """
        IntegrationTestsMixin.setUp(self)

        # Make an account to go with this virtual host.
        self.username = u'alice'
        self.userAccount = self.login.addAccount(self.username,
                                                 self.domain,
                                                 u'password',
                                                 internal=True)
        self.userStore = self.userAccount.avatars.open()
        self.virtualHost = u'.'.join((self.username, self.domain))

        # Share something that we'll try to load.
        self.sharedContent = u'content owned by alice and shared to everyone'
        self.share = getEveryoneRole(self.userStore).shareItem(
            DummyItem(store=self.userStore, markup=self.sharedContent))
Beispiel #32
0
    def test_userSharedResource(self):
        """
        An item shared by a user to everybody can be accessed by that user.
        """
        # Make an item and share it.
        sharedContent = u'content owned by alice and shared to everyone'
        shareID = getEveryoneRole(self.userStore).shareItem(
            DummyItem(store=self.userStore, markup=sharedContent)).shareID

        page = getResource(
            self.factory, '/users/%s/%s' % (
                self.username.encode('ascii'), shareID.encode('ascii')),
            {'host': self.domain.encode('ascii')},
            self.cookies)

        def rendered(request):
            self.assertIn(sharedContent, request.accumulator)
        page.addCallback(rendered)
        return page
Beispiel #33
0
    def test_userSharedResource(self):
        """
        An item shared by a user to everybody can be accessed by that user.
        """
        # Make an item and share it.
        sharedContent = u'content owned by alice and shared to everyone'
        shareID = getEveryoneRole(self.userStore).shareItem(
            DummyItem(store=self.userStore, markup=sharedContent)).shareID

        page = getResource(
            self.factory, '/users/%s/%s' %
            (self.username.encode('ascii'), shareID.encode('ascii')),
            {'host': self.domain.encode('ascii')}, self.cookies)

        def rendered(request):
            self.assertIn(sharedContent, request.accumulator)

        page.addCallback(rendered)
        return page
Beispiel #34
0
 def test_myFirstBlog(self):
     """
     Verify that when the user creates a blog via the default public interface,
     createBlog, it is editable by the author (e.g. the owner of the store)
     and viewable by the public.
     """
     self.publicPresence = hyperbola_model.HyperbolaPublicPresence(
         store=self.store)
     self.publicPresence.createBlog(u"A wonderful blog", u"Here it is")
     myBlogs = list(self.publicPresence.getTopLevelFor(getSelfRole(self.store)))
     yourBlogs = list(self.publicPresence.getTopLevelFor(getEveryoneRole(
         self.store)))
     self.failUnless(len(myBlogs) == 1)
     self.failUnless(len(yourBlogs) == 1)
     self.failUnless(ihyperbola.IEditable.providedBy(myBlogs[0]))
     self.failIf(ihyperbola.IEditable.providedBy(yourBlogs[0]))
     self.failUnless(ihyperbola.IViewable.providedBy(myBlogs[0]))
     self.failUnless(ihyperbola.IViewable.providedBy(yourBlogs[0]))
     self.failUnless(ihyperbola.ICommentable.providedBy(myBlogs[0]))
     self.failIf(ihyperbola.ICommentable.providedBy(yourBlogs[0]))
 def test_myFirstBlog(self):
     """
     Verify that when the user creates a blog via the default public interface,
     createBlog, it is editable by the author (e.g. the owner of the store)
     and viewable by the public.
     """
     self.publicPresence = hyperbola_model.HyperbolaPublicPresence(
         store=self.store)
     self.publicPresence.createBlog(u"A wonderful blog", u"Here it is")
     myBlogs = list(
         self.publicPresence.getTopLevelFor(getSelfRole(self.store)))
     yourBlogs = list(
         self.publicPresence.getTopLevelFor(getEveryoneRole(self.store)))
     self.failUnless(len(myBlogs) == 1)
     self.failUnless(len(yourBlogs) == 1)
     self.failUnless(ihyperbola.IEditable.providedBy(myBlogs[0]))
     self.failIf(ihyperbola.IEditable.providedBy(yourBlogs[0]))
     self.failUnless(ihyperbola.IViewable.providedBy(myBlogs[0]))
     self.failUnless(ihyperbola.IViewable.providedBy(yourBlogs[0]))
     self.failUnless(ihyperbola.ICommentable.providedBy(myBlogs[0]))
     self.failIf(ihyperbola.ICommentable.providedBy(yourBlogs[0]))
Beispiel #36
0
 def setUp(self):
     """
     Set up a store with an installed offering.
     """
     self.siteStore = Store(dbdir=self.mktemp())
     Mantissa().installSite(self.siteStore, u"localhost", u"", False)
     off = Offering(
         name=u"test_offering",
         description=u"Offering for creating a sample app store",
         siteRequirements=[],
         appPowerups=[TestAppPowerup],
         installablePowerups=[],
         loginInterfaces=[],
         themes=[],
     )
     self.installedOffering = installOffering(self.siteStore, off, None)
     self.app = self.installedOffering.application
     self.substore = self.app.open()
     sharedItem = getEveryoneRole(self.substore).getShare(getDefaultShareID(self.substore))
     self.frontPage = self.siteStore.findUnique(FrontPage)
     self.webViewer = IWebViewer(self.siteStore)
Beispiel #37
0
    def data_offerings(self, ctx, data):
        """
        Generate a list of installed offerings.

        @return: a generator of dictionaries mapping 'name' to the name of an
        offering installed on the store.
        """
        for io in self.original.store.query(offering.InstalledOffering):
            pp = ixmantissa.IPublicPage(io.application, None)
            if pp is not None and getattr(pp, 'index', True):
                warn("Use the sharing system to provide public pages,"
                     " not IPublicPage",
                     category=DeprecationWarning,
                     stacklevel=2)
                yield {'name': io.offeringName}
            else:
                s = io.application.open()
                try:
                    pp = getEveryoneRole(s).getShare(getDefaultShareID(s))
                    yield {'name': io.offeringName}
                except NoSuchShare:
                    continue
Beispiel #38
0
 def setUp(self):
     """
     Set up a store with an installed offering.
     """
     self.siteStore = Store(dbdir=self.mktemp())
     Mantissa().installSite(self.siteStore, u"localhost", u"", False)
     off = Offering(
         name=u'test_offering',
         description=u'Offering for creating a sample app store',
         siteRequirements=[],
         appPowerups=[TestAppPowerup],
         installablePowerups=[],
         loginInterfaces=[],
         themes=[],
     )
     self.installedOffering = installOffering(self.siteStore, off, None)
     self.app = self.installedOffering.application
     self.substore = self.app.open()
     sharedItem = getEveryoneRole(self.substore).getShare(
         getDefaultShareID(self.substore))
     self.frontPage = self.siteStore.findUnique(FrontPage)
     self.webViewer = IWebViewer(self.siteStore)
Beispiel #39
0
    def setUp(self):
        """
        Set up an environment suitable for testing the share-handling
        functionality of L{hyperbola_view.ShareScrollingElement}.
        """
        self._setUpStore()

        blogShare = self._shareAndGetProxy(self._makeBlurb(FLAVOR.BLOG))
        EVERYBODY = sharing.getEveryoneRole(self.userStore)
        sharing.itemFromProxy(blogShare).permitChildren(
            EVERYBODY, FLAVOR.BLOG_POST, ihyperbola.IViewable)

        # For sanity's sake, let's not have the role of the view and the role
        # implicitly chosen by not calling 'customizeFor' disagree.  (This
        # shouldn't be possible anyway, and in the future getRole should just
        # be looking at its proxy.)
        self.publicBlogShare = sharing.getShare(
            self.userStore, EVERYBODY, blogShare.shareID)
        selfRole = sharing.getSelfRole(self.userStore)
        blogPostShareID = blogShare.post(u'', u'', selfRole)
        self.blogPostSharedToEveryone = sharing.getShare(
            self.userStore, EVERYBODY, blogPostShareID)
        self.blogPostItem = sharing.itemFromProxy(self.blogPostSharedToEveryone)
Beispiel #40
0
    def data_offerings(self, ctx, data):
        """
        Generate a list of installed offerings.

        @return: a generator of dictionaries mapping 'name' to the name of an
        offering installed on the store.
        """
        for io in self.original.store.query(offering.InstalledOffering):
            pp = ixmantissa.IPublicPage(io.application, None)
            if pp is not None and getattr(pp, 'index', True):
                warn(
                    "Use the sharing system to provide public pages,"
                    " not IPublicPage",
                    category=DeprecationWarning,
                    stacklevel=2)
                yield {'name': io.offeringName}
            else:
                s = io.application.open()
                try:
                    pp = getEveryoneRole(s).getShare(getDefaultShareID(s))
                    yield {'name': io.offeringName}
                except NoSuchShare:
                    continue
Beispiel #41
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])
Beispiel #42
0
    def test_defaultUserSharedResource(self):
        """
        The resource for the default share can be accessed by an authenticated
        user.
        """
        # Make an item and share it.
        sharedContent = u'content owned by alice and shared to everyone'
        shareID = getEveryoneRole(self.userStore).shareItem(
            DummyItem(store=self.userStore, markup=sharedContent)).shareID

        # Make it the default.
        addDefaultShareID(self.userStore, shareID, 0)

        # Get it.
        page = getWithSession(self.factory, 1,
                              '/users/%s' % (self.username.encode('ascii'), ),
                              {'host': self.domain.encode('ascii')},
                              self.cookies)

        def rendered(request):
            self.assertIn(sharedContent, request.accumulator)

        page.addCallback(rendered)
        return page
Beispiel #43
0
 def roleIn(self, userStore):
     """
     Return only the 'everyone' role in the given user- or app-store, since
     the user represented by this object is anonymous.
     """
     return getEveryoneRole(userStore)
Beispiel #44
0
 def installed(self):
     getEveryoneRole(self.store).shareItem(self, CALENDAR_SHARE_ID, [IMessageReceiver])
Beispiel #45
0
 def roleIn(self, userStore):
     """
     Return only the 'everyone' role in the given user- or app-store, since
     the user represented by this object is anonymous.
     """
     return getEveryoneRole(userStore)
Beispiel #46
0
 def installed(self):
     getEveryoneRole(self.store).shareItem(self, CALENDAR_SHARE_ID, [IMessageReceiver])