Search in sources :

Example 6 with Client

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));
}
Also used : RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) Client(org.orcid.pojo.ajaxForm.Client) Test(org.junit.Test) BaseControllerTest(org.orcid.frontend.web.util.BaseControllerTest)

Example 7 with Client

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));
}
Also used : RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) Client(org.orcid.pojo.ajaxForm.Client) Test(org.junit.Test) BaseControllerTest(org.orcid.frontend.web.util.BaseControllerTest)

Example 8 with Client

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")));
}
Also used : Client(org.orcid.pojo.ajaxForm.Client) Test(org.junit.Test) BaseControllerTest(org.orcid.frontend.web.util.BaseControllerTest) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with Client

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));
}
Also used : RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) Client(org.orcid.pojo.ajaxForm.Client) Test(org.junit.Test) BaseControllerTest(org.orcid.frontend.web.util.BaseControllerTest)

Example 10 with Client

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());
    }
}
Also used : RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) Client(org.orcid.pojo.ajaxForm.Client) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Client (org.orcid.pojo.ajaxForm.Client)12 Test (org.junit.Test)8 RedirectUri (org.orcid.pojo.ajaxForm.RedirectUri)7 BaseControllerTest (org.orcid.frontend.web.util.BaseControllerTest)5 ArrayList (java.util.ArrayList)4 OrcidClient (org.orcid.jaxb.model.clientgroup.OrcidClient)3 DBUnitTest (org.orcid.test.DBUnitTest)3 Text (org.orcid.pojo.ajaxForm.Text)2 Rollback (org.springframework.test.annotation.Rollback)2 Transactional (org.springframework.transaction.annotation.Transactional)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 Produces (javax.ws.rs.Produces)1 OrcidClientGroupManagementException (org.orcid.core.exception.OrcidClientGroupManagementException)1 OrcidClientGroup (org.orcid.jaxb.model.clientgroup.OrcidClientGroup)1 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)1 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)1 ClientSecretEntity (org.orcid.persistence.jpa.entities.ClientSecretEntity)1