Search in sources :

Example 11 with Provider

use of org.gluu.model.passport.Provider in project oxTrust by GluuFederation.

the class PassportProviderWebResourceTest method createProviderTest.

@Test
public void createProviderTest() {
    String name = "ApiLinkedin";
    Provider provider = getProvider(name);
    HttpPost request = new HttpPost(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.PASSPORT + ApiConstants.PROVIDERS);
    try {
        HttpEntity entity = new ByteArrayEntity(mapper.writeValueAsString(provider).toString().getBytes("UTF-8"), ContentType.APPLICATION_FORM_URLENCODED);
        request.setEntity(entity);
        request.setHeader(CONTENT_TYPE, MediaType.APPLICATION_JSON);
        HttpResponse response = handle(request);
        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
        HttpEntity result = response.getEntity();
        Provider myProvider = mapper.readValue(EntityUtils.toString(result), Provider.class);
        Assert.assertEquals(myProvider.getDisplayName(), name);
        Assert.assertEquals(myProvider.isEnabled(), false);
    } catch (ParseException | IOException e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    }
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) HttpEntity(org.apache.http.HttpEntity) ByteArrayEntity(org.apache.http.entity.ByteArrayEntity) HttpResponse(org.apache.http.HttpResponse) ParseException(org.apache.http.ParseException) IOException(java.io.IOException) Provider(org.gluu.model.passport.Provider) Test(org.junit.Test)

Aggregations

Provider (org.gluu.model.passport.Provider)11 PassportProvider (org.gluu.oxtrust.model.PassportProvider)4 Operation (io.swagger.v3.oas.annotations.Operation)3 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HttpEntity (org.apache.http.HttpEntity)3 HttpResponse (org.apache.http.HttpResponse)3 ParseException (org.apache.http.ParseException)3 OptionEntry (org.gluu.oxtrust.model.OptionEntry)3 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)3 Test (org.junit.Test)3 HttpPost (org.apache.http.client.methods.HttpPost)2 ByteArrayEntity (org.apache.http.entity.ByteArrayEntity)2 HttpGet (org.apache.http.client.methods.HttpGet)1 HttpPut (org.apache.http.client.methods.HttpPut)1 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)1