Search in sources :

Example 1 with CreateRptService

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

the class ObtainRptTokenFlowHttpTest method testObtainRptTokenFlow.

/**
     * Test for the obtaining UMA RPT token
     */
@Test
@Parameters({ "umaAmHost" })
public void testObtainRptTokenFlow(final String umaAmHost) throws Exception {
    showTitle("testObtainRptTokenFlow");
    CreateRptService requesterPermissionTokenService = UmaClientFactory.instance().createRequesterPermissionTokenService(this.metadataConfiguration);
    // Get requester permission token
    RPTResponse requesterPermissionTokenResponse = null;
    try {
        requesterPermissionTokenResponse = requesterPermissionTokenService.createRPT("Bearer " + m_aat.getAccessToken(), umaAmHost);
    } catch (ClientResponseFailure ex) {
        System.err.println(ex.getResponse().getEntity(String.class));
        throw ex;
    }
    UmaTestUtil.assert_(requesterPermissionTokenResponse);
    this.rptToken = requesterPermissionTokenResponse.getRpt();
}
Also used : CreateRptService(org.xdi.oxauth.client.uma.CreateRptService) RPTResponse(org.xdi.oxauth.model.uma.RPTResponse) ClientResponseFailure(org.jboss.resteasy.client.ClientResponseFailure) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 2 with CreateRptService

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

the class ObtainRptTokenFlowHttpTest method testObtainRptTokenFlowWithInvalidAat.

/**
     * Test for the obtaining UMA RPT token
     */
@Test
@Parameters({ "umaAmHost" })
public void testObtainRptTokenFlowWithInvalidAat(final String umaAmHost) throws Exception {
    showTitle("testObtainRptTokenFlowWithInvalidAat");
    CreateRptService requesterPermissionTokenService = UmaClientFactory.instance().createRequesterPermissionTokenService(this.metadataConfiguration);
    // Get requester permission token
    RPTResponse requesterPermissionTokenResponse = null;
    try {
        requesterPermissionTokenResponse = requesterPermissionTokenService.createRPT("Bearer " + m_aat.getAccessToken() + "_invalid", umaAmHost);
    } catch (ClientResponseFailure ex) {
        System.err.println(ex.getResponse().getEntity(String.class));
        assertEquals(ex.getResponse().getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "Unexpected response status");
    }
    assertNull(requesterPermissionTokenResponse, "Requester permission token response is not null");
}
Also used : CreateRptService(org.xdi.oxauth.client.uma.CreateRptService) RPTResponse(org.xdi.oxauth.model.uma.RPTResponse) 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)2 Parameters (org.testng.annotations.Parameters)2 Test (org.testng.annotations.Test)2 BaseTest (org.xdi.oxauth.BaseTest)2 CreateRptService (org.xdi.oxauth.client.uma.CreateRptService)2 RPTResponse (org.xdi.oxauth.model.uma.RPTResponse)2