コード例 #1
0
 def test_URISourceExpression_schemeOnly(self):
     srcExprFull = URISourceExpression("chrome-extension",
                                       "mkfokfffehpeedafpekjeddnmnjhmcmk",
                                       None, None)
     assert srcExprFull.schemeOnly() == URISourceExpression(
         "chrome-extension", None, None, None)
     srcExprIncomplete = URISourceExpression(None, "seclab.nu", None, None)
     assert srcExprIncomplete.schemeOnly() == SourceExpression.INVALID()
コード例 #2
0
 def test_InvalidSourceExpression_match(self):
     """The invalid source expression does not match anything."""
     srcExpr = SourceExpression.INVALID()
     selfURI = SourceExpressionTest.uri_chromeExtension
     assert not srcExpr.matches(SourceExpressionTest.uri_empty, selfURI)
     assert not srcExpr.matches(SourceExpressionTest.uri_urlFull, selfURI)
     assert not srcExpr.matches(SourceExpressionTest.uri_urlSubstring,
                                selfURI)
     assert not srcExpr.matches(SourceExpressionTest.uri_domain, selfURI)
     assert not srcExpr.matches(SourceExpressionTest.uri_data, selfURI)
     assert not srcExpr.matches(URI.INVALID(), selfURI)
     assert not srcExpr.matches(URI.EVAL(), selfURI)
     assert not srcExpr.matches(URI.INLINE(), selfURI)
コード例 #3
0
 def testDirective_init_removeInvalidSourceExpressions(self):
     assert Directive("img-src", [SourceExpression.INVALID()]) == Directive(
         "img-src", [])
コード例 #4
0
 def test_parse_unsupported_scheme_fails(self):
     exprStr = "my-scheme://domain/path"
     srcExpr = SourceExpressionParser(knownSchemes=('http',
                                                    'https')).parse(exprStr)
     assert srcExpr == SourceExpression.INVALID()