Пример #1
0
  @Test
  public void verifyUpdatingServices() {
    this.dao.save(getRegexRegisteredService());
    final List<RegisteredService> services = this.dao.load();

    final AbstractRegisteredService rs =
        (AbstractRegisteredService) this.dao.findServiceById(services.get(0).getId());
    assertNotNull(rs);
    rs.setEvaluationOrder(9999);
    rs.setUsernameAttributeProvider(new DefaultRegisteredServiceUsernameProvider());
    rs.setName("Another Test Service");
    rs.setDescription("The new description");
    rs.setServiceId("https://hello.world");
    rs.setProxyPolicy(new RegexMatchingRegisteredServiceProxyPolicy("https"));
    rs.setAttributeReleasePolicy(new ReturnAllowedAttributeReleasePolicy());
    assertNotNull(this.dao.save(rs));

    final RegisteredService rs3 = this.dao.findServiceById(rs.getId());
    assertEquals(rs3.getName(), rs.getName());
    assertEquals(rs3.getDescription(), rs.getDescription());
    assertEquals(rs3.getEvaluationOrder(), rs.getEvaluationOrder());
    assertEquals(rs3.getUsernameAttributeProvider(), rs.getUsernameAttributeProvider());
    assertEquals(rs3.getProxyPolicy(), rs.getProxyPolicy());
    assertEquals(rs3.getUsernameAttributeProvider(), rs.getUsernameAttributeProvider());
    assertEquals(rs3.getServiceId(), rs.getServiceId());
  }
Пример #2
0
  private static RegisteredService getRegexRegisteredService() {
    final AbstractRegisteredService rs = new RegexRegisteredService();
    rs.setName("Service Name Regex");
    rs.setProxyPolicy(new RefuseRegisteredServiceProxyPolicy());
    rs.setUsernameAttributeProvider(
        new AnonymousRegisteredServiceUsernameAttributeProvider(
            new ShibbolethCompatiblePersistentIdGenerator("hello")));
    rs.setDescription("Service description");
    rs.setServiceId("^http?://.+");
    rs.setTheme("the theme name");
    rs.setEvaluationOrder(123);
    rs.setDescription("Here is another description");
    rs.setRequiredHandlers(new HashSet<>(Lists.newArrayList("handler1", "handler2")));

    final Map<String, RegisteredServiceProperty> propertyMap = new HashMap();
    final DefaultRegisteredServiceProperty property = new DefaultRegisteredServiceProperty();

    final Set<String> values = new HashSet<>();
    values.add("value1");
    values.add("value2");
    property.setValues(values);
    propertyMap.put("field1", property);
    rs.setProperties(propertyMap);

    return rs;
  }