]> WPIA git - gigi.git/commitdiff
Adding very basic tests for Security headers
authorFelix Dörre <felix@dogcraft.de>
Thu, 3 Jul 2014 22:10:50 +0000 (00:10 +0200)
committerFelix Dörre <felix@dogcraft.de>
Thu, 3 Jul 2014 22:10:50 +0000 (00:10 +0200)
tests/org/cacert/gigi/TestSecurityHeaders.java [new file with mode: 0644]

diff --git a/tests/org/cacert/gigi/TestSecurityHeaders.java b/tests/org/cacert/gigi/TestSecurityHeaders.java
new file mode 100644 (file)
index 0000000..9df4e22
--- /dev/null
@@ -0,0 +1,31 @@
+package org.cacert.gigi;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.cacert.gigi.testUtils.ManagedTest;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class TestSecurityHeaders extends ManagedTest {
+       @Test
+       public void testSTS() throws IOException {
+               HttpURLConnection uc = (HttpURLConnection) new URL("https://"
+                               + getServerName()).openConnection();
+               assertNotNull(uc.getHeaderField("Strict-Transport-Security"));
+       }
+
+       public void testCSP() throws IOException {
+               HttpURLConnection uc = (HttpURLConnection) new URL("https://"
+                               + getServerName()).openConnection();
+               assertNotNull(uc.getHeaderField("Content-Security-Policy"));
+       }
+       public void testAllowOrigin() throws IOException {
+               HttpURLConnection uc = (HttpURLConnection) new URL("https://"
+                               + getServerName()).openConnection();
+               assertNotNull(uc.getHeaderField("Access-Control-Allow-Origin"));
+
+       }
+}