use of edu.uiuc.ncsa.security.oauth_2_0.OA2ClientConverter 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