示例#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()
示例#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
示例#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)])
示例#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()
示例#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
示例#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)])