Search in sources :

Example 1 with UmaScopeDescription

use of org.gluu.oxauth.model.uma.UmaScopeDescription in project oxTrust by GluuFederation.

the class UmaResourceWebServiceTest method getUmaResourceScopesTest.

@Test
public void getUmaResourceScopesTest() {
    String id = "0f963ecc-93f0-49c1-beae-ad2006abbb99";
    HttpUriRequest request = new HttpGet(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.UMA + ApiConstants.RESOURCES + "/" + id + ApiConstants.SCOPES);
    HttpResponse response = handle(request);
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    HttpEntity entity = response.getEntity();
    try {
        String content = EntityUtils.toString(entity);
        UmaScopeDescription[] scopes = mapper.readValue(content, UmaScopeDescription[].class);
        Assert.assertNotNull(scopes);
        Assert.assertEquals(scopes.length, 1);
    } catch (ParseException | IOException e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    }
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) HttpEntity(org.apache.http.HttpEntity) UmaScopeDescription(org.gluu.oxauth.model.uma.UmaScopeDescription) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ParseException(org.apache.http.ParseException) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with UmaScopeDescription

use of org.gluu.oxauth.model.uma.UmaScopeDescription in project oxTrust by GluuFederation.

the class UmaScopeWebResourceTest method searchUmaScopeTest.

@Test
public void searchUmaScopeTest() {
    String searchPattern = "SCIM";
    String SEARCH_QUERY = "?" + ApiConstants.SEARCH_PATTERN + "=" + searchPattern + "&size=5";
    HttpUriRequest request = new HttpGet(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.UMA + ApiConstants.SCOPES + ApiConstants.SEARCH + SEARCH_QUERY);
    HttpResponse response = handle(request);
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    HttpEntity entity = response.getEntity();
    try {
        String content = EntityUtils.toString(entity);
        UmaScopeDescription[] scopes = mapper.readValue(content, UmaScopeDescription[].class);
        Assert.assertTrue(scopes.length >= 1);
    } catch (ParseException | IOException e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    }
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) HttpEntity(org.apache.http.HttpEntity) UmaScopeDescription(org.gluu.oxauth.model.uma.UmaScopeDescription) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ParseException(org.apache.http.ParseException) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with UmaScopeDescription

use of org.gluu.oxauth.model.uma.UmaScopeDescription in project oxTrust by GluuFederation.

the class UmaScopeWebResourceTest method getUmaScopeByInumTest.

@Test
public void getUmaScopeByInumTest() {
    String inum = "8CAD-B06D";
    HttpUriRequest request = new HttpGet(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.UMA + ApiConstants.SCOPES + "/" + inum);
    HttpResponse response = handle(request);
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    HttpEntity entity = response.getEntity();
    try {
        String content = EntityUtils.toString(entity);
        UmaScopeDescription scope = mapper.readValue(content, UmaScopeDescription.class);
        Assert.assertNotNull(scope);
    } catch (ParseException | IOException e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    }
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) HttpEntity(org.apache.http.HttpEntity) UmaScopeDescription(org.gluu.oxauth.model.uma.UmaScopeDescription) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ParseException(org.apache.http.ParseException) IOException(java.io.IOException) Test(org.junit.Test)

Example 4 with UmaScopeDescription

use of org.gluu.oxauth.model.uma.UmaScopeDescription in project oxTrust by GluuFederation.

the class UmaScopeWebResourceTest method getUmaScopesTest.

@Test
public void getUmaScopesTest() {
    HttpUriRequest request = new HttpGet(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.UMA + ApiConstants.SCOPES);
    HttpResponse response = handle(request);
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    HttpEntity entity = response.getEntity();
    try {
        String content = EntityUtils.toString(entity);
        UmaScopeDescription[] scopes = mapper.readValue(content, UmaScopeDescription[].class);
        Assert.assertTrue(scopes.length >= 1);
    } catch (ParseException | IOException e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    }
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) HttpEntity(org.apache.http.HttpEntity) UmaScopeDescription(org.gluu.oxauth.model.uma.UmaScopeDescription) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ParseException(org.apache.http.ParseException) IOException(java.io.IOException) Test(org.junit.Test)

Example 5 with UmaScopeDescription

use of org.gluu.oxauth.model.uma.UmaScopeDescription in project oxAuth by GluuFederation.

the class ScopeHttpTest method scopePresence.

@Test
@Parameters({ "umaMetaDataUrl" })
public void scopePresence(final String umaMetaDataUrl) {
    final UmaMetadata metadata = UmaClientFactory.instance().createMetadataService(umaMetaDataUrl).getMetadata();
    final UmaScopeService scopeService = UmaClientFactory.instance().createScopeService(metadata.getScopeEndpoint());
    final UmaScopeDescription modifyScope = scopeService.getScope("modify");
    UmaTestUtil.assert_(modifyScope);
}
Also used : UmaMetadata(org.gluu.oxauth.model.uma.UmaMetadata) UmaScopeDescription(org.gluu.oxauth.model.uma.UmaScopeDescription) UmaScopeService(org.gluu.oxauth.client.uma.UmaScopeService) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Aggregations

UmaScopeDescription (org.gluu.oxauth.model.uma.UmaScopeDescription)7 IOException (java.io.IOException)4 HttpEntity (org.apache.http.HttpEntity)4 HttpResponse (org.apache.http.HttpResponse)4 ParseException (org.apache.http.ParseException)4 HttpGet (org.apache.http.client.methods.HttpGet)4 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)4 Test (org.junit.Test)4 Parameters (org.testng.annotations.Parameters)2 Test (org.testng.annotations.Test)2 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Builder (javax.ws.rs.client.Invocation.Builder)1 Response (javax.ws.rs.core.Response)1 BaseTest (org.gluu.oxauth.BaseTest)1 UmaScopeService (org.gluu.oxauth.client.uma.UmaScopeService)1 UmaMetadata (org.gluu.oxauth.model.uma.UmaMetadata)1 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)1 Scope (org.oxauth.persistence.model.Scope)1