Search in sources :

Example 6 with ClientResponseFailure

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

the class AccessProtectedResourceFlowHttpTest method testHostDetermineRptStatus1.

/**
     * Host determines RPT status
     */
@Test(dependsOnMethods = { "testRequesterAccessProtectedResourceWithNotEnoughPermissionsRpt" })
@Parameters({ "umaAmHost" })
public void testHostDetermineRptStatus1(final String umaAmHost) throws Exception {
    showTitle("testHostDetermineRptStatus1");
    String resourceSetId = umaRegisterResourceSetFlowHttpTest.resourceSetId;
    // Determine RPT token to status
    RptIntrospectionResponse tokenStatusResponse = null;
    try {
        tokenStatusResponse = this.rptStatusService.requestRptStatus("Bearer " + m_pat.getAccessToken(), this.umaObtainRptTokenFlowHttpTest.rptToken, "");
    } 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) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 7 with ClientResponseFailure

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

the class AccessProtectedResourceFlowHttpTest 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 RPT token to access permission ticket
    RptAuthorizationResponse authorizationResponse = null;
    try {
        RptAuthorizationRequest rptAuthorizationRequest = new RptAuthorizationRequest(this.umaObtainRptTokenFlowHttpTest.rptToken, umaRegisterResourceSetPermissionFlowHttpTest.ticketForFullAccess);
        authorizationResponse = this.rptPermissionAuthorizationService.requestRptPermissionAuthorization("Bearer " + m_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 8 with ClientResponseFailure

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

the class GatFlowHttpTest method testHostDetermineRptStatus2.

/**
     * Host determines GAT status
     */
@Test(dependsOnMethods = { "testRequesterAccessProtectedResourceWithEnoughPermissionsRpt" })
public void testHostDetermineRptStatus2() throws Exception {
    showTitle("testHostDetermineRptStatus2");
    // 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));
        throw ex;
    }
    UmaTestUtil.assert_(tokenStatusResponse);
}
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 9 with ClientResponseFailure

use of org.jboss.resteasy.client.ClientResponseFailure 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 10 with ClientResponseFailure

use of org.jboss.resteasy.client.ClientResponseFailure 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)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