use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class GroupAdministratorControllerTest method emptyClientTest.
@Test
@Transactional("transactionManager")
@Rollback(true)
public void emptyClientTest() {
Client client = controller.getClient();
client = controller.createClient(client);
assertNotNull(client);
List<String> errors = client.getErrors();
assertEquals(4, errors.size());
assertTrue(errors.contains(controller.getMessage("manage.developer_tools.group.error.display_name.empty")));
assertTrue(errors.contains(controller.getMessage("manage.developer_tools.group.error.website.empty")));
assertTrue(errors.contains(controller.getMessage("manage.developer_tools.group.error.short_description.empty")));
assertTrue(errors.contains(controller.getMessage("common.invalid_url")));
}
use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class GroupAdministratorControllerTest method testInvalidWebsite.
@Test
public void testInvalidWebsite() {
Client client = controller.getClient();
client.setRedirectUris(new ArrayList<RedirectUri>());
client.setDisplayName(Text.valueOf("This is a valid name"));
client.setShortDescription(Text.valueOf("This is a valid description"));
client.setWebsite(Text.valueOf("http:://orcid.org"));
client = controller.createClient(client);
assertNotNull(client);
assertEquals(1, client.getErrors().size());
assertEquals(controller.getMessage("common.invalid_url"), client.getErrors().get(0));
}
use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class ClientsControllerTest method editInvalidClientTest.
@Test
public void editInvalidClientTest() {
// Test invalid fields
Client client = controller.getEmptyClient();
String _151chars = RandomStringUtils.randomAlphanumeric(151);
client.setDisplayName(Text.valueOf(_151chars));
client.setShortDescription(Text.valueOf("description"));
client.setWebsite(Text.valueOf("http://site.com"));
List<RedirectUri> redirectUris = new ArrayList<RedirectUri>();
RedirectUri one = new RedirectUri();
one.setType(Text.valueOf("default"));
one.setValue(Text.valueOf(""));
redirectUris.add(one);
client.setRedirectUris(redirectUris);
client = controller.editClient(client);
List<String> errors = client.getErrors();
assertEquals(2, errors.size());
assertTrue(errors.contains(controller.getMessage("manage.developer_tools.group.error.display_name.150")));
assertTrue(errors.contains(controller.getMessage("manage.developer_tools.empty_redirect_uri")));
// Test invalid redirect uris
client = controller.getEmptyClient();
client.setDisplayName(Text.valueOf("Name"));
client.setShortDescription(Text.valueOf("Description"));
client.setWebsite(Text.valueOf("http://mysite.com"));
redirectUris = new ArrayList<RedirectUri>();
one = new RedirectUri();
one.setType(Text.valueOf("default"));
one.setValue(new Text());
redirectUris.add(one);
client.setRedirectUris(redirectUris);
client = controller.editClient(client);
errors = client.getErrors();
assertEquals(1, errors.size());
assertTrue(errors.contains(controller.getMessage("manage.developer_tools.empty_redirect_uri")));
RedirectUri two = new RedirectUri();
two.setType(Text.valueOf("grant-read-wizard"));
two.setValue(new Text());
redirectUris = new ArrayList<RedirectUri>();
redirectUris.add(two);
client.setRedirectUris(redirectUris);
client = controller.editClient(client);
errors = client.getErrors();
assertEquals(2, errors.size());
assertTrue(errors.contains(controller.getMessage("manage.developer_tools.empty_redirect_uri")));
assertTrue(errors.contains(controller.getMessage("manage.developer_tools.group.error.empty_scopes")));
}
use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class ClientsControllerTest method editClientTest.
@Test
public void editClientTest() {
List<Client> clients = controller.getClients();
int clientsSoFar = clients.size();
assertNotNull(clients);
assertEquals(2, clients.size());
Client client = clients.get(0);
assertEquals("APP-5555555555555555", client.getClientId().getValue());
String random = RandomStringUtils.randomAlphanumeric(20);
client.getDisplayName().setValue("Source Client 1 Updated");
client.getShortDescription().setValue("Updated client description");
client.getWebsite().setValue("http://orcid.org/" + random);
RedirectUri newRedirectUri = new RedirectUri();
newRedirectUri.setValue(Text.valueOf("http://orcid.org/" + random));
newRedirectUri.setType(Text.valueOf(RedirectUriType.DEFAULT.value()));
client.getRedirectUris().add(newRedirectUri);
client = controller.editClient(client);
assertTrue(client.getErrors().isEmpty());
clients = controller.getClients();
assertTrue(clients.size() == clientsSoFar);
boolean found = false;
for (Client c : clients) {
if (client.getClientId().getValue().equals(c.getClientId().getValue())) {
assertEquals("Source Client 1 Updated", client.getDisplayName().getValue());
assertEquals("Updated client description", client.getShortDescription().getValue());
assertEquals("http://orcid.org/" + random, client.getWebsite().getValue());
boolean rUriFound = false;
for (RedirectUri rUri : client.getRedirectUris()) {
if (rUri.getValue().getValue().equals("http://orcid.org/" + random)) {
assertEquals(RedirectUriType.DEFAULT.value(), rUri.getType().getValue());
rUriFound = true;
}
}
assertTrue(rUriFound);
found = true;
break;
}
}
assertTrue(found);
}
use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class ClientsControllerTest method getClientsTest.
@Test
public void getClientsTest() {
List<Client> clients = controller.getClients();
assertNotNull(clients);
assertEquals(2, clients.size());
Client client1 = clients.get(0);
assertEquals("APP-5555555555555555", client1.getClientId().getValue());
Client client2 = clients.get(1);
assertEquals("APP-5555555555555556", client2.getClientId().getValue());
}
Aggregations