def test_whitelist(self): """Test that whitelisted files are properly skipped tested by the content validator.""" self.setup_err() # Build a fake package with a js file that would not validate if it # wasn't whitelisted. mock_package = MockXPI({"foo.js": "tests/resources/content/error.js"}) # Build the mock whitelist. Convert line-endings to unix-style before # building the hash, it should still validate properly as the code that # validates the package converts every js file to unix-style endings # first. ok_('\r\n' in mock_package.read('foo.js')) foo_js = mock_package.read('foo.js').replace('\r\n', '\n') hashes_whitelist = [hashlib.sha256(foo_js).hexdigest()] with patch("appvalidator.testcases.content.hashes_whitelist", hashes_whitelist): eq_(self._run_test(mock_package), 0) self.assert_passes() # Prove that it would fail otherwise. eq_(self._run_test(mock_package), 1) self.assert_failed()
def test_whitelist(self): """Test that whitelisted files are properly skipped tested by the content validator.""" self.setup_err() # Build a fake package with a js file that would not validate if it # wasn't whitelisted. mock_package = MockXPI({"foo.js": "tests/resources/content/error.js"}) # Build the mock whitelist. foo_js = mock_package.read('foo.js') hashes_whitelist = [hashlib.sha256(foo_js).hexdigest()] with patch("appvalidator.testcases.content.hashes_whitelist", hashes_whitelist): eq_(self._run_test(mock_package), 0) self.assert_passes() # Prove that it would fail otherwise. eq_(self._run_test(mock_package), 1) self.assert_failed()
def test_whitelist(self): """Test that whitelisted files are properly skipped tested by the content validator.""" self.setup_err() # Build a fake package with a js file that would not validate if it # wasn't whitelisted. mock_package = MockXPI({"foo.js": "tests/resources/content/error.js"}) # Build the mock whitelist. foo_js = mock_package.read('foo.js') hashes_whitelist = [hashlib.sha256(foo_js).hexdigest()] with patch("appvalidator.testcases.content.hashes_whitelist", hashes_whitelist): eq_(self._run_test(mock_package), 0) self.assert_passes() # Prove that it would fail otherwise. eq_(self._run_test(mock_package), 1) self.assert_failed()