示例#1
0
  @Test
  public void testupdateSecurityRules() {
    AdministratorGeoStoreClient adminClient = new AdministratorGeoStoreClient();
    adminClient.setGeostoreRestUrl("http://localhost:9191/geostore/rest");
    adminClient.setUsername("admin");
    adminClient.setPassword("admin");

    createDefaultCategory();

    RESTResource res = new RESTResource();
    res.setCategory(new RESTCategory(DEFAULTCATEGORYNAME));

    String timeid = Long.toString(System.currentTimeMillis());
    res.setName("rest_test_resource_" + timeid);

    User u1 = new User();
    u1.setName("u1_" + timeid);
    u1.setRole(Role.USER);
    Long userId = adminClient.insert(u1);

    UserGroup g1 = new UserGroup();
    g1.setGroupName("g1_" + timeid);
    Long groupId = adminClient.insertUserGroup(g1);

    Long id = client.insert(res);
    List<SecurityRule> ruleList = new ArrayList<SecurityRule>();

    SecurityRule rule = new SecurityRule();
    rule.setCanRead(true);
    rule.setCanWrite(true);
    User user = new User();
    user.setId(userId);
    rule.setUser(user);
    ruleList.add(rule);

    rule = new SecurityRule();
    rule.setCanRead(true);
    rule.setCanWrite(false);
    UserGroup group = new UserGroup();
    group.setId(groupId);
    rule.setGroup(group);
    ruleList.add(rule);

    SecurityRuleList rules = new SecurityRuleList(ruleList);
    client.updateSecurityRules(id, rules);

    SecurityRuleList writtenRules = client.getSecurityRules(id);
    assertNotNull(writtenRules.getList());
    assertEquals(2, rules.getList().size());
  }
示例#2
0
  @Test
  public void testDefaultSecurityRules() {
    createDefaultCategory();

    RESTResource res = new RESTResource();
    res.setCategory(new RESTCategory(DEFAULTCATEGORYNAME));

    String timeid = Long.toString(System.currentTimeMillis());
    res.setName("rest_test_resource_" + timeid);

    Long id = client.insert(res);

    SecurityRuleList rules = client.getSecurityRules(id);
    assertNotNull(rules.getList());
    assertEquals(1, rules.getList().size());
  }