use of org.jboss.resteasy.client.ClientResponseFailure in project oxAuth by GluuFederation.
the class RegisterResourceSetFlowHttpTest method testModifyResourceSet.
/**
* Test UMA resource set description modification
*/
@Test(dependsOnMethods = { "testRegisterResourceSet" })
public void testModifyResourceSet() throws Exception {
showTitle("testModifyResourceSet");
ResourceSetRegistrationService resourceSetRegistrationService = UmaClientFactory.instance().createResourceSetRegistrationService(this.metadataConfiguration);
// Modify resource set description
ResourceSetResponse resourceSetStatus = null;
try {
ResourceSet resourceSet = new ResourceSet();
resourceSet.setName("Photo Album 2");
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));
throw ex;
}
assertNotNull(resourceSetStatus, "Resource set status is null");
this.resourceSetId = resourceSetStatus.getId();
assertNotNull(this.resourceSetId, "Resource set description id is null");
}
use of org.jboss.resteasy.client.ClientResponseFailure in project oxAuth by GluuFederation.
the class RegisterResourceSetFlowHttpTest method testGetOneResourceSet.
/**
* Test for getting UMA resource set descriptions
*/
@Test(dependsOnMethods = { "testModifyResourceSet" })
public void testGetOneResourceSet() throws Exception {
showTitle("testGetResourceSets");
ResourceSetRegistrationService resourceSetRegistrationService = UmaClientFactory.instance().createResourceSetRegistrationService(this.metadataConfiguration);
// Get list of resource set descriptions
ResourceSetWithId resourceSets = null;
try {
resourceSets = resourceSetRegistrationService.getResourceSet("Bearer " + m_pat.getAccessToken(), this.resourceSetId);
} catch (ClientResponseFailure ex) {
System.err.println(ex.getResponse().getEntity(String.class));
throw ex;
}
assertNotNull(resourceSets, "Resource set descriptions is null");
}
use of org.jboss.resteasy.client.ClientResponseFailure in project oxAuth by GluuFederation.
the class RegisterResourceSetPermissionFlowHttpTest method testRegisterResourceSetPermissionForInvalidResource.
/**
* Test for registering permissions for resource set
*/
@Test
@Parameters({ "umaAmHost" })
public void testRegisterResourceSetPermissionForInvalidResource(final String umaAmHost) throws Exception {
showTitle("testRegisterResourceSetPermissionForInvalidResource");
PermissionRegistrationService resourceSetPermissionRegistrationService = UmaClientFactory.instance().createResourceSetPermissionRegistrationService(this.metadataConfiguration);
// Register permissions for resource set
UmaPermission resourceSetPermissionRequest = new UmaPermission();
resourceSetPermissionRequest.setResourceSetId(this.umaRegisterResourceSetFlowHttpTest.resourceSetId + "1");
resourceSetPermissionRequest.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view", "http://photoz.example.com/dev/scopes/all"));
PermissionTicket resourceSetPermissionTiket = null;
try {
resourceSetPermissionTiket = resourceSetPermissionRegistrationService.registerResourceSetPermission("Bearer " + this.umaRegisterResourceSetFlowHttpTest.m_pat.getAccessToken(), umaAmHost, resourceSetPermissionRequest);
} catch (ClientResponseFailure ex) {
System.err.println(ex.getResponse().getEntity(String.class));
assertEquals(ex.getResponse().getStatus(), Response.Status.BAD_REQUEST.getStatusCode(), "Unexpected response status");
}
assertNull(resourceSetPermissionTiket, "Resource set permission is not null");
}
use of org.jboss.resteasy.client.ClientResponseFailure in project oxAuth by GluuFederation.
the class RegisterResourceSetPermissionFlowHttpTest method registerResourceSetPermission.
public String registerResourceSetPermission(final String umaAmHost, String resourceSetId, List<String> scopes) throws Exception {
PermissionRegistrationService resourceSetPermissionRegistrationService = UmaClientFactory.instance().createResourceSetPermissionRegistrationService(this.metadataConfiguration);
// Register permissions for resource set
UmaPermission resourceSetPermissionRequest = new UmaPermission();
resourceSetPermissionRequest.setResourceSetId(resourceSetId);
resourceSetPermissionRequest.setScopes(scopes);
PermissionTicket t = null;
try {
t = resourceSetPermissionRegistrationService.registerResourceSetPermission("Bearer " + this.umaRegisterResourceSetFlowHttpTest.m_pat.getAccessToken(), umaAmHost, resourceSetPermissionRequest);
} catch (ClientResponseFailure ex) {
System.err.println(ex.getResponse().getEntity(String.class));
throw ex;
}
UmaTestUtil.assert_(t);
this.ticketForFullAccess = t.getTicket();
return t.getTicket();
}
use of org.jboss.resteasy.client.ClientResponseFailure in project oxAuth by GluuFederation.
the class TrustElevationHttpTest method trustElevation.
@Test
@Parameters({ "umaMetaDataUrl", "umaAmHost", "umaPatClientId", "umaPatClientSecret", "umaAatClientId", "umaAatClientSecret" })
public void trustElevation(final String umaMetaDataUrl, final String umaAmHost, final String umaPatClientId, final String umaPatClientSecret, final String umaAatClientId, final String umaAatClientSecret) throws Exception {
this.metadataConfiguration = UmaClientFactory.instance().createMetaDataConfigurationService(umaMetaDataUrl).getMetadataConfiguration();
UmaTestUtil.assert_(this.metadataConfiguration);
this.umaObtainRptTokenFlowHttpTest = new ObtainRptTokenFlowHttpTest(this.metadataConfiguration);
this.umaRegisterResourceSetFlowHttpTest = new RegisterResourceSetFlowHttpTest(this.metadataConfiguration);
this.umaRegisterResourceSetPermissionFlowHttpTest = new RegisterResourceSetPermissionFlowHttpTest(this.metadataConfiguration);
this.rptStatusService = UmaClientFactory.instance().createRptStatusService(metadataConfiguration);
this.rptPermissionAuthorizationService = UmaClientFactory.instance().createAuthorizationRequestService(metadataConfiguration);
m_pat = UmaClient.requestPat(tokenEndpoint, umaPatClientId, umaPatClientSecret);
m_aat = UmaClient.requestAat(tokenEndpoint, umaAatClientId, umaAatClientSecret);
UmaTestUtil.assert_(m_pat);
UmaTestUtil.assert_(m_aat);
final List<String> rsScopes = Arrays.asList("http://gluu.example.com/dev/scopes/view", "http://gluu.example.com/dev/scopes/all");
this.umaRegisterResourceSetFlowHttpTest.m_pat = m_pat;
final String resourceId = this.umaRegisterResourceSetFlowHttpTest.registerResourceSet(rsScopes);
this.umaObtainRptTokenFlowHttpTest.m_aat = this.m_aat;
this.umaObtainRptTokenFlowHttpTest.testObtainRptTokenFlow(umaAmHost);
this.umaRegisterResourceSetPermissionFlowHttpTest.umaRegisterResourceSetFlowHttpTest = umaRegisterResourceSetFlowHttpTest;
this.umaRegisterResourceSetPermissionFlowHttpTest.registerResourceSetPermission(umaAmHost, resourceId, rsScopes);
RptIntrospectionResponse rptStatus = this.rptStatusService.requestRptStatus("Bearer " + m_pat.getAccessToken(), this.umaObtainRptTokenFlowHttpTest.rptToken, "");
RptAuthorizationRequest rptAuthorizationRequest = new RptAuthorizationRequest(this.umaObtainRptTokenFlowHttpTest.rptToken, umaRegisterResourceSetPermissionFlowHttpTest.ticketForFullAccess);
try {
RptAuthorizationResponse authorizationResponse = this.rptPermissionAuthorizationService.requestRptPermissionAuthorization("Bearer " + m_aat.getAccessToken(), umaAmHost, rptAuthorizationRequest);
} catch (ClientResponseFailure ex) {
System.err.println(ex.getResponse().getEntity(String.class));
throw ex;
}
rptStatus = this.rptStatusService.requestRptStatus("Bearer " + m_pat.getAccessToken(), this.umaObtainRptTokenFlowHttpTest.rptToken, "");
}
Aggregations