Search in sources :

Example 1 with ResourceSetRegistrationService

use of org.xdi.oxauth.client.uma.ResourceSetRegistrationService in project oxAuth by GluuFederation.

the class RegisterResourceSetFlowHttpTest method testModifyResourceSet.

/**
     * Test UMA resource set description modification
     */
@Test(dependsOnMethods = { "testRegisterResourceSet" })
public void testModifyResourceSet() throws Exception {
    showTitle("testModifyResourceSet");
    ResourceSetRegistrationService resourceSetRegistrationService = UmaClientFactory.instance().createResourceSetRegistrationService(this.metadataConfiguration);
    // Modify resource set description
    ResourceSetResponse resourceSetStatus = null;
    try {
        ResourceSet resourceSet = new ResourceSet();
        resourceSet.setName("Photo Album 2");
        resourceSet.setIconUri("http://www.example.com/icons/flower.png");
        resourceSet.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view", "http://photoz.example.com/dev/scopes/all"));
        resourceSetStatus = resourceSetRegistrationService.updateResourceSet("Bearer " + m_pat.getAccessToken(), this.resourceSetId, resourceSet);
    } catch (ClientResponseFailure ex) {
        System.err.println(ex.getResponse().getEntity(String.class));
        throw ex;
    }
    assertNotNull(resourceSetStatus, "Resource set status is null");
    this.resourceSetId = resourceSetStatus.getId();
    assertNotNull(this.resourceSetId, "Resource set description id is null");
}
Also used : ResourceSetRegistrationService(org.xdi.oxauth.client.uma.ResourceSetRegistrationService) ResourceSetResponse(org.xdi.oxauth.model.uma.ResourceSetResponse) ResourceSet(org.xdi.oxauth.model.uma.ResourceSet) ClientResponseFailure(org.jboss.resteasy.client.ClientResponseFailure) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 2 with ResourceSetRegistrationService

use of org.xdi.oxauth.client.uma.ResourceSetRegistrationService in project oxAuth by GluuFederation.

the class RegisterResourceSetFlowHttpTest method testGetOneResourceSet.

/**
     * Test for getting UMA resource set descriptions
     */
@Test(dependsOnMethods = { "testModifyResourceSet" })
public void testGetOneResourceSet() throws Exception {
    showTitle("testGetResourceSets");
    ResourceSetRegistrationService resourceSetRegistrationService = UmaClientFactory.instance().createResourceSetRegistrationService(this.metadataConfiguration);
    // Get list of resource set descriptions
    ResourceSetWithId resourceSets = null;
    try {
        resourceSets = resourceSetRegistrationService.getResourceSet("Bearer " + m_pat.getAccessToken(), this.resourceSetId);
    } catch (ClientResponseFailure ex) {
        System.err.println(ex.getResponse().getEntity(String.class));
        throw ex;
    }
    assertNotNull(resourceSets, "Resource set descriptions is null");
}
Also used : ResourceSetRegistrationService(org.xdi.oxauth.client.uma.ResourceSetRegistrationService) ResourceSetWithId(org.xdi.oxauth.model.uma.ResourceSetWithId) ClientResponseFailure(org.jboss.resteasy.client.ClientResponseFailure) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 3 with ResourceSetRegistrationService

use of org.xdi.oxauth.client.uma.ResourceSetRegistrationService in project oxAuth by GluuFederation.

the class RegisterResourceSetFlowHttpTest method testModifyResourceSetWithInvalidPat.

/**
     * Test UMA resource set description modification with invalid PAT
     */
@Test(dependsOnMethods = { "testModifyResourceSet" })
public void testModifyResourceSetWithInvalidPat() throws Exception {
    showTitle("testModifyResourceSetWithInvalidPat");
    ResourceSetRegistrationService resourceSetRegistrationService = UmaClientFactory.instance().createResourceSetRegistrationService(this.metadataConfiguration);
    // Modify resource set description with invalid PAT
    ResourceSetResponse resourceSetStatus = null;
    try {
        ResourceSet resourceSet = new ResourceSet();
        resourceSet.setName("Photo Album 4");
        resourceSet.setIconUri("http://www.example.com/icons/flower.png");
        resourceSet.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view", "http://photoz.example.com/dev/scopes/all"));
        resourceSetStatus = resourceSetRegistrationService.updateResourceSet("Bearer " + m_pat.getAccessToken() + "_invalid", this.resourceSetId + "_invalid", resourceSet);
    } catch (ClientResponseFailure ex) {
        System.err.println(ex.getResponse().getEntity(String.class));
        assertEquals(ex.getResponse().getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "Unexpected response status");
    }
    assertNull(resourceSetStatus, "Resource set status is not null");
}
Also used : ResourceSetRegistrationService(org.xdi.oxauth.client.uma.ResourceSetRegistrationService) ResourceSetResponse(org.xdi.oxauth.model.uma.ResourceSetResponse) ResourceSet(org.xdi.oxauth.model.uma.ResourceSet) ClientResponseFailure(org.jboss.resteasy.client.ClientResponseFailure) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 4 with ResourceSetRegistrationService

use of org.xdi.oxauth.client.uma.ResourceSetRegistrationService in project oxAuth by GluuFederation.

the class RegisterResourceSetFlowHttpTest method testDeleteResourceSet.

/**
     * Test for deleting UMA resource set descriptions
     */
@Test(dependsOnMethods = { "testGetResourceSets" })
public void testDeleteResourceSet() throws Exception {
    showTitle("testDeleteResourceSet");
    ResourceSetRegistrationService resourceSetRegistrationService = UmaClientFactory.instance().createResourceSetRegistrationService(this.metadataConfiguration);
    // Delete resource set description
    boolean deleted = false;
    try {
        resourceSetRegistrationService.deleteResourceSet("Bearer " + m_pat.getAccessToken(), this.resourceSetId);
        deleted = true;
    } catch (ClientResponseFailure ex) {
        System.err.println(ex.getResponse().getEntity(String.class));
        throw ex;
    }
    assertTrue(deleted, "Failed to delete resource set description");
}
Also used : ResourceSetRegistrationService(org.xdi.oxauth.client.uma.ResourceSetRegistrationService) ClientResponseFailure(org.jboss.resteasy.client.ClientResponseFailure) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 5 with ResourceSetRegistrationService

use of org.xdi.oxauth.client.uma.ResourceSetRegistrationService in project oxAuth by GluuFederation.

the class RegisterResourceSetFlowHttpTest method testGetResourceSets.

/**
     * Test for getting UMA resource set description
     */
@Test(dependsOnMethods = { "testGetOneResourceSet" })
public void testGetResourceSets() throws Exception {
    showTitle("testGetResourceSets");
    ResourceSetRegistrationService resourceSetRegistrationService = UmaClientFactory.instance().createResourceSetRegistrationService(this.metadataConfiguration);
    // Get list of resource set descriptions
    List<String> resourceSets = null;
    try {
        resourceSets = resourceSetRegistrationService.getResourceSetList("Bearer " + m_pat.getAccessToken(), "");
    } catch (ClientResponseFailure ex) {
        System.err.println(ex.getResponse().getEntity(String.class));
        throw ex;
    }
    assertNotNull(resourceSets, "Resource set descriptions is null");
    assertTrue(resourceSets.contains(this.resourceSetId), "Resource set descriptions list doesn't contain added resource set description");
}
Also used : ResourceSetRegistrationService(org.xdi.oxauth.client.uma.ResourceSetRegistrationService) ClientResponseFailure(org.jboss.resteasy.client.ClientResponseFailure) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Aggregations

ClientResponseFailure (org.jboss.resteasy.client.ClientResponseFailure)7 ResourceSetRegistrationService (org.xdi.oxauth.client.uma.ResourceSetRegistrationService)7 Test (org.testng.annotations.Test)6 BaseTest (org.xdi.oxauth.BaseTest)6 ResourceSet (org.xdi.oxauth.model.uma.ResourceSet)4 ResourceSetResponse (org.xdi.oxauth.model.uma.ResourceSetResponse)4 ResourceSetWithId (org.xdi.oxauth.model.uma.ResourceSetWithId)1