File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -50,4 +50,44 @@ public function testCreateShouldReturnPolicy(): void
5050
5151 self ::assertSame ($ expected , $ result ->getDirectives ());
5252 }
53+
54+ public function testCreateShouldAddDirectiveWhichIsPresentInCustomButNotDefaultConfiguration (): void
55+ {
56+ $ policyFactory = new PolicyFactory ();
57+ $ nonceMock = $ this ->createMock (Nonce::class);
58+
59+ $ defaultDirective = [
60+ 'base-uri ' => [
61+ 'self ' ,
62+ ],
63+ 'script-src ' => [
64+ 'self ' ,
65+ ],
66+ ];
67+ $ customDirective = [
68+ 'script-src ' => [
69+ '{nonce} ' ,
70+ ],
71+ 'worker-src ' => [
72+ 'self ' ,
73+ ],
74+ ];
75+
76+ $ expected = [
77+ 'base-uri ' => [
78+ "'self' " ,
79+ ],
80+ 'script-src ' => [
81+ "'self' " ,
82+ "'nonce-' " ,
83+ ],
84+ 'worker-src ' => [
85+ 'self ' ,
86+ ],
87+ ];
88+
89+ $ result = $ policyFactory ->create ($ nonceMock , $ defaultDirective , $ customDirective );
90+
91+ self ::assertSame ($ expected , $ result ->getDirectives ());
92+ }
5393}
You can’t perform that action at this time.
0 commit comments