Example #1
0
 def testDirective_withoutPaths(self):
     withPaths = Directive("script-src", [DirectiveTest.sampleSrcExpr2, SelfSourceExpression.SELF()])
     withoutPaths = Directive("script-src", [DirectiveTest.sampleSrcExpr2.removePath(), SelfSourceExpression.SELF()])
     assert withPaths.withoutPaths() == withoutPaths
     assert withoutPaths.withoutPaths() == withoutPaths
     assert Directive.INVALID().withoutPaths() == Directive.INVALID()
     assert Directive.EVAL_SCRIPT_BASE_RESTRICTION().withoutPaths() == Directive.EVAL_SCRIPT_BASE_RESTRICTION()
     assert Directive.INLINE_SCRIPT_BASE_RESTRICTION().withoutPaths() == Directive.INLINE_SCRIPT_BASE_RESTRICTION()
     assert Directive.INLINE_STYLE_BASE_RESTRICTION().withoutPaths() == Directive.INLINE_STYLE_BASE_RESTRICTION()
Example #2
0
 def testDirective_withoutPaths_removeDuplicates(self):
     withPaths = Directive(
         "script-src",
         [DirectiveTest.sampleSrcExpr2, DirectiveTest.sampleSrcExpr3])
     withoutPaths = Directive("script-src",
                              [DirectiveTest.sampleSrcExpr2.removePath()])
     assert withPaths.withoutPaths() == withoutPaths
Example #3
0
 def testDirective_withoutPaths_schemeOnly(self):
     chromeExt = Directive("img-src", [
         URISourceExpression("chrome-extension",
                             "mkfokfffehpeedafpekjeddnmnjhmcmk", None, None)
     ])
     assert chromeExt.withoutPaths(["chrome-extension"]) == Directive(
         "img-src",
         [URISourceExpression("chrome-extension", None, None, None)])
Example #4
0
 def testDirective_withoutPaths(self):
     withPaths = Directive(
         "script-src",
         [DirectiveTest.sampleSrcExpr2,
          SelfSourceExpression.SELF()])
     withoutPaths = Directive("script-src", [
         DirectiveTest.sampleSrcExpr2.removePath(),
         SelfSourceExpression.SELF()
     ])
     assert withPaths.withoutPaths() == withoutPaths
     assert withoutPaths.withoutPaths() == withoutPaths
     assert Directive.INVALID().withoutPaths() == Directive.INVALID()
     assert Directive.EVAL_SCRIPT_BASE_RESTRICTION().withoutPaths(
     ) == Directive.EVAL_SCRIPT_BASE_RESTRICTION()
     assert Directive.INLINE_SCRIPT_BASE_RESTRICTION().withoutPaths(
     ) == Directive.INLINE_SCRIPT_BASE_RESTRICTION()
     assert Directive.INLINE_STYLE_BASE_RESTRICTION().withoutPaths(
     ) == Directive.INLINE_STYLE_BASE_RESTRICTION()
Example #5
0
 def testDirective_withoutPaths_removeDuplicates(self):
     withPaths = Directive("script-src", [DirectiveTest.sampleSrcExpr2, DirectiveTest.sampleSrcExpr3])
     withoutPaths = Directive("script-src", [DirectiveTest.sampleSrcExpr2.removePath()])
     assert withPaths.withoutPaths() == withoutPaths
Example #6
0
 def testDirective_withoutPaths_schemeOnly(self):
     chromeExt = Directive("img-src", [URISourceExpression("chrome-extension", "mkfokfffehpeedafpekjeddnmnjhmcmk", None, None)])
     assert chromeExt.withoutPaths(["chrome-extension"]) == Directive("img-src", [URISourceExpression("chrome-extension", None, None, None)])