コード例 #1
0
 @Test
 public void test_cannot_delete_uaa_zone() {
   addMembers();
   assertThat(
       jdbcTemplate.queryForObject(
           "select count(*) from group_membership where group_id in (select id from groups where identity_zone_id=?)",
           new Object[] {IdentityZoneHolder.get().getId()},
           Integer.class),
       is(4));
   assertThat(
       jdbcTemplate.queryForObject(
           "select count(*) from groups where identity_zone_id=?",
           new Object[] {IdentityZoneHolder.get().getId()},
           Integer.class),
       is(4));
   gdao.onApplicationEvent(new EntityDeletedEvent<>(IdentityZone.getUaa(), null));
   assertThat(
       jdbcTemplate.queryForObject(
           "select count(*) from group_membership where group_id in (select id from groups where identity_zone_id=?)",
           new Object[] {IdentityZoneHolder.get().getId()},
           Integer.class),
       is(4));
   assertThat(
       jdbcTemplate.queryForObject(
           "select count(*) from groups where identity_zone_id=?",
           new Object[] {IdentityZoneHolder.get().getId()},
           Integer.class),
       is(4));
 }
コード例 #2
0
 @Test
 public void test_cannot_delete_uaa_provider() {
   IdentityZoneHolder.set(zone);
   addMembers(LOGIN_SERVER);
   assertThat(
       jdbcTemplate.queryForObject(
           "select count(*) from group_membership where group_id in (select id from groups where identity_zone_id=?)",
           new Object[] {IdentityZoneHolder.get().getId()},
           Integer.class),
       is(4));
   assertThat(
       jdbcTemplate.queryForObject(
           "select count(*) from groups where identity_zone_id=?",
           new Object[] {IdentityZoneHolder.get().getId()},
           Integer.class),
       is(3));
   IdentityProvider loginServer =
       new IdentityProvider().setOriginKey(UAA).setIdentityZoneId(zone.getId());
   gdao.onApplicationEvent(new EntityDeletedEvent<>(loginServer, null));
   assertThat(
       jdbcTemplate.queryForObject(
           "select count(*) from group_membership where group_id in (select id from groups where identity_zone_id=?)",
           new Object[] {IdentityZoneHolder.get().getId()},
           Integer.class),
       is(4));
   assertThat(
       jdbcTemplate.queryForObject(
           "select count(*) from groups where identity_zone_id=?",
           new Object[] {IdentityZoneHolder.get().getId()},
           Integer.class),
       is(3));
 }
コード例 #3
0
  @Test
  public void test_zone_deleted() {
    String zoneAdminId = generator.generate();
    addGroup(zoneAdminId, "zones." + zone.getId() + ".admin", IdentityZone.getUaa().getId());
    addMember(zoneAdminId, "m1", "USER", "MEMBER", OriginKeys.UAA);

    IdentityZoneHolder.set(zone);
    addMembers();
    assertThat(
        jdbcTemplate.queryForObject(
            "select count(*) from group_membership where group_id in (select id from groups where identity_zone_id=?)",
            new Object[] {IdentityZoneHolder.get().getId()},
            Integer.class),
        is(4));
    assertThat(
        jdbcTemplate.queryForObject(
            "select count(*) from groups where identity_zone_id=?",
            new Object[] {IdentityZoneHolder.get().getId()},
            Integer.class),
        is(3));
    assertThat(
        jdbcTemplate.queryForObject(
            "select count(*) from external_group_mapping where group_id in (select id from groups where identity_zone_id=?)",
            new Object[] {IdentityZoneHolder.get().getId()},
            Integer.class),
        is(3));
    assertThat(
        jdbcTemplate.queryForObject(
            "select count(*) from group_membership where group_id in (select id from groups where identity_zone_id=? and displayName like ?)",
            new Object[] {
              IdentityZone.getUaa().getId(), "zones." + IdentityZoneHolder.get().getId() + ".%"
            },
            Integer.class),
        is(1));
    assertThat(
        jdbcTemplate.queryForObject(
            "select count(*) from groups where identity_zone_id=? and displayName like ?",
            new Object[] {
              IdentityZone.getUaa().getId(), "zones." + IdentityZoneHolder.get().getId() + ".%"
            },
            Integer.class),
        is(1));
    gdao.onApplicationEvent(new EntityDeletedEvent<>(zone, null));
    assertThat(
        jdbcTemplate.queryForObject(
            "select count(*) from group_membership where group_id in (select id from groups where identity_zone_id=?)",
            new Object[] {IdentityZoneHolder.get().getId()},
            Integer.class),
        is(0));
    assertThat(
        jdbcTemplate.queryForObject(
            "select count(*) from groups where identity_zone_id=?",
            new Object[] {IdentityZoneHolder.get().getId()},
            Integer.class),
        is(0));
    assertThat(
        jdbcTemplate.queryForObject(
            "select count(*) from external_group_mapping where group_id in (select id from groups where identity_zone_id=?)",
            new Object[] {IdentityZoneHolder.get().getId()},
            Integer.class),
        is(0));
    assertThat(
        jdbcTemplate.queryForObject(
            "select count(*) from group_membership where group_id in (select id from groups where identity_zone_id=? and displayName like ?)",
            new Object[] {
              IdentityZone.getUaa().getId(), "zones." + IdentityZoneHolder.get().getId() + ".%"
            },
            Integer.class),
        is(0));
    assertThat(
        jdbcTemplate.queryForObject(
            "select count(*) from groups where identity_zone_id=? and displayName like ?",
            new Object[] {
              IdentityZone.getUaa().getId(), "zones." + IdentityZoneHolder.get().getId() + ".%"
            },
            Integer.class),
        is(0));
  }