Skip to content

Commit 448894a

Browse files
committed
refactor: modify constants creation to reduce diff when a new value is added
1 parent 6bd90f2 commit 448894a

File tree

1 file changed

+87
-87
lines changed

1 file changed

+87
-87
lines changed

src/test/java/ru/mystamps/web/support/spring/security/ContentSecurityPolicyHeaderWriterTest.java

Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,19 @@ public void onIndexPageWithResourcesFromCdn() {
118118
"report-uri https://my-stamps.ru/site/csp/reports"
119119
)
120120
.contains(
121-
"style-src "
122-
+ "'report-sample' "
123-
+ "https://cdn.jsdelivr.net "
124-
+ "https://stamps.filezz.ru "
125-
+ "https://maxcdn.bootstrapcdn.com"
121+
"style-src"
122+
+ " 'report-sample'"
123+
+ " https://cdn.jsdelivr.net"
124+
+ " https://stamps.filezz.ru"
125+
+ " https://maxcdn.bootstrapcdn.com"
126126
)
127127
.contains(
128-
"script-src "
129-
+ "'report-sample' "
130-
+ "'unsafe-inline' "
131-
+ "https://stamps.filezz.ru "
132-
+ "https://maxcdn.bootstrapcdn.com "
133-
+ "https://yandex.st"
128+
"script-src"
129+
+ " 'report-sample'"
130+
+ " 'unsafe-inline'"
131+
+ " https://stamps.filezz.ru"
132+
+ " https://maxcdn.bootstrapcdn.com"
133+
+ " https://yandex.st"
134134
)
135135
.hasSize(NUMBER_OF_DIRECTIVES_ON_STANDARD_PAGES);
136136
}
@@ -148,19 +148,19 @@ public void onCollectionInfoPageWithLocalResources() {
148148
// test only the directives that differ from the index page
149149
assertThat(directives)
150150
.contains(
151-
"style-src "
152-
+ "'report-sample' "
153-
+ "https://cdn.jsdelivr.net "
154-
+ "'self' "
155-
+ "https://www.gstatic.com "
156-
+ "'sha256-/kXZODfqoc2myS1eI6wr0HH8lUt+vRhW8H/oL+YJcMg='"
151+
"style-src"
152+
+ " 'report-sample'"
153+
+ " https://cdn.jsdelivr.net"
154+
+ " 'self'"
155+
+ " https://www.gstatic.com"
156+
+ " 'sha256-/kXZODfqoc2myS1eI6wr0HH8lUt+vRhW8H/oL+YJcMg='"
157157
)
158158
.contains(
159-
"script-src "
160-
+ "'report-sample' "
161-
+ "'unsafe-inline' "
162-
+ "'self' "
163-
+ "https://www.gstatic.com"
159+
"script-src"
160+
+ " 'report-sample'"
161+
+ " 'unsafe-inline'"
162+
+ " 'self'"
163+
+ " https://www.gstatic.com"
164164
)
165165
// hope that all other directives are the same as on the index page
166166
.hasSize(NUMBER_OF_DIRECTIVES_ON_STANDARD_PAGES);
@@ -179,22 +179,22 @@ public void onCollectionInfoPageWithResourcesFromCdn() {
179179
// test only the directives that differ from the index page
180180
assertThat(directives)
181181
.contains(
182-
"style-src "
183-
+ "'report-sample' "
184-
+ "https://cdn.jsdelivr.net "
185-
+ "https://stamps.filezz.ru "
186-
+ "https://maxcdn.bootstrapcdn.com "
187-
+ "https://www.gstatic.com "
188-
+ "'sha256-/kXZODfqoc2myS1eI6wr0HH8lUt+vRhW8H/oL+YJcMg='"
182+
"style-src"
183+
+ " 'report-sample'"
184+
+ " https://cdn.jsdelivr.net"
185+
+ " https://stamps.filezz.ru"
186+
+ " https://maxcdn.bootstrapcdn.com"
187+
+ " https://www.gstatic.com"
188+
+ " 'sha256-/kXZODfqoc2myS1eI6wr0HH8lUt+vRhW8H/oL+YJcMg='"
189189
)
190190
.contains(
191-
"script-src "
192-
+ "'report-sample' "
193-
+ "'unsafe-inline' "
194-
+ "https://stamps.filezz.ru "
195-
+ "https://maxcdn.bootstrapcdn.com "
196-
+ "https://yandex.st "
197-
+ "https://www.gstatic.com"
191+
"script-src"
192+
+ " 'report-sample'"
193+
+ " 'unsafe-inline'"
194+
+ " https://stamps.filezz.ru"
195+
+ " https://maxcdn.bootstrapcdn.com"
196+
+ " https://yandex.st"
197+
+ " https://www.gstatic.com"
198198
)
199199
// hope that all other directives are the same as on the index page
200200
.hasSize(NUMBER_OF_DIRECTIVES_ON_STANDARD_PAGES);
@@ -215,11 +215,11 @@ public void onSeriesAddImagePageWithLocalResources() {
215215
// test only the directives that are differ from the index page
216216
assertThat(directives)
217217
.contains(
218-
"style-src "
219-
+ "'report-sample' "
220-
+ "https://cdn.jsdelivr.net "
221-
+ "'self' "
222-
+ "'sha256-DpmxvnMJIlwkpmmAANZYNzmyfnX2PQCBDO4CB2BFjzU='"
218+
"style-src"
219+
+ " 'report-sample'"
220+
+ " https://cdn.jsdelivr.net"
221+
+ " 'self'"
222+
+ " 'sha256-DpmxvnMJIlwkpmmAANZYNzmyfnX2PQCBDO4CB2BFjzU='"
223223
)
224224
.contains("connect-src 'self'")
225225
// hope that all other directives are the same as on the index page
@@ -242,21 +242,21 @@ public void onSeriesAddImagePageWithResourcesFromCdn() {
242242
// test only the directives that are differ from the index page
243243
assertThat(directives)
244244
.contains(
245-
"style-src "
246-
+ "'report-sample' "
247-
+ "https://cdn.jsdelivr.net "
248-
+ "https://stamps.filezz.ru "
249-
+ "https://maxcdn.bootstrapcdn.com "
250-
+ "'sha256-DpmxvnMJIlwkpmmAANZYNzmyfnX2PQCBDO4CB2BFjzU='"
245+
"style-src"
246+
+ " 'report-sample'"
247+
+ " https://cdn.jsdelivr.net"
248+
+ " https://stamps.filezz.ru"
249+
+ " https://maxcdn.bootstrapcdn.com"
250+
+ " 'sha256-DpmxvnMJIlwkpmmAANZYNzmyfnX2PQCBDO4CB2BFjzU='"
251251
)
252252
.contains(
253-
"script-src "
254-
+ "'report-sample' "
255-
+ "'unsafe-inline' "
256-
+ "https://stamps.filezz.ru "
257-
+ "https://maxcdn.bootstrapcdn.com "
258-
+ "https://yandex.st "
259-
+ "https://unpkg.com"
253+
"script-src"
254+
+ " 'report-sample'"
255+
+ " 'unsafe-inline'"
256+
+ " https://stamps.filezz.ru"
257+
+ " https://maxcdn.bootstrapcdn.com"
258+
+ " https://yandex.st"
259+
+ " https://unpkg.com"
260260
)
261261
.contains("connect-src 'self'")
262262
// hope that all other directives are the same as on the index page
@@ -277,19 +277,19 @@ public void onSeriesAddPageWithLocalResources() {
277277
// test only the directives that differ from the index page
278278
assertThat(directives)
279279
.contains(
280-
"style-src "
281-
+ "'report-sample' "
282-
+ "https://cdn.jsdelivr.net "
283-
+ "'self' "
284-
+ "'sha256-DpmxvnMJIlwkpmmAANZYNzmyfnX2PQCBDO4CB2BFjzU=' "
285-
+ "https://cdnjs.cloudflare.com"
280+
"style-src"
281+
+ " 'report-sample'"
282+
+ " https://cdn.jsdelivr.net"
283+
+ " 'self'"
284+
+ " 'sha256-DpmxvnMJIlwkpmmAANZYNzmyfnX2PQCBDO4CB2BFjzU='"
285+
+ " https://cdnjs.cloudflare.com"
286286
)
287287
.contains(
288-
"script-src "
289-
+ "'report-sample' "
290-
+ "'unsafe-inline' "
291-
+ "'self' "
292-
+ "https://cdnjs.cloudflare.com"
288+
"script-src"
289+
+ " 'report-sample'"
290+
+ " 'unsafe-inline'"
291+
+ " 'self'"
292+
+ " https://cdnjs.cloudflare.com"
293293
)
294294
.contains("connect-src 'self'")
295295
// hope that all other directives are the same as on the index page
@@ -309,22 +309,22 @@ public void onSeriesAddPageWithResourcesFromCdn() {
309309
// test only the directives that differ from the index page
310310
assertThat(directives)
311311
.contains(
312-
"style-src "
313-
+ "'report-sample' "
314-
+ "https://cdn.jsdelivr.net "
315-
+ "https://stamps.filezz.ru "
316-
+ "https://maxcdn.bootstrapcdn.com "
317-
+ "'sha256-DpmxvnMJIlwkpmmAANZYNzmyfnX2PQCBDO4CB2BFjzU=' "
318-
+ "https://cdnjs.cloudflare.com"
312+
"style-src"
313+
+ " 'report-sample'"
314+
+ " https://cdn.jsdelivr.net"
315+
+ " https://stamps.filezz.ru"
316+
+ " https://maxcdn.bootstrapcdn.com"
317+
+ " 'sha256-DpmxvnMJIlwkpmmAANZYNzmyfnX2PQCBDO4CB2BFjzU='"
318+
+ " https://cdnjs.cloudflare.com"
319319
)
320320
.contains(
321-
"script-src "
322-
+ "'report-sample' "
323-
+ "'unsafe-inline' "
324-
+ "https://stamps.filezz.ru "
325-
+ "https://maxcdn.bootstrapcdn.com "
326-
+ "https://yandex.st "
327-
+ "https://cdnjs.cloudflare.com"
321+
"script-src"
322+
+ " 'report-sample'"
323+
+ " 'unsafe-inline'"
324+
+ " https://stamps.filezz.ru"
325+
+ " https://maxcdn.bootstrapcdn.com"
326+
+ " https://yandex.st"
327+
+ " https://cdnjs.cloudflare.com"
328328
)
329329
.contains("connect-src 'self'")
330330
// hope that all other directives are the same as on the index page
@@ -344,9 +344,9 @@ public void onH2ConsoleWithLocalResources() {
344344
// test only the directives that are differ from the index page
345345
assertThat(directives).
346346
contains(
347-
"style-src "
348-
+ "'report-sample' "
349-
+ "https://cdn.jsdelivr.net"
347+
"style-src"
348+
+ " 'report-sample'"
349+
+ " https://cdn.jsdelivr.net"
350350
+ " 'self'"
351351
+ " 'sha256-biLFinpqYMtWHmXfkA1BPeCY0/fNt46SAZ+BBk5YUog='"
352352
+ " 'sha256-aqNNdDLnnrDOnTNdkJpYlAxKVJtLt9CtFLklmInuUAE='"
@@ -376,11 +376,11 @@ public void onH2ConsoleWithResourcesFromCdn() {
376376
assertThat(directives)
377377
// "style-src" directive should be the same as for the index page
378378
.contains(
379-
"style-src "
380-
+ "'report-sample' "
381-
+ "https://cdn.jsdelivr.net "
382-
+ "https://stamps.filezz.ru "
383-
+ "https://maxcdn.bootstrapcdn.com"
379+
"style-src"
380+
+ " 'report-sample'"
381+
+ " https://cdn.jsdelivr.net"
382+
+ " https://stamps.filezz.ru"
383+
+ " https://maxcdn.bootstrapcdn.com"
384384
)
385385
.doesNotContain("child-src 'self'")
386386
// hope that all other directives are the same as on the index page

0 commit comments

Comments
 (0)