mirror of
https://github.com/sismics/docs.git
synced 2024-11-14 10:27:55 +01:00
#18: administrators group
This commit is contained in:
parent
a5ce5bf9ec
commit
3b9a66d1d8
@ -152,7 +152,10 @@ public class GroupDao {
|
||||
Map<String, Object> parameterMap = new HashMap<String, Object>();
|
||||
List<String> criteriaList = new ArrayList<String>();
|
||||
|
||||
StringBuilder sb = new StringBuilder("select g.GRP_ID_C as c0, g.GRP_NAME_C as c1, g.GRP_IDPARENT_C as c2, ug.UGP_ID_C ");
|
||||
StringBuilder sb = new StringBuilder("select g.GRP_ID_C as c0, g.GRP_NAME_C as c1, g.GRP_IDPARENT_C as c2 ");
|
||||
if (criteria.getUserId() != null) {
|
||||
sb.append(" , ug.UGP_ID_C ");
|
||||
}
|
||||
sb.append(" from T_GROUP g ");
|
||||
|
||||
// Add search criterias
|
||||
@ -189,7 +192,7 @@ public class GroupDao {
|
||||
.setName((String) o[i++])
|
||||
.setParentId((String) o[i++]);
|
||||
groupDtoList.add(groupDto);
|
||||
if (o[i++] != null) {
|
||||
if (criteria.getUserId() != null && o[i++] != null) {
|
||||
userGroupDtoList.add(groupDto);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
create memory table T_GROUP ( GRP_ID_C varchar(36) not null, GRP_IDPARENT_C varchar(36), GRP_NAME_C varchar(50) not null, GRP_DELETEDATE_D datetime, primary key (GRP_ID_C) );
|
||||
create memory table T_USER_GROUP ( UGP_ID_C varchar(36) not null, UGP_IDUSER_C varchar(36) not null, UGP_IDGROUP_C varchar(36) not null, UGP_DELETEDATE_D datetime, primary key (UGP_ID_C) );
|
||||
|
||||
insert into T_GROUP(GRP_ID_C, GRP_NAME_C) values('administrators', 'administrators');
|
||||
insert into T_USER_GROUP(UGP_ID_C, UGP_IDUSER_C, UGP_IDGROUP_C) values('admin-administrators', 'admin', 'administrators');
|
||||
|
||||
update T_CONFIG set CFG_VALUE_C = '8' where CFG_ID_C = 'DB_VERSION';
|
||||
|
@ -219,7 +219,7 @@ public class TestAclResource extends BaseJerseyTest {
|
||||
.delete();
|
||||
Assert.assertEquals(Status.BAD_REQUEST, Status.fromStatusCode(response.getStatus()));
|
||||
|
||||
// Search target list
|
||||
// Search target list (acl)
|
||||
json = target().path("/acl/target/search")
|
||||
.queryParam("search", "acl")
|
||||
.request()
|
||||
@ -229,5 +229,16 @@ public class TestAclResource extends BaseJerseyTest {
|
||||
Assert.assertEquals(2, users.size());
|
||||
JsonArray groups = json.getJsonArray("groups");
|
||||
Assert.assertEquals(1, groups.size());
|
||||
|
||||
// Search target list (admin)
|
||||
json = target().path("/acl/target/search")
|
||||
.queryParam("search", "admin")
|
||||
.request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, acl1Token)
|
||||
.get(JsonObject.class);
|
||||
users = json.getJsonArray("users");
|
||||
Assert.assertEquals(1, users.size());
|
||||
groups = json.getJsonArray("groups");
|
||||
Assert.assertEquals(1, groups.size());
|
||||
}
|
||||
}
|
@ -41,11 +41,19 @@ public class TestGroupResource extends BaseJerseyTest {
|
||||
clientUtil.createUser("group1", "g112", "g12");
|
||||
String group1Token = clientUtil.login("group1");
|
||||
|
||||
// Check group1 groups (all computed groups)
|
||||
// Check admin groups (all computed groups)
|
||||
JsonObject json = target().path("/user").request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, group1Token)
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, adminToken)
|
||||
.get(JsonObject.class);
|
||||
JsonArray groups = json.getJsonArray("groups");
|
||||
Assert.assertEquals(1, groups.size());
|
||||
Assert.assertEquals("administrators", groups.getString(0));
|
||||
|
||||
// Check group1 groups (all computed groups)
|
||||
json = target().path("/user").request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, group1Token)
|
||||
.get(JsonObject.class);
|
||||
groups = json.getJsonArray("groups");
|
||||
List<String> groupList = new ArrayList<>();
|
||||
for (int i = 0; i < groups.size(); i++) {
|
||||
groupList.add(groups.getString(i));
|
||||
|
Loading…
Reference in New Issue
Block a user