Skip to content

Commit

Permalink
resolved conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuszkubis committed Sep 22, 2016
1 parent 31d5a61 commit 83970f1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ public HtmlLibraryManagerTest(Configuration config) {
}

@Override public boolean doTest(String url, String instanceName) throws Exception {
String[] user = AuthorTest.ENVIRONMENT_NAME.equals(instanceName) ?
UserHelper.splitUser(config.getStringValue("authorUser", "admin:admin")) :
UserHelper.splitUser(config.getStringValue("publishUser", "admin:admin"));
String configurationEndpoint = url
+ "/system/console/configMgr/com.adobe.granite.ui.clientlibs.impl.HtmlLibraryManagerImpl.json";
String body = getJsonBodyOfOsgiConfiguration(configurationEndpoint, user, instanceName);
String body = getJsonBodyOfOsgiConfiguration(configurationEndpoint, getUsernamePasswordCredentials(instanceName), instanceName);
checkBooleanValue(getBooleanValueFromJson("htmllibmanager.minify", body), true, "Minify",
instanceName);
checkBooleanValue(getBooleanValueFromJson("htmllibmanager.gzip", body), true, "Gzip", instanceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.UsernamePasswordCredentials;
Expand All @@ -18,22 +19,27 @@ interface OsgiConfigurationTest {

JsonParser JSON_PARSER = new JsonParser();

default String getJsonBodyOfOsgiConfiguration(String osgiConfigurationUrl, String[] credentials, String instanceName) throws AuthenticationException, IOException {
UsernamePasswordCredentials creds = new UsernamePasswordCredentials(credentials[0], credentials[1]);
default String getJsonBodyOfOsgiConfiguration(String osgiConfigurationUrl,
UsernamePasswordCredentials credentials, String instanceName)
throws AuthenticationException, IOException {
DefaultHttpClient authorizedClient = new DefaultHttpClient();
HttpUriRequest request = new HttpGet(osgiConfigurationUrl);
request.addHeader(new BasicScheme().authenticate(creds, request, null));
request.addHeader(new BasicScheme().authenticate(credentials, request, null));
HttpResponse response = authorizedClient.execute(request);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpURLConnection.HTTP_OK) {
throw new AuthenticationException("Cannot authenticate user " + credentials[0] + " to " + instanceName + " instance");
throw new AuthenticationException(
"Cannot authenticate user " + credentials.getUserName() + " to " + instanceName
+ " instance");
}
return EntityUtils.toString(response.getEntity());
}

default boolean getBooleanValueFromJson(String propertyKey, String osgiConfigurationJson) throws IOException, AuthenticationException {
JsonObject configuration = JSON_PARSER.parse(osgiConfigurationJson).getAsJsonArray().get(0).getAsJsonObject();
JsonObject properties = configuration.getAsJsonObject("properties");
default boolean getBooleanValueFromJson(String propertyKey, String osgiConfigurationJson)
throws IOException, AuthenticationException {
JsonObject configuration = JSON_PARSER.parse(osgiConfigurationJson).getAsJsonArray().get(0)
.getAsJsonObject();
JsonObject properties = configuration.getAsJsonObject("properties");
return properties.getAsJsonObject(propertyKey).getAsJsonPrimitive("value").getAsBoolean();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ public SlingJsHandlerTest(Configuration config) {
}

@Override public boolean doTest(String url, String instanceName) throws Exception {
String[] user = AuthorTest.ENVIRONMENT_NAME.equals(instanceName) ?
UserHelper.splitUser(config.getStringValue("authorUser", "admin:admin")) :
UserHelper.splitUser(config.getStringValue("publishUser", "admin:admin"));
String configurationEndpoint = url
+ "/system/console/configMgr/org.apache.sling.scripting.java.impl.JavaScriptEngineFactory.json";
String jsonBody = getJsonBodyOfOsgiConfiguration(configurationEndpoint, user, instanceName);
String jsonBody = getJsonBodyOfOsgiConfiguration(configurationEndpoint, getUsernamePasswordCredentials(instanceName), instanceName);
checkBooleanValue(getBooleanValueFromJson("java.classdebuginfo", jsonBody), false,
"Generate Debug Info", instanceName);
return getErrorMessages().isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public SlingJspScriptHandlerTest(Configuration config) {
UserHelper.splitUser(config.getStringValue("publishUser", "admin:admin"));
String configurationEndpoint = url
+ "/system/console/configMgr/com.adobe.granite.ui.clientlibs.impl.HtmlLibraryManagerImpl.json";
String body = getJsonBodyOfOsgiConfiguration(configurationEndpoint, user, instanceName);
String body = getJsonBodyOfOsgiConfiguration(configurationEndpoint, getUsernamePasswordCredentials(instanceName), instanceName);
checkBooleanValue(getBooleanValueFromJson("jasper.classdebuginfo", body), false,
"Generate Debug Info", instanceName);
checkBooleanValue(getBooleanValueFromJson("jasper.mappedfile", body), false, "Mapped Content",
Expand Down

0 comments on commit 83970f1

Please sign in to comment.