Ejemplo n.º 1
0
    def _makeSite(self):
        import base64
        from cStringIO import StringIO
        import urllib

        from AccessControl.User import UserFolder
        from OFS.Folder import Folder
        from OFS.DTMLMethod import DTMLMethod

        root = Folder()
        root.isTopLevelPrincipiaApplicationObject = 1  # User folder needs this
        root.getPhysicalPath = lambda: ()  # hack
        root._View_Permission = ('Anonymous',)

        users = UserFolder()
        users._setId('acl_users')
        users._doAddUser('abraham', 'pass-w', ('Patriarch',), ())
        users._doAddUser('isaac', 'pass-w', ('Son',), ())
        root._setObject(users.id, users)

        cc = self._makeOne()
        cc.id = self._CC_ID
        root._setObject(cc.id, cc)

        index = DTMLMethod()
        index.munge('This is the default view')
        index._setId('index_html')
        root._setObject(index.getId(), index)

        login = DTMLMethod()
        login.munge('Please log in first.')
        login._setId('login_form')
        root._setObject(login.getId(), login)

        protected = DTMLMethod()
        protected._View_Permission = ('Manager',)
        protected.munge('This is the protected view')
        protected._setId('protected')
        root._setObject(protected.getId(), protected)

        req = makerequest(root, StringIO())
        self._finally = req.close

        credentials = urllib.quote(
            base64.encodestring('abraham:pass-w').rstrip())

        return root, cc, req, credentials
Ejemplo n.º 2
0
    def _makeSite(self):
        import base64
        from cStringIO import StringIO
        import urllib

        from AccessControl.User import UserFolder
        from OFS.Folder import Folder
        from OFS.DTMLMethod import DTMLMethod

        root = Folder()
        root.isTopLevelPrincipiaApplicationObject = 1  # User folder needs this
        root.getPhysicalPath = lambda: ()  # hack
        root._View_Permission = ('Anonymous', )

        users = UserFolder()
        users._setId('acl_users')
        users._doAddUser('abraham', 'pass-w', ('Patriarch', ), ())
        users._doAddUser('isaac', 'pass-w', ('Son', ), ())
        root._setObject(users.id, users)

        cc = self._makeOne()
        cc.id = self._CC_ID
        root._setObject(cc.id, cc)

        index = DTMLMethod()
        index.munge('This is the default view')
        index._setId('index_html')
        root._setObject(index.getId(), index)

        login = DTMLMethod()
        login.munge('Please log in first.')
        login._setId('login_form')
        root._setObject(login.getId(), login)

        protected = DTMLMethod()
        protected._View_Permission = ('Manager', )
        protected.munge('This is the protected view')
        protected._setId('protected')
        root._setObject(protected.getId(), protected)

        req = makerequest(root, StringIO())
        self._finally = req.close

        credentials = urllib.quote(
            base64.encodestring('abraham:pass-w').rstrip())

        return root, cc, req, credentials
Ejemplo n.º 3
0
    def setUp(self):
        CookieCrumblerTests.setUp(self)
        root = Folder()
        self.root = root
        root.isTopLevelPrincipiaApplicationObject = 1  # User folder needs this
        root.getPhysicalPath = lambda: ()  # hack
        root._View_Permission = ('Anonymous', )

        users = UserFolder()
        users._setId('acl_users')
        users._doAddUser('abraham', 'pass-w', ('Patriarch', ), ())
        users._doAddUser('isaac', 'pass-w', ('Son', ), ())
        users._doAddUser(
            'abrahammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm',
            'pass-wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww',
            ('Son', ), ())
        root._setObject(users.id, users)

        cc = CookieCrumbler()
        cc.id = 'cookie_authentication'
        root._setObject(cc.id, cc)
        self.cc = getattr(root, cc.id)

        index = DTMLMethod()
        index.munge('This is the default view')
        index._setId('index_html')
        root._setObject(index.getId(), index)

        login = DTMLMethod()
        login.munge('Please log in first.')
        login._setId('login_form')
        root._setObject(login.getId(), login)

        protected = DTMLMethod()
        protected._View_Permission = ('Manager', )
        protected.munge('This is the protected view')
        protected._setId('protected')
        root._setObject(protected.getId(), protected)

        self.responseOut = StringIO()
        self.req = makerequest(root, self.responseOut)

        self.credentials = urllib.quote(
            base64.encodestring('abraham:pass-w').replace('\012', ''))
Ejemplo n.º 4
0
  def setUp(self):
    CookieCrumblerTests.setUp(self)
    root = Folder()
    self.root = root
    root.isTopLevelPrincipiaApplicationObject = 1  # User folder needs this
    root.getPhysicalPath = lambda: ()  # hack
    root._View_Permission = ('Anonymous',)

    users = UserFolder()
    users._setId('acl_users')
    users._doAddUser('abraham', 'pass-w', ('Patriarch',), ())
    users._doAddUser('isaac', 'pass-w', ('Son',), ())
    users._doAddUser('abrahammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm',
                     'pass-wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww',
                     ('Son',), ())
    root._setObject(users.id, users)
    
    cc = CookieCrumbler()
    cc.id = 'cookie_authentication'
    root._setObject(cc.id, cc)
    self.cc = getattr(root, cc.id)

    index = DTMLMethod()
    index.munge('This is the default view')
    index._setId('index_html')
    root._setObject(index.getId(), index)

    login = DTMLMethod()
    login.munge('Please log in first.')
    login._setId('login_form')
    root._setObject(login.getId(), login)

    protected = DTMLMethod()
    protected._View_Permission = ('Manager',)
    protected.munge('This is the protected view')
    protected._setId('protected')
    root._setObject(protected.getId(), protected)

    self.responseOut = StringIO()
    self.req = makerequest(root, self.responseOut)

    self.credentials = urllib.quote(
        base64.encodestring('abraham:pass-w').replace('\012', ''))