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()
def testDirective_withoutPaths_removeDuplicates(self): withPaths = Directive( "script-src", [DirectiveTest.sampleSrcExpr2, DirectiveTest.sampleSrcExpr3]) withoutPaths = Directive("script-src", [DirectiveTest.sampleSrcExpr2.removePath()]) assert withPaths.withoutPaths() == withoutPaths
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)])
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()
def testDirective_withoutPaths_removeDuplicates(self): withPaths = Directive("script-src", [DirectiveTest.sampleSrcExpr2, DirectiveTest.sampleSrcExpr3]) withoutPaths = Directive("script-src", [DirectiveTest.sampleSrcExpr2.removePath()]) assert withPaths.withoutPaths() == withoutPaths
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)])