use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient in project OA4MP by ncsa.
the class ClientServerTest method testRemove.
public void testRemove(CMTestStoreProvider tp2) throws Exception {
CC cc = setupClients(tp2);
// so approve this
ClientServer server = new ClientServer(tp2.getCOSE());
ApproveRequest approveRequest = RequestFactory.createRequest(cc.adminClient, new TypeClient(), new ActionApprove(), cc.client, null);
server.process(approveRequest);
assert tp2.getClientApprovalStore().containsKey(cc.client.getIdentifier());
assert tp2.getClientApprovalStore().get(cc.client.getIdentifier()).isApproved();
assert !tp2.getPermissionStore().get(cc.adminClient.getIdentifier(), cc.client.getIdentifier()).isEmpty();
AdminClient ac2 = getAdminClient(tp2.getAdminClientStore());
PermissionServer permissionServer = new PermissionServer(tp2.getCOSE());
AddClientRequest addClientRequest = RequestFactory.createRequest(ac2, new TypePermission(), new ActionAdd(), cc.client, null);
permissionServer.process(addClientRequest);
assert !tp2.getPermissionStore().get(ac2.getIdentifier(), cc.client.getIdentifier()).isEmpty();
// ok, so now we have a couple of admin clients with permissions on this client and it is approved. Let's
// see if everything gets cleaned out.
RemoveRequest removeRequest = RequestFactory.createRequest(cc.adminClient, new TypeClient(), new ActionRemove(), cc.client, null);
server.process(removeRequest);
assert !tp2.getClientStore().containsKey(cc.client.getIdentifier());
assert !tp2.getClientApprovalStore().containsKey(cc.client.getIdentifier());
assert tp2.getPermissionStore().get(cc.adminClient.getIdentifier(), cc.client.getIdentifier()).isEmpty();
assert tp2.getPermissionStore().get(ac2.getIdentifier(), cc.client.getIdentifier()).isEmpty();
}
use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient in project OA4MP by ncsa.
the class ClientServerTest method testApprove.
public void testApprove(CMTestStoreProvider tp2) throws Exception {
CC cc = setupClients(tp2);
ApproveRequest req = RequestFactory.createRequest(cc.adminClient, new TypeClient(), new ActionApprove(), cc.client, null);
ClientServer server = new ClientServer(tp2.getCOSE());
ClientResponse resp = (ClientResponse) server.process(req);
ClientApproval approval = tp2.getClientApprovalStore().get(cc.client.getIdentifier());
assert approval != null : "No approval found";
assert approval.isApproved();
}
use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient in project OA4MP by ncsa.
the class ClientServerTest method testUnapprove.
public void testUnapprove(CMTestStoreProvider tp2) throws Exception {
CC cc = setupClients(tp2);
// approve it first.
ApproveRequest req0 = RequestFactory.createRequest(cc.adminClient, new TypeClient(), new ActionApprove(), cc.client, null);
ClientServer server = new ClientServer(tp2.getCOSE());
ClientResponse resp0 = (ClientResponse) server.process(req0);
UnapproveRequest req = RequestFactory.createRequest(cc.adminClient, new TypeClient(), new ActionUnapprove(), cc.client, null);
ClientResponse resp = (ClientResponse) server.process(req);
ClientApproval approval = tp2.getClientApprovalStore().get(cc.client.getIdentifier());
assert approval != null : "No approval found";
assert !approval.isApproved();
}
use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient in project OA4MP by ncsa.
the class ClientServerTest method testCreatePublicClient.
public void testCreatePublicClient(CMTestStoreProvider tp2) throws Exception {
// only needs an admin client and map.
CC cc = setupClients(tp2);
cc.client.setPublicClient(true);
tp2.getClientStore().save(cc.client);
OA2ClientConverter converter = getClientConverter(tp2);
ColumnMap values = new ColumnMap();
converter.toMap(cc.client, values);
tp2.getClientStore().remove(cc.client.getIdentifier());
assert !tp2.getClientStore().containsKey(cc.client.getIdentifier());
// remove the identifier and create it
OA2ClientKeys clientKeys = getClientKeys(tp2);
values.remove(clientKeys.identifier());
values.remove(clientKeys.creationTS());
JSONObject json = new JSONObject();
json.putAll(values);
CreateRequest req = RequestFactory.createRequest(cc.adminClient, new TypeClient(), new ActionCreate(), null, json);
ClientServer server = new ClientServer(tp2.getCOSE());
CreateResponse resp = (CreateResponse) server.process(req);
OA2Client newClient = resp.getClient();
assert tp2.getClientStore().containsKey(newClient.getIdentifier());
// quick and dirty check
OA2Client oldClient = (OA2Client) cc.client;
oldClient.setIdentifier(newClient.getIdentifier());
oldClient.setSecret(newClient.getSecret());
assert oldClient.equals(newClient);
}
use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient in project OA4MP by ncsa.
the class ClientServerTest method testCreate.
public void testCreate(CMTestStoreProvider tp2) throws Exception {
// only needs an admin client and map.
CC cc = setupClients(tp2);
OA2ClientConverter converter = getClientConverter(tp2);
ColumnMap values = new ColumnMap();
converter.toMap(cc.client, values);
tp2.getClientStore().remove(cc.client.getIdentifier());
assert !tp2.getClientStore().containsKey(cc.client.getIdentifier());
// remove the identifier and create it
OA2ClientKeys clientKeys = getClientKeys(tp2);
values.remove(clientKeys.identifier());
values.remove(clientKeys.creationTS());
JSONObject json = new JSONObject();
json.putAll(values);
CreateRequest req = RequestFactory.createRequest(cc.adminClient, new TypeClient(), new ActionCreate(), null, json);
ClientServer server = new ClientServer(tp2.getCOSE());
CreateResponse resp = (CreateResponse) server.process(req);
OA2Client newClient = resp.getClient();
assert tp2.getClientStore().containsKey(newClient.getIdentifier());
// quick and dirty check
OA2Client oldClient = (OA2Client) cc.client;
oldClient.setIdentifier(newClient.getIdentifier());
oldClient.setSecret(newClient.getSecret());
assert oldClient.equals(newClient);
}
Aggregations