use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission in project OA4MP by ncsa.
the class DDServerTests method setupClients.
protected CC setupClients(CMTestStoreProvider tp2) throws Exception {
AdminClient adminClient = getAdminClient(tp2.getAdminClientStore());
ClientApproval clientApproval = tp2.getClientApprovalStore().create();
clientApproval.setIdentifier(adminClient.getIdentifier());
clientApproval.setApproved(true);
clientApproval.setApprover("junit");
tp2.getClientApprovalStore().save(clientApproval);
OA2Client client = getOa2Client(tp2.getClientStore());
PermissionList permissions = tp2.getPermissionStore().get(adminClient.getIdentifier(), client.getIdentifier());
if (permissions.isEmpty()) {
Permission p = tp2.getPermissionStore().create();
p.setAdminID(adminClient.getIdentifier());
p.setClientID(client.getIdentifier());
p.setRead(true);
p.setWrite(true);
p.setDelete(true);
p.setApprove(true);
p.setCreate(true);
tp2.getPermissionStore().save(p);
}
CC cc = new CC();
cc.adminClient = adminClient;
cc.client = client;
return cc;
}
use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission in project OA4MP by ncsa.
the class PermissionServerTest method testGetClients.
public void testGetClients(CMTestStoreProvider tp2) throws Exception {
int clientCount = 4;
CC cc = setupClients(tp2);
List<OA2Client> clients = new LinkedList<>();
for (int i = 0; i < clientCount; i++) {
OA2Client client2 = getOa2Client(tp2.getClientStore());
Permission p = tp2.getPermissionStore().create();
p.setDelete(true);
p.setRead(true);
p.setApprove(true);
p.setCreate(true);
p.setWrite(true);
p.setAdminID(cc.adminClient.getIdentifier());
p.setClientID(client2.getIdentifier());
tp2.getPermissionStore().save(p);
clients.add(client2);
}
clients.add(cc.client);
// need this list of identifiers later for checking that the returned result is correct.
List<Identifier> clientIDs = new LinkedList<>();
for (OA2Client ac : clients) {
clientIDs.add(ac.getIdentifier());
}
PermissionServer permissionServer = new PermissionServer(tp2.getCOSE());
ListClientsRequest req = (ListClientsRequest) RequestFactory.createRequest(cc.adminClient, new TypePermission(), new ActionList(), null, null);
ListClientResponse resp = (ListClientResponse) permissionServer.process(req);
// so add a bunch of admins for a single client and check that they all come back.
List<OA2Client> returnedACs = resp.getClients();
assert returnedACs.size() == clients.size();
for (OA2Client x : returnedACs) {
assert clientIDs.contains(x.getIdentifier());
}
}
use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission in project OA4MP by ncsa.
the class PermissionTest method testPermission.
public void testPermission(PermissionsStore pStore, ClientStore clientStore, AdminClientStore acStore) throws Exception {
AdminClient ac = (AdminClient) acStore.create();
OA2Client c = (OA2Client) clientStore.create();
Permission p = (Permission) pStore.create();
p.setAdminID(ac.getIdentifier());
p.setClientID(c.getIdentifier());
pStore.save(p);
assert pStore.hasEntry(ac.getIdentifier(), c.getIdentifier());
List<Identifier> adminIds = pStore.getAdmins(c.getIdentifier());
assert adminIds.contains(ac.getIdentifier());
List<Identifier> clientIDs = pStore.getClients(ac.getIdentifier());
assert clientIDs.contains(c.getIdentifier());
// now to ttest for multiple additions
pStore.save(p);
pStore.save(p);
assert pStore.getAdmins(c.getIdentifier()).size() == 1;
assert pStore.getClients(ac.getIdentifier()).size() == 1;
OA2Client c1 = (OA2Client) clientStore.create();
Permission p1 = (Permission) pStore.create();
p1.setApprove(false);
p1.setAdminID(ac.getIdentifier());
p1.setClientID(c1.getIdentifier());
pStore.save(p1);
assert pStore.getAdmins(c1.getIdentifier()).size() == 1;
assert pStore.getClients(ac.getIdentifier()).size() == 2;
}
use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission in project OA4MP by ncsa.
the class PermissionTest method testIDs.
public void testIDs(PermissionsStore pStore, ClientStore clientStore, AdminClientStore acStore) throws Exception {
AdminClient ac = (AdminClient) acStore.create();
AdminClient ac2 = (AdminClient) acStore.create();
OA2Client c = (OA2Client) clientStore.create();
Permission p = (Permission) pStore.create();
p.setAdminID(ac.getIdentifier());
p.setClientID(c.getIdentifier());
pStore.save(p);
p.setAdminID(ac2.getIdentifier());
System.out.println(p);
pStore.save(p);
Permission p2 = (Permission) pStore.get(p.getIdentifier());
assert p2.getAdminID().equals(ac2.getIdentifier());
assert pStore.hasEntry(ac2.getIdentifier(), c.getIdentifier());
assert !pStore.hasEntry(ac.getIdentifier(), c.getIdentifier());
}
use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission in project OA4MP by ncsa.
the class OA2PermissionCommands method longFormat.
@Override
protected void longFormat(Identifiable identifiable) {
Permission p = (Permission) identifiable;
sayi("client id=" + p.getClientID());
sayi("admin id=" + p.getAdminID());
sayi("can approve?=" + p.isApprove());
sayi("can read?=" + p.isRead());
sayi("can write?=" + p.isWrite());
sayi("can delete?=" + p.isDelete());
sayi("can create?=" + p.isCreate());
}
Aggregations