]> source.dussan.org Git - sonarqube.git/commitdiff
Adding clientauth tests
authorJohn W <jjw-github@johntology.org>
Fri, 14 Mar 2014 01:41:40 +0000 (21:41 -0400)
committerJohn W <jjw-github@johntology.org>
Thu, 20 Mar 2014 04:18:20 +0000 (00:18 -0400)
sonar-application/src/test/java/org/sonar/application/ConnectorsTest.java

index 4d8e9b4773c5c2c7cfc52141cd94820de061e685..20c2bfca4f923675394dc346979de394409a73ff 100644 (file)
@@ -124,7 +124,8 @@ public class ConnectorsTest {
       @Override
       public boolean matches(Object o) {
         Connector c = (Connector) o;
-        return c.getScheme().equals("https") && c.getPort() == 9443;
+        return c.getScheme().equals("https") && c.getPort() == 9443
+                       && c.getProperty("clientAuth").equals("false");
       }
     }));
   }
@@ -256,6 +257,52 @@ public class ConnectorsTest {
     verify(tomcat.getServer(), never()).setShutdown(anyString());
   }
 
+  @Test
+  public void enable_client_auth() throws Exception {
+         
+    Properties p = new Properties();
+
+    p.setProperty("sonar.web.port", "-1");
+    p.setProperty("sonar.web.https.port", "9443");
+    p.setProperty("sonar.web.https.clientAuth", "want");
+    
+    Props props = new Props(p);
+
+    Connectors.configure(tomcat, props);
+
+    verify(tomcat).setConnector(argThat(new ArgumentMatcher<Connector>() {
+        @Override
+        public boolean matches(Object o) {
+          Connector c = (Connector) o;
+          return c.getScheme().equals("https") && c.getProperty("clientAuth").equals("want");
+        }
+      }));
+  }
+
+  @Test
+  public void require_client_auth() throws Exception {
+         
+    Properties p = new Properties();
+
+    p.setProperty("sonar.web.port", "-1");
+    p.setProperty("sonar.web.https.port", "9443");
+    p.setProperty("sonar.web.https.clientAuth", "true");
+    
+    Props props = new Props(p);
+
+    Connectors.configure(tomcat, props);
+
+    verify(tomcat).setConnector(argThat(new ArgumentMatcher<Connector>() {
+        @Override
+        public boolean matches(Object o) {
+          Connector c = (Connector) o;
+          return c.getScheme().equals("https") && c.getProperty("clientAuth").equals("true");
+        }
+      }));
+  }
+  
+
   private static class PropertiesMatcher extends ArgumentMatcher<Connector> {
     private final Map<String, Object> expected;