Ejemplo n.º 1
0
 public static String getServiceUrl(HttpServletRequest req, ServiceProperties serviceProperties) {
   String serviceUrl = serviceProperties.getService();
   if (serviceUrl != null && !serviceUrl.startsWith("http")) {
     serviceUrl = getJenkinsUrl(req) + serviceUrl;
   }
   return serviceUrl;
 }
 @Test
 public void nullServiceWhenAuthenticateAllTokens() throws Exception {
   ServiceProperties sp = new ServiceProperties();
   sp.setAuthenticateAllArtifacts(true);
   try {
     sp.afterPropertiesSet();
     fail("Expected Exception");
   } catch (IllegalArgumentException success) {
   }
   sp.setAuthenticateAllArtifacts(false);
   try {
     sp.afterPropertiesSet();
     fail("Expected Exception");
   } catch (IllegalArgumentException success) {
   }
 }
 @Override
 public void afterPropertiesSet() throws Exception {
   super.afterPropertiesSet();
   String url = this.getService();
   if (url.endsWith("/")) {
     this.setService(url + "cas_security_check_");
   } else {
     this.setService(url + "/cas_security_check_");
   }
 }
  @Test
  public void testGettersSetters() throws Exception {
    ServiceProperties[] sps = {new ServiceProperties(), new SamlServiceProperties()};
    for (ServiceProperties sp : sps) {
      sp.setSendRenew(false);
      assertThat(sp.isSendRenew()).isFalse();
      sp.setSendRenew(true);
      assertThat(sp.isSendRenew()).isTrue();
      sp.setArtifactParameter("notticket");
      assertThat(sp.getArtifactParameter()).isEqualTo("notticket");
      sp.setServiceParameter("notservice");
      assertThat(sp.getServiceParameter()).isEqualTo("notservice");

      sp.setService("https://mycompany.com/service");
      assertThat(sp.getService()).isEqualTo("https://mycompany.com/service");

      sp.afterPropertiesSet();
    }
  }
 @Test(expected = IllegalArgumentException.class)
 public void detectsMissingService() throws Exception {
   ServiceProperties sp = new ServiceProperties();
   sp.afterPropertiesSet();
 }