コード例 #1
0
    def test_custom_condition_fail(self):
        def custom(req):
            return False

        addCommitCondition("custom-condition", custom=custom)
        checker = CommitChecker(self.request, ('custom-condition', ))
        self.assertTrue(not checker.can_commit())
コード例 #2
0
 def test_custom_condition_fail(self):
     def custom(req):
         return False
     addCommitCondition("custom-condition",
         custom=custom)
     checker = CommitChecker(self.request, ('custom-condition',))
     self.assertTrue(not checker.can_commit())
コード例 #3
0
    def test_custom_condition_success(self):
        def custom(req):
            return True

        addCommitCondition("custom-condition", custom=custom)
        checker = CommitChecker(self.request, ('custom-condition', ))
        self.assertTrue(checker.can_commit())
コード例 #4
0
 def test_custom_condition_success(self):
     def custom(req):
         return True
     addCommitCondition("custom-condition",
         custom=custom)
     checker = CommitChecker(self.request, ('custom-condition',))
     self.assertTrue(checker.can_commit())
コード例 #5
0
 def test_multiple_conditions_all_fail(self):
     addCommitCondition("path", path="/foo/bar")
     addCommitCondition("method", request_method="POST",
         host="www.foobar.com")
     self.request.set('ACTUAL_URL', self.portal_url + '/foo')
     self.request.set('REQUEST_METHOD', 'GET')
     self.request.set('BASE1', 'http://www.foboar.com')
     checker = CommitChecker(self.request, ('path', 'method'))
     self.assertTrue(not checker.can_commit())
コード例 #6
0
 def test_all_criteria_not_met(self):
     addCommitCondition("condition",
         path="/foo/bar",
         request_method="POST",
         host="www.foobar.com")
     self.request.set('ACTUAL_URL', self.portal_url + '/foo')
     self.request.set('REQUEST_METHOD', 'GET')
     self.request.set('BASE1', 'http://www.foboar.com')
     checker = CommitChecker(self.request, ('condition',))
     self.assertTrue(not checker.can_commit())
コード例 #7
0
 def test_multiple_conditions_all_fail(self):
     addCommitCondition("path", path="/foo/bar")
     addCommitCondition("method",
                        request_method="POST",
                        host="www.foobar.com")
     self.request.set('ACTUAL_URL', self.portal_url + '/foo')
     self.request.set('REQUEST_METHOD', 'GET')
     self.request.set('BASE1', 'http://www.foboar.com')
     checker = CommitChecker(self.request, ('path', 'method'))
     self.assertTrue(not checker.can_commit())
コード例 #8
0
 def test_all_criteria_not_met(self):
     addCommitCondition("condition",
                        path="/foo/bar",
                        request_method="POST",
                        host="www.foobar.com")
     self.request.set('ACTUAL_URL', self.portal_url + '/foo')
     self.request.set('REQUEST_METHOD', 'GET')
     self.request.set('BASE1', 'http://www.foboar.com')
     checker = CommitChecker(self.request, ('condition', ))
     self.assertTrue(not checker.can_commit())
コード例 #9
0
    def setUp(self):
        from wildcard.lockdown import addCommitCondition

        self.portal = self.layer["portal"]
        self.request = self.layer["request"]
        self.portal_url = self.portal.absolute_url()
        addCommitCondition("user-area", path="/users*", request_method="POST")
        folder = createObject(self.portal, "Folder", "users")
        createObject(folder, "News Item", "test1", title="Test 1")
        createObject(folder, "News Item", "test2", title="Test 2")
        createObject(self.portal, "Document", "testpage", title="Test page")

        transaction.commit()
        self.browser = Browser(self.layer["app"])
        self.browser.handleErrors = False
        browserLogin(self.portal, self.browser)
コード例 #10
0
    def setUp(self):
        from wildcard.lockdown import addCommitCondition
        self.portal = self.layer['portal']
        self.request = self.layer['request']
        self.portal_url = self.portal.absolute_url()
        addCommitCondition("user-area",
            path="/users*",
            request_method="POST")
        folder = createObject(self.portal, 'Folder', 'users')
        createObject(folder, 'News Item', 'test1', title="Test 1")
        createObject(folder, 'News Item', 'test2', title="Test 2")
        createObject(self.portal, 'Document', 'testpage', title="Test page")
        registry = getUtility(IRegistry)
        self._settings = registry.forInterface(ISettings)

        transaction.commit()
        self.browser = Browser(self.layer['app'])
        self.browser.handleErrors = False
        browserLogin(self.portal, self.browser)
コード例 #11
0
 def test_host_condition_wildcard_fail(self):
     addCommitCondition("host-condition",
         host="*.bar.com")
     self.request.set('BASE1', 'http://fob.oar.com')
     checker = CommitChecker(self.request, ('host-condition',))
     self.assertTrue(not checker.can_commit())
コード例 #12
0
 def test_portal_type_condition_fail(self):
     addCommitCondition("pt-condition", portal_type="foobar")
     self.request.set('PARENTS', [FakePT('foboar')])
     checker = CommitChecker(self.request, ('pt-condition', ))
     self.assertTrue(not checker.can_commit())
コード例 #13
0
 def test_request_condition_fail(self):
     addCommitCondition("request-method-condition",
         request_method="POST")
     self.request.set('REQUEST_METHOD', 'GET')
     checker = CommitChecker(self.request, ('request-method-condition',))
     self.assertTrue(not checker.can_commit())
コード例 #14
0
 def test_host_condition_plus_port_success(self):
     addCommitCondition("host-condition",
         host="www.foobar.com:8080")
     self.request.set('BASE1', 'https://www.foobar.com:8080')
     checker = CommitChecker(self.request, ('host-condition',))
     self.assertTrue(checker.can_commit())
コード例 #15
0
 def test_path_condition_fail_with_wildcard(self):
     addCommitCondition("path-condition",
         path="/foo*")
     self.request.set('ACTUAL_URL', self.portal_url + '/fob/oar')
     checker = CommitChecker(self.request, ('path-condition',))
     self.assertTrue(not checker.can_commit())
コード例 #16
0
 def test_request_condition_success_case_insensitive(self):
     addCommitCondition("request-method-condition",
         request_method="put")
     self.request.set('REQUEST_METHOD', 'PUT')
     checker = CommitChecker(self.request, ('request-method-condition',))
     self.assertTrue(checker.can_commit())
コード例 #17
0
 def test_path_condition_success(self):
     addCommitCondition("path-condition",
         path="/foo/bar")
     self.request.set('ACTUAL_URL', self.portal_url + '/foo/bar')
     checker = CommitChecker(self.request, ('path-condition',))
     self.assertTrue(checker.can_commit())
コード例 #18
0
 def test_path_condition_success(self):
     addCommitCondition("path-condition", path="/foo/bar")
     self.request.set('ACTUAL_URL', self.portal_url + '/foo/bar')
     checker = CommitChecker(self.request, ('path-condition', ))
     self.assertTrue(checker.can_commit())
コード例 #19
0
 def test_request_condition_success_case_insensitive(self):
     addCommitCondition("request-method-condition", request_method="put")
     self.request.set('REQUEST_METHOD', 'PUT')
     checker = CommitChecker(self.request, ('request-method-condition', ))
     self.assertTrue(checker.can_commit())
コード例 #20
0
 def test_path_condition_fail_with_wildcard(self):
     addCommitCondition("path-condition", path="/foo*")
     self.request.set('ACTUAL_URL', self.portal_url + '/fob/oar')
     checker = CommitChecker(self.request, ('path-condition', ))
     self.assertTrue(not checker.can_commit())
コード例 #21
0
 def test_request_condition_fail(self):
     addCommitCondition("request-method-condition", request_method="POST")
     self.request.set('REQUEST_METHOD', 'GET')
     checker = CommitChecker(self.request, ('request-method-condition', ))
     self.assertTrue(not checker.can_commit())
コード例 #22
0
 def test_portal_type_condition_fail(self):
     addCommitCondition("pt-condition",
         portal_type="foobar")
     self.request.set('PARENTS', [FakePT('foboar')])
     checker = CommitChecker(self.request, ('pt-condition',))
     self.assertTrue(not checker.can_commit())
コード例 #23
0
from wildcard.lockdown import addCommitCondition

addCommitCondition("Allow logged in on host",
    logged_in=True,
    host="backend.myhost.com")
コード例 #24
0
 def test_host_condition_wildcard_fail(self):
     addCommitCondition("host-condition", host="*.bar.com")
     self.request.set('BASE1', 'http://fob.oar.com')
     checker = CommitChecker(self.request, ('host-condition', ))
     self.assertTrue(not checker.can_commit())
コード例 #25
0
 def test_host_condition_plus_port_success(self):
     addCommitCondition("host-condition", host="www.foobar.com:8080")
     self.request.set('BASE1', 'https://www.foobar.com:8080')
     checker = CommitChecker(self.request, ('host-condition', ))
     self.assertTrue(checker.can_commit())