3
3
// SPDX-License-Identifier: Apache-2.0
4
4
package io .securecodebox .persistence .defectdojo .service ;
5
5
6
+ import com .github .tomakehurst .wiremock .http .HttpHeader ;
7
+ import com .github .tomakehurst .wiremock .http .HttpHeaders ;
6
8
import com .github .tomakehurst .wiremock .junit5 .WireMockTest ;
7
9
import io .securecodebox .persistence .defectdojo .config .Config ;
8
10
import lombok .Getter ;
9
11
import lombok .experimental .Accessors ;
10
12
11
13
import java .io .IOException ;
12
14
import java .nio .charset .StandardCharsets ;
15
+ import java .time .ZoneId ;
16
+ import java .time .ZonedDateTime ;
17
+ import java .time .format .DateTimeFormatter ;
13
18
import java .util .Objects ;
14
19
15
20
/**
@@ -34,4 +39,24 @@ String readFixtureFile(String fixtureFile) throws IOException {
34
39
return new String (bytes , StandardCharsets .UTF_8 );
35
40
}
36
41
}
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
+ }
37
62
}
0 commit comments