use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class GroupAdministratorControllerTest method testInvalidDescription.
@Test
public void testInvalidDescription() {
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 <a>invalid</a> description"));
client.setWebsite(Text.valueOf("http://www.orcid.org"));
client = controller.createClient(client);
assertNotNull(client);
assertEquals(1, client.getErrors().size());
assertEquals(controller.getMessage("manage.developer_tools.group.error.short_description.html"), client.getErrors().get(0));
}
use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class GroupAdministratorControllerTest method testInvalidName.
@Test
public void testInvalidName() {
Client client = controller.getClient();
client.setRedirectUris(new ArrayList<RedirectUri>());
client.setDisplayName(Text.valueOf("This is a <a>invalid</a> name"));
client.setShortDescription(Text.valueOf("This is a valid description"));
client.setWebsite(Text.valueOf("http://www.orcid.org"));
client = controller.createClient(client);
assertNotNull(client);
assertEquals(1, client.getErrors().size());
assertEquals(controller.getMessage("manage.developer_tools.group.error.display_name.html"), client.getErrors().get(0));
}
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 ManageMembersControllerTest method findClientTest.
@Test
public void findClientTest() throws Exception {
//Client with all redirect uris default
Client client_0002 = manageMembers.findClient("APP-0000000000000002");
assertNotNull(client_0002);
assertNotNull(client_0002.getDisplayName());
assertEquals("Client # 2", client_0002.getDisplayName().getValue());
assertNotNull(client_0002.getRedirectUris());
assertEquals(1, client_0002.getRedirectUris().size());
assertEquals("http://www.google.com/APP-0000000000000002/redirect/oauth", client_0002.getRedirectUris().get(0).getValue().getValue());
//Client with redirect uri not default
Client client_0003 = manageMembers.findClient("APP-0000000000000003");
assertNotNull(client_0003);
assertNotNull(client_0003.getDisplayName());
assertEquals("Client # 3", client_0003.getDisplayName().getValue());
assertNotNull(client_0003.getRedirectUris());
assertEquals(2, client_0003.getRedirectUris().size());
RedirectUri rUri1 = client_0003.getRedirectUris().get(0);
if ("http://www.google.com/APP-0000000000000003/redirect/oauth".equals(rUri1.getValue().getValue())) {
assertNotNull(rUri1.getType());
assertEquals("default", rUri1.getType().getValue());
assertNotNull(rUri1.getScopes());
assertEquals(0, rUri1.getScopes().size());
} else if ("http://www.google.com/APP-0000000000000003/redirect/oauth/grant_read_wizard".equals(rUri1.getValue().getValue())) {
assertNotNull(rUri1.getType());
assertEquals("grant-read-wizard", rUri1.getType().getValue());
assertNotNull(rUri1.getScopes());
assertEquals(1, rUri1.getScopes().size());
assertEquals("/funding/read-limited", rUri1.getScopes().get(0));
} else {
fail("Invalid redirect uri: " + rUri1.getValue().getValue());
}
RedirectUri rUri2 = client_0003.getRedirectUris().get(1);
if ("http://www.google.com/APP-0000000000000003/redirect/oauth".equals(rUri2.getValue().getValue())) {
assertNotNull(rUri2.getType());
assertEquals("default", rUri2.getType().getValue());
assertNotNull(rUri2.getScopes());
assertEquals(1, rUri2.getScopes().size());
assertEquals("", rUri2.getScopes().get(0));
} else if ("http://www.google.com/APP-0000000000000003/redirect/oauth/grant_read_wizard".equals(rUri2.getValue().getValue())) {
assertNotNull(rUri2.getType());
assertEquals("grant-read-wizard", rUri2.getType().getValue());
assertNotNull(rUri2.getScopes());
assertEquals(1, rUri2.getScopes().size());
assertEquals("/funding/read-limited", rUri2.getScopes().get(0));
} else {
fail("Invalid redirect uri: " + rUri2.getValue().getValue());
}
}
Aggregations