示例#1
0
 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])
示例#2
0
 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])])
示例#3
0
 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])
示例#4
0
 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])
     ])