33// SPDX-License-Identifier: Apache-2.0
44package io .securecodebox .persistence .defectdojo .service ;
55
6+ import com .github .tomakehurst .wiremock .http .HttpHeader ;
7+ import com .github .tomakehurst .wiremock .http .HttpHeaders ;
68import com .github .tomakehurst .wiremock .junit5 .WireMockTest ;
79import io .securecodebox .persistence .defectdojo .config .Config ;
810import lombok .Getter ;
911import lombok .experimental .Accessors ;
1012
1113import java .io .IOException ;
1214import java .nio .charset .StandardCharsets ;
15+ import java .time .ZoneId ;
16+ import java .time .ZonedDateTime ;
17+ import java .time .format .DateTimeFormatter ;
1318import java .util .Objects ;
1419
1520/**
@@ -34,4 +39,24 @@ String readFixtureFile(String fixtureFile) throws IOException {
3439 return new String (bytes , StandardCharsets .UTF_8 );
3540 }
3641 }
42+
43+ HttpHeaders responseHeaders (int contentLength ) {
44+ return HttpHeaders .noHeaders ().plus (
45+ new HttpHeader ("date" , now ()),
46+ new HttpHeader ("content-type" , "application/json" ),
47+ new HttpHeader ("content-length" , String .valueOf (contentLength )),
48+ new HttpHeader ("allow" , "GET, PUT, PATCH, DELETE, HEAD, OPTIONS" ),
49+ new HttpHeader ("x-frame-options" , "DENY" ),
50+ new HttpHeader ("x-content-type-options" , "nosniff" ),
51+ new HttpHeader ("referrer-policy" , "same-origin" ),
52+ new HttpHeader ("cross-origin-opener-policy" , "same-origin" ),
53+ new HttpHeader ("vary" , "Cookie" ),
54+ new HttpHeader ("strict-transport-security" , "max-age=31536000; includeSubDomains" )
55+ );
56+ }
57+
58+ String now () {
59+ return ZonedDateTime .now (ZoneId .of ("Europe/Berlin" ))
60+ .format (DateTimeFormatter .RFC_1123_DATE_TIME );
61+ }
3762}
0 commit comments