use of org.orcid.pojo.ajaxForm.RedirectUri 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.RedirectUri 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));
}
use of org.orcid.pojo.ajaxForm.RedirectUri in project ORCID-Source by ORCID.
the class DeveloperToolsControllerTest method updateClientTest.
@Test
public void updateClientTest() throws Exception {
Client client = new Client();
client.setDisplayName(Text.valueOf("Updated client name"));
client.setShortDescription(Text.valueOf("Updated client description"));
client.setWebsite(Text.valueOf("http://updated.com"));
client.setType(Text.valueOf(ClientType.PUBLIC_CLIENT.value()));
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);
RedirectUri rUri2 = new RedirectUri();
rUri2.setType(Text.valueOf(RedirectUriType.SSO_AUTHENTICATION.value()));
rUri2.setValue(Text.valueOf("http://test2.com"));
redirectUris.add(rUri2);
client.setRedirectUris(redirectUris);
Client updatedClient = developerToolsController.updateClient(client);
verify(mockClientManager, times(1)).edit(Matchers.any(org.orcid.jaxb.model.v3.dev1.client.Client.class), Matchers.eq(false));
assertEquals(CLIENT_2, updatedClient.getClientId().getValue());
}
use of org.orcid.pojo.ajaxForm.RedirectUri in project ORCID-Source by ORCID.
the class DeveloperToolsControllerTest method testClientValidation.
@Test
public void testClientValidation() throws Exception {
// Test empty title
Client client = new Client();
client.setShortDescription(Text.valueOf("This is a 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.getErrors());
assertEquals(result.getErrors().size(), 1);
assertEquals(result.getErrors().get(0), developerToolsController.getMessage("manage.developer_tools.name_not_empty"));
// Test empty description
client = new Client();
client.setDisplayName(Text.valueOf("Client Name"));
client.setWebsite(Text.valueOf("http://client.com"));
redirectUris = new ArrayList<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);
result = developerToolsController.createClient(client);
assertNotNull(result.getErrors());
assertEquals(result.getErrors().size(), 1);
assertEquals(result.getErrors().get(0), developerToolsController.getMessage("manage.developer_tools.description_not_empty"));
// Test empty website
client = new Client();
client.setDisplayName(Text.valueOf("Client Name"));
client.setShortDescription(Text.valueOf("This is a description"));
redirectUris = new ArrayList<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);
result = developerToolsController.createClient(client);
assertNotNull(result.getErrors());
assertEquals(result.getErrors().size(), 1);
assertEquals(result.getErrors().get(0), developerToolsController.getMessage("manage.developer_tools.website_not_empty"));
// Test empty redirect uris
client = new Client();
client.setDisplayName(Text.valueOf("Client Name"));
client.setShortDescription(Text.valueOf("This is a description"));
client.setWebsite(Text.valueOf("http://client.com"));
result = developerToolsController.createClient(client);
assertNotNull(result.getErrors());
assertEquals(result.getErrors().size(), 1);
assertEquals(result.getErrors().get(0), developerToolsController.getMessage("manage.developer_tools.at_least_one"));
}
use of org.orcid.pojo.ajaxForm.RedirectUri 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(0, rUri2.getScopes().size());
} 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