use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class ClientsControllerTest method addClientTest.
@Test
public void addClientTest() {
List<Client> clients = controller.getClients();
int clientsSoFar = clients.size();
assertTrue(clientsSoFar > 0);
Client client = new Client();
client.setAllowAutoDeprecate(Checkbox.valueOf(true));
client.setClientId(Text.valueOf("XXXXXX"));
client.setDisplayName(Text.valueOf("My client name"));
client.setMemberId(Text.valueOf("0000-0000-0000-0000"));
client.setMemberName(Text.valueOf("My member name"));
client.setPersistentTokenEnabled(Checkbox.valueOf(true));
List<RedirectUri> redirectUris = new ArrayList<RedirectUri>();
RedirectUri r1 = new RedirectUri();
r1.setValue(Text.valueOf("http://orcid.org"));
r1.setType(Text.valueOf(RedirectUriType.DEFAULT.value()));
redirectUris.add(r1);
client.setRedirectUris(redirectUris);
client.setShortDescription(Text.valueOf("My short description"));
client.setWebsite(Text.valueOf("http://orcid.org"));
client = controller.createClient(client);
assertTrue(client.getErrors().isEmpty());
assertNotNull(client);
assertNotNull(client.getClientId());
assertTrue(client.getClientId().getValue().startsWith("APP-"));
assertFalse(PojoUtil.isEmpty(client.getClientSecret()));
clients = controller.getClients();
assertTrue(clients.size() > clientsSoFar);
boolean found = false;
for (Client c : clients) {
if (client.getClientId().getValue().equals(c.getClientId().getValue())) {
found = true;
break;
}
}
assertTrue(found);
}
use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class ClientsControllerTest method testInvalidDescription.
@Test
public void testInvalidDescription() {
Client client = controller.getEmptyClient();
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 DeveloperToolsControllerTest method testCrossSiteScriptingOnClientName.
@Test
public void testCrossSiteScriptingOnClientName() throws Exception {
Client client = new Client();
client.setDisplayName(Text.valueOf("<script>alert('name')</script>"));
client.setShortDescription(Text.valueOf("This is a short description"));
client.setWebsite(Text.valueOf("http://client.com"));
List<RedirectUri> redirectUris = new ArrayList<RedirectUri>();
RedirectUri rUri = new RedirectUri();
rUri.setType(Text.valueOf(RedirectUriType.SSO_AUTHENTICATION.value()));
rUri.setValue(Text.valueOf("http://test.com"));
redirectUris.add(rUri);
client.setRedirectUris(redirectUris);
Client result = developerToolsController.createClient(client);
assertNotNull(result);
assertEquals(1, result.getErrors().size());
assertEquals(developerToolsController.getMessage("manage.developer_tools.name.html"), result.getErrors().get(0));
}
use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class DeveloperToolsControllerTest method createClientTest.
@Test
public void createClientTest() throws Exception {
Client client = new Client();
client.setDisplayName(Text.valueOf("Client Name"));
client.setShortDescription(Text.valueOf("This is a test"));
client.setType(Text.valueOf(ClientType.PUBLIC_CLIENT.value()));
client.setWebsite(Text.valueOf("http://client.com"));
List<RedirectUri> redirectUris = new ArrayList<RedirectUri>();
RedirectUri rUri = new RedirectUri();
rUri.setType(Text.valueOf(RedirectUriType.SSO_AUTHENTICATION.value()));
rUri.setValue(Text.valueOf("http://test.com"));
redirectUris.add(rUri);
client.setRedirectUris(redirectUris);
Client result = developerToolsController.createClient(client);
verify(mockClientManager, times(1)).createPublicClient(Matchers.any(org.orcid.jaxb.model.v3.dev1.client.Client.class));
assertEquals(CLIENT_1, result.getClientId().getValue());
}
use of org.orcid.pojo.ajaxForm.Client in project ORCID-Source by ORCID.
the class DeveloperToolsControllerTest method testCrossSiteScriptingOnClientDescription.
@Test
public void testCrossSiteScriptingOnClientDescription() throws Exception {
Client client = new Client();
client.setDisplayName(Text.valueOf("Client Name"));
client.setShortDescription(Text.valueOf("This is a test to show that html is <script>alert('name')</script> throws an error"));
client.setWebsite(Text.valueOf("http://client.com"));
List<RedirectUri> redirectUris = new ArrayList<RedirectUri>();
RedirectUri rUri = new RedirectUri();
rUri.setType(Text.valueOf(RedirectUriType.SSO_AUTHENTICATION.value()));
rUri.setValue(Text.valueOf("http://test.com"));
redirectUris.add(rUri);
client.setRedirectUris(redirectUris);
Client result = developerToolsController.createClient(client);
assertNotNull(result);
assertEquals(1, result.getErrors().size());
assertEquals(developerToolsController.getMessage("manage.developer_tools.description.html"), result.getErrors().get(0));
}
Aggregations