def testDirective_asBasicDirectives_single(self): assert Directive.INVALID().asBasicDirectives() == set([]) assert Directive.EVAL_SCRIPT_BASE_RESTRICTION().asBasicDirectives() == set([]) assert Directive.INLINE_SCRIPT_BASE_RESTRICTION().asBasicDirectives() == set([]) assert Directive.INLINE_STYLE_BASE_RESTRICTION().asBasicDirectives() == set([]) sampleDirective = Directive("img-src", [DirectiveTest.sampleSrcExpr1b]) assert sampleDirective.asBasicDirectives() == set([sampleDirective])
def testDirective_asBasicDirectives_multiple(self): sampleDirective = Directive("script-src", [SelfSourceExpression.SELF(), DirectiveTest.sampleSrcExpr1a, DirectiveTest.sampleSrcExpr2, DirectiveTest.sampleSrcExpr3]) assert sampleDirective.asBasicDirectives() == set([Directive("script-src", [SelfSourceExpression.SELF()]), Directive("script-src", [DirectiveTest.sampleSrcExpr1a]), Directive("script-src", [DirectiveTest.sampleSrcExpr2]), Directive("script-src", [DirectiveTest.sampleSrcExpr3])])
def testDirective_asBasicDirectives_single(self): assert Directive.INVALID().asBasicDirectives() == set([]) assert Directive.EVAL_SCRIPT_BASE_RESTRICTION().asBasicDirectives( ) == set([]) assert Directive.INLINE_SCRIPT_BASE_RESTRICTION().asBasicDirectives( ) == set([]) assert Directive.INLINE_STYLE_BASE_RESTRICTION().asBasicDirectives( ) == set([]) sampleDirective = Directive("img-src", [DirectiveTest.sampleSrcExpr1b]) assert sampleDirective.asBasicDirectives() == set([sampleDirective])
def testDirective_asBasicDirectives_multiple(self): sampleDirective = Directive("script-src", [ SelfSourceExpression.SELF(), DirectiveTest.sampleSrcExpr1a, DirectiveTest.sampleSrcExpr2, DirectiveTest.sampleSrcExpr3 ]) assert sampleDirective.asBasicDirectives() == set([ Directive("script-src", [SelfSourceExpression.SELF()]), Directive("script-src", [DirectiveTest.sampleSrcExpr1a]), Directive("script-src", [DirectiveTest.sampleSrcExpr2]), Directive("script-src", [DirectiveTest.sampleSrcExpr3]) ])