Search in sources :

Example 1 with ClientResponseFailure

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");
}
Also used : ResourceSetRegistrationService(org.xdi.oxauth.client.uma.ResourceSetRegistrationService) ResourceSetResponse(org.xdi.oxauth.model.uma.ResourceSetResponse) ResourceSet(org.xdi.oxauth.model.uma.ResourceSet) ClientResponseFailure(org.jboss.resteasy.client.ClientResponseFailure) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 2 with ClientResponseFailure

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");
}
Also used : ResourceSetRegistrationService(org.xdi.oxauth.client.uma.ResourceSetRegistrationService) ResourceSetWithId(org.xdi.oxauth.model.uma.ResourceSetWithId) ClientResponseFailure(org.jboss.resteasy.client.ClientResponseFailure) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 3 with ClientResponseFailure

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");
}
Also used : PermissionTicket(org.xdi.oxauth.model.uma.PermissionTicket) UmaPermission(org.xdi.oxauth.model.uma.UmaPermission) ClientResponseFailure(org.jboss.resteasy.client.ClientResponseFailure) PermissionRegistrationService(org.xdi.oxauth.client.uma.PermissionRegistrationService) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 4 with ClientResponseFailure

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();
}
Also used : PermissionTicket(org.xdi.oxauth.model.uma.PermissionTicket) UmaPermission(org.xdi.oxauth.model.uma.UmaPermission) ClientResponseFailure(org.jboss.resteasy.client.ClientResponseFailure) PermissionRegistrationService(org.xdi.oxauth.client.uma.PermissionRegistrationService)

Example 5 with ClientResponseFailure

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, "");
}
Also used : RptIntrospectionResponse(org.xdi.oxauth.model.uma.RptIntrospectionResponse) 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)

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