Search in sources :

Example 16 with ClientResponseFailure

use of org.jboss.resteasy.client.ClientResponseFailure in project oxAuth by GluuFederation.

the class RegisterResourceSetFlowHttpTest method registerResourceSet.

public String registerResourceSet(List<String> scopes) throws Exception {
    ResourceSetRegistrationService resourceSetRegistrationService = UmaClientFactory.instance().createResourceSetRegistrationService(this.metadataConfiguration);
    // Add resource set description
    ResourceSetResponse resourceSetStatus = null;
    try {
        ResourceSet resourceSet = new ResourceSet();
        resourceSet.setName("Photo Album");
        resourceSet.setIconUri("http://www.example.com/icons/flower.png");
        resourceSet.setScopes(scopes);
        resourceSetStatus = resourceSetRegistrationService.addResourceSet("Bearer " + m_pat.getAccessToken(), resourceSet);
    } catch (ClientResponseFailure ex) {
        System.err.println(ex.getResponse().getEntity(String.class));
        throw ex;
    }
    UmaTestUtil.assert_(resourceSetStatus);
    this.resourceSetId = resourceSetStatus.getId();
    return this.resourceSetId;
}
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)

Example 17 with ClientResponseFailure

use of org.jboss.resteasy.client.ClientResponseFailure in project oxAuth by GluuFederation.

the class RegisterResourceSetFlowHttpTest method testModifyNotExistingResourceSet.

/**
     * Test non existing UMA resource set description modification
     */
@Test(dependsOnMethods = { "testModifyResourceSet" })
public void testModifyNotExistingResourceSet() throws Exception {
    showTitle("testModifyNotExistingResourceSet");
    ResourceSetRegistrationService resourceSetRegistrationService = UmaClientFactory.instance().createResourceSetRegistrationService(this.metadataConfiguration);
    // Modify resource set description with non existing Id
    ResourceSetResponse resourceSetStatus = null;
    try {
        ResourceSet resourceSet = new ResourceSet();
        resourceSet.setName("Photo Album 3");
        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));
        assertEquals(ex.getResponse().getStatus(), Response.Status.NOT_FOUND.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 18 with ClientResponseFailure

use of org.jboss.resteasy.client.ClientResponseFailure in project oxAuth by GluuFederation.

the class GatFlowHttpTest method testHostDetermineRptStatus1.

/**
     * Host determines GAT status
     */
@Test(dependsOnMethods = { "testRequesterObtainsGat" })
public void testHostDetermineRptStatus1() throws Exception {
    showTitle("testHostDetermineRptStatus1");
    // Determine GAT status
    RptIntrospectionResponse tokenStatusResponse = null;
    try {
        tokenStatusResponse = this.rptStatusService.requestRptStatus("Bearer " + pat.getAccessToken(), gat, "");
    } catch (ClientResponseFailure ex) {
        System.err.println(ex.getResponse().getEntity(String.class));
        //			assertEquals(ex.getResponse().getStatus(), Response.Status.BAD_REQUEST.getStatusCode(), "Unexpected response status");
        throw ex;
    }
    assertNotNull(tokenStatusResponse, "Token response status is not invalid");
    assertTrue(tokenStatusResponse.getActive(), "Token response status is not active");
    assertTrue(tokenStatusResponse.getPermissions() == null || tokenStatusResponse.getPermissions().isEmpty());
}
Also used : RptIntrospectionResponse(org.xdi.oxauth.model.uma.RptIntrospectionResponse) ClientResponseFailure(org.jboss.resteasy.client.ClientResponseFailure) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 19 with ClientResponseFailure

use of org.jboss.resteasy.client.ClientResponseFailure in project oxAuth by GluuFederation.

the class GatFlowHttpTest method testRequesterAsksForAuthorization.

//** 4 ******************************************************************************
/**
     * Authorize requester to access resource set
     */
@Test(dependsOnMethods = { "testHostReturnTicketToRequester" })
@Parameters({ "umaAmHost" })
public void testRequesterAsksForAuthorization(final String umaAmHost) throws Exception {
    showTitle("testRequesterAsksForAuthorization");
    // Authorize GAT to access permission ticket
    RptAuthorizationResponse authorizationResponse = null;
    try {
        RptAuthorizationRequest rptAuthorizationRequest = new RptAuthorizationRequest(gat, umaRegisterResourceSetPermissionFlowHttpTest.ticketForFullAccess);
        authorizationResponse = this.authorizationService.requestRptPermissionAuthorization("Bearer " + aat.getAccessToken(), umaAmHost, rptAuthorizationRequest);
    } catch (ClientResponseFailure ex) {
        System.err.println(ex.getResponse().getEntity(String.class));
        throw ex;
    }
    UmaTestUtil.assertAuthorizationRequest(authorizationResponse);
}
Also used : RptAuthorizationResponse(org.xdi.oxauth.model.uma.RptAuthorizationResponse) RptAuthorizationRequest(org.xdi.oxauth.model.uma.RptAuthorizationRequest) ClientResponseFailure(org.jboss.resteasy.client.ClientResponseFailure) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 20 with ClientResponseFailure

use of org.jboss.resteasy.client.ClientResponseFailure in project oxAuth by GluuFederation.

the class MetaDataFlowHttpTest method testGetUmaMetaDataConfiguration.

/**
     * Test for getting meta data configuration
     */
@Test
@Parameters({ "umaMetaDataUrl" })
public void testGetUmaMetaDataConfiguration(final String umaMetaDataUrl) throws Exception {
    showTitle("testGetUmaMetaDataConfiguration");
    UmaConfigurationService metaDataConfigurationService = UmaClientFactory.instance().createMetaDataConfigurationService(umaMetaDataUrl);
    // Get meta data configuration
    UmaConfiguration c = null;
    try {
        c = metaDataConfigurationService.getMetadataConfiguration();
    } catch (ClientResponseFailure ex) {
        System.err.println(ex.getResponse().getEntity(String.class));
        throw ex;
    }
    UmaTestUtil.assert_(c);
}
Also used : UmaConfigurationService(org.xdi.oxauth.client.uma.UmaConfigurationService) UmaConfiguration(org.xdi.oxauth.model.uma.UmaConfiguration) ClientResponseFailure(org.jboss.resteasy.client.ClientResponseFailure) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Aggregations

ClientResponseFailure (org.jboss.resteasy.client.ClientResponseFailure)20 Test (org.testng.annotations.Test)17 BaseTest (org.xdi.oxauth.BaseTest)17 Parameters (org.testng.annotations.Parameters)9 ResourceSetRegistrationService (org.xdi.oxauth.client.uma.ResourceSetRegistrationService)7 RptIntrospectionResponse (org.xdi.oxauth.model.uma.RptIntrospectionResponse)5 ResourceSet (org.xdi.oxauth.model.uma.ResourceSet)4 ResourceSetResponse (org.xdi.oxauth.model.uma.ResourceSetResponse)4 PermissionTicket (org.xdi.oxauth.model.uma.PermissionTicket)3 RptAuthorizationRequest (org.xdi.oxauth.model.uma.RptAuthorizationRequest)3 RptAuthorizationResponse (org.xdi.oxauth.model.uma.RptAuthorizationResponse)3 UmaPermission (org.xdi.oxauth.model.uma.UmaPermission)3 CreateRptService (org.xdi.oxauth.client.uma.CreateRptService)2 PermissionRegistrationService (org.xdi.oxauth.client.uma.PermissionRegistrationService)2 RPTResponse (org.xdi.oxauth.model.uma.RPTResponse)2 MalformedURLException (java.net.MalformedURLException)1 UmaConfigurationService (org.xdi.oxauth.client.uma.UmaConfigurationService)1 ResourceSetWithId (org.xdi.oxauth.model.uma.ResourceSetWithId)1 UmaConfiguration (org.xdi.oxauth.model.uma.UmaConfiguration)1