Search in sources :

Example 6 with SmtpConfiguration

use of org.gluu.model.SmtpConfiguration in project oxTrust by GluuFederation.

the class SMTPWebResourceTest method updateSmtpServerConfigurationTest.

@Test
public void updateSmtpServerConfigurationTest() {
    SmtpConfiguration configuration = getStmp();
    HttpPut request = new HttpPut(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.CONFIGURATION + ApiConstants.SMTP);
    try {
        String json = mapper.writeValueAsString(configuration);
        HttpEntity entity = new ByteArrayEntity(json.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();
        configuration = mapper.readValue(EntityUtils.toString(result), SmtpConfiguration.class);
        Assert.assertNotNull(configuration);
    } catch (ParseException | IOException e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    }
}
Also used : HttpEntity(org.apache.http.HttpEntity) ByteArrayEntity(org.apache.http.entity.ByteArrayEntity) SmtpConfiguration(org.gluu.model.SmtpConfiguration) HttpResponse(org.apache.http.HttpResponse) ParseException(org.apache.http.ParseException) IOException(java.io.IOException) HttpPut(org.apache.http.client.methods.HttpPut) Test(org.junit.Test)

Example 7 with SmtpConfiguration

use of org.gluu.model.SmtpConfiguration in project oxTrust by GluuFederation.

the class SMTPWebResourceTest method getStmp.

private SmtpConfiguration getStmp() {
    SmtpConfiguration configuration = new SmtpConfiguration();
    configuration.setHost("smtp.gmail.com");
    configuration.setPort(587);
    configuration.setPassword("XoLsnJdMZ4EQnWaqkvBSBA==");
    configuration.setPasswordDecrypted("GluuTestMail");
    configuration.setFromEmailAddress("gluutestmail@gmail.com");
    configuration.setFromName("Gluu Api");
    configuration.setRequiresAuthentication(true);
    configuration.setServerTrust(true);
    configuration.setRequiresSsl(true);
    configuration.setUserName("gluutestmail@gmail.com");
    return configuration;
}
Also used : SmtpConfiguration(org.gluu.model.SmtpConfiguration)

Aggregations

SmtpConfiguration (org.gluu.model.SmtpConfiguration)7 IOException (java.io.IOException)2 RequestScoped (javax.enterprise.context.RequestScoped)2 Produces (javax.enterprise.inject.Produces)2 GluuConfiguration (org.gluu.oxtrust.model.GluuConfiguration)2 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1 HttpEntity (org.apache.http.HttpEntity)1 HttpResponse (org.apache.http.HttpResponse)1 ParseException (org.apache.http.ParseException)1 HttpPut (org.apache.http.client.methods.HttpPut)1 ByteArrayEntity (org.apache.http.entity.ByteArrayEntity)1 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)1 BasePersistenceException (org.gluu.persist.exception.BasePersistenceException)1 Test (org.junit.Test)1 GluuConfiguration (org.oxauth.persistence.model.configuration.GluuConfiguration)1