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());
}
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);
}
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);
}
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();
}
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");
}
Aggregations