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