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