You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by en...@apache.org on 2020/08/04 01:01:06 UTC
[sling-org-apache-sling-launchpad-integration-tests] 01/02: Revert
"SLING-8809 SLING-8810 SLING-8811 SLING-8812 - testing fixes"
This is an automated email from the ASF dual-hosted git repository.
enorman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-launchpad-integration-tests.git
commit db22baf99ed084d03206b32372b72a26bae385ff
Author: Eric Norman <en...@apache.org>
AuthorDate: Mon Aug 3 17:59:43 2020 -0700
Revert "SLING-8809 SLING-8810 SLING-8811 SLING-8812 - testing fixes"
This reverts commit 1e6204f42c829b6b86076313248903b5aa4ec3f5.
---
.../accessManager/ModifyAceTest.java | 60 ----------------
.../accessManager/RemoveAcesTest.java | 80 ----------------------
.../resolver/errorhandler/ErrorHandlingTest.java | 27 +-------
.../servlets/errorhandler/json.404.jsp | 52 --------------
4 files changed, 1 insertion(+), 218 deletions(-)
diff --git a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
index 505233e..388dc25 100644
--- a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
+++ b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
@@ -43,7 +43,6 @@ import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.sling.commons.testing.integration.HttpTest;
import org.apache.sling.launchpad.webapp.integrationtest.util.JsonUtil;
-import org.apache.sling.servlets.post.JSONResponse;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -1348,63 +1347,4 @@ public class ModifyAceTest {
assertEquals("/hello_again", ((JsonString)repGlob2).getString());
}
- /**
- * SLING-8809 - Test to verify submitting an invalid principalId returns a
- * good error message instead of a NullPointerException
- */
- @Test
- public void testModifyAceForInvalidUser() throws IOException, JsonException {
- String invalidUserId = "notRealUser123";
-
- testFolderUrl = H.createTestFolder();
-
- String postUrl = testFolderUrl + ".modifyAce.json";
-
- List<NameValuePair> postParams = new ArrayList<NameValuePair>();
- postParams.add(new NameValuePair(":http-equiv-accept", JSONResponse.RESPONSE_CONTENT_TYPE));
- postParams.add(new NameValuePair("principalId", invalidUserId));
- postParams.add(new NameValuePair("privilege@jcr:read", "granted"));
- postParams.add(new NameValuePair("privilege@jcr:write", "denied"));
- postParams.add(new NameValuePair("privilege@jcr:modifyAccessControl", "bogus")); //invalid value should be ignored.
-
- Credentials creds = new UsernamePasswordCredentials("admin", "admin");
- String json = H.getAuthenticatedPostContent(creds, postUrl, HttpTest.CONTENT_TYPE_JSON, postParams, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- assertNotNull(json);
-
- JsonObject jsonObject = JsonUtil.parseObject(json);
- assertEquals("javax.jcr.RepositoryException: Invalid principalId was submitted.", jsonObject.getString("status.message"));
- }
-
- /**
- * SLING-8811 - Test to verify that the "changes" list of a modifyAce response
- * returns the list of principals that were changed
- */
- @Test
- public void testModifyAceChangesInResponse() throws IOException, JsonException {
- testUserId = H.createTestUser();
-
- testFolderUrl = H.createTestFolder();
-
- String postUrl = testFolderUrl + ".modifyAce.json";
-
- List<NameValuePair> postParams = new ArrayList<NameValuePair>();
- postParams.add(new NameValuePair(":http-equiv-accept", JSONResponse.RESPONSE_CONTENT_TYPE));
- postParams.add(new NameValuePair("principalId", testUserId));
- postParams.add(new NameValuePair("privilege@jcr:read", "granted"));
- postParams.add(new NameValuePair("privilege@jcr:write", "denied"));
- postParams.add(new NameValuePair("privilege@jcr:modifyAccessControl", "bogus")); //invalid value should be ignored.
-
- Credentials creds = new UsernamePasswordCredentials("admin", "admin");
- String json = H.getAuthenticatedPostContent(creds, postUrl, HttpTest.CONTENT_TYPE_JSON, postParams, HttpServletResponse.SC_OK);
- assertNotNull(json);
-
- JsonObject jsonObject = JsonUtil.parseObject(json);
- JsonArray changesArray = jsonObject.getJsonArray("changes");
- assertNotNull(changesArray);
- assertEquals(1, changesArray.size());
- JsonObject change = changesArray.getJsonObject(0);
- assertEquals("modified", change.getString("type"));
- assertEquals(testUserId, change.getString("argument"));
- }
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java
index a5e7f3a..5eb8e05 100644
--- a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java
+++ b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java
@@ -30,8 +30,6 @@ import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.sling.commons.testing.integration.HttpTest;
import org.apache.sling.launchpad.webapp.integrationtest.util.JsonUtil;
-import org.apache.sling.servlets.post.JSONResponse;
-import org.junit.Test;
/**
* Tests for the 'removeAce' Sling POST operation
@@ -220,83 +218,5 @@ public class RemoveAcesTest extends AccessManagerTestUtil {
JsonObject jsonObject = JsonUtil.parseObject(json);
assertNotNull(jsonObject);
}
-
- /**
- * SLING-8810 - Test that a attempt to remove an ACE from a
- * node that does not yet have an AccessControlList responds
- * in a consistent way to other scenarios
- */
- @Test
- public void testRemoveAceWhenAccessControlListDoesNotExist() throws IOException, JsonException {
- testUserId = createTestUser();
- testFolderUrl = createTestFolder();
-
- String postUrl = testFolderUrl + ".deleteAce.json";
-
- List<NameValuePair> postParams = new ArrayList<NameValuePair>();
- postParams.add(new NameValuePair(":http-equiv-accept", JSONResponse.RESPONSE_CONTENT_TYPE));
- postParams.add(new NameValuePair(":applyTo", testUserId));
-
- Credentials creds = new UsernamePasswordCredentials("admin", "admin");
- String json = getAuthenticatedPostContent(creds, postUrl, HttpTest.CONTENT_TYPE_JSON, postParams, HttpServletResponse.SC_OK);
- assertNotNull(json);
-
- JsonObject jsonObject = JsonUtil.parseObject(json);
- JsonArray changesArray = jsonObject.getJsonArray("changes");
- assertNotNull(changesArray);
- assertEquals(0, changesArray.size());
- }
-
- /**
- * SLING-8812 - Test to verify submitting an invalid principalId returns a
- * good error message instead of a NullPointerException
- */
- @Test
- public void testRemoveAceForInvalidUser() throws IOException, JsonException {
- String invalidUserId = "notRealUser123";
-
- String folderUrl = createFolderWithAces(true);
-
- String postUrl = folderUrl + ".deleteAce.json";
-
- List<NameValuePair> postParams = new ArrayList<NameValuePair>();
- postParams.add(new NameValuePair(":http-equiv-accept", JSONResponse.RESPONSE_CONTENT_TYPE));
- postParams.add(new NameValuePair(":applyTo", invalidUserId));
-
- Credentials creds = new UsernamePasswordCredentials("admin", "admin");
- String json = getAuthenticatedPostContent(creds, postUrl, HttpTest.CONTENT_TYPE_JSON, postParams, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- assertNotNull(json);
-
- JsonObject jsonObject = JsonUtil.parseObject(json);
- assertEquals("javax.jcr.RepositoryException: Invalid principalId was submitted.", jsonObject.getString("status.message"));
- }
-
- /**
- * SLING-8811 - Test to verify that the "changes" list of a modifyAce response
- * returns the list of principals that were changed
- */
- @Test
- public void testRemoveAceChangesInResponse() throws IOException, JsonException {
- String folderUrl = createFolderWithAces(true);
-
- String postUrl = folderUrl + ".deleteAce.json";
-
- List<NameValuePair> postParams = new ArrayList<NameValuePair>();
- postParams.add(new NameValuePair(":http-equiv-accept", JSONResponse.RESPONSE_CONTENT_TYPE));
- postParams.add(new NameValuePair(":applyTo", testUserId));
-
- Credentials creds = new UsernamePasswordCredentials("admin", "admin");
- String json = getAuthenticatedPostContent(creds, postUrl, HttpTest.CONTENT_TYPE_JSON, postParams, HttpServletResponse.SC_OK);
- assertNotNull(json);
-
- JsonObject jsonObject = JsonUtil.parseObject(json);
- JsonArray changesArray = jsonObject.getJsonArray("changes");
- assertNotNull(changesArray);
- assertEquals(1, changesArray.size());
- JsonObject change = changesArray.getJsonObject(0);
- assertEquals("deleted", change.getString("type"));
- assertEquals(testUserId, change.getString("argument"));
- }
-
}
diff --git a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ErrorHandlingTest.java b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ErrorHandlingTest.java
index 0b1a6c8..1a26cd7 100644
--- a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ErrorHandlingTest.java
+++ b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ErrorHandlingTest.java
@@ -16,19 +16,14 @@
*/
package org.apache.sling.launchpad.webapp.integrationtest.servlets.resolver.errorhandler;
-import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.json.Json;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-
import org.apache.commons.httpclient.NameValuePair;
-import org.apache.sling.launchpad.webapp.integrationtest.RenderingTestBase;
import org.apache.sling.servlets.post.SlingPostConstants;
+import org.apache.sling.launchpad.webapp.integrationtest.RenderingTestBase;
/** Test the sling error handling mechanism http://sling.apache.org/site/errorhandling.html*/
public class ErrorHandlingTest extends RenderingTestBase {
@@ -63,7 +58,6 @@ public class ErrorHandlingTest extends RenderingTestBase {
testClient.mkdirs(HTTP_BASE_URL, ERROR_HANDLER_PATH);
testClient.mkdirs(HTTP_BASE_URL, TEST_ROOT+"/"+THROW_ERROR_PATH);
uploadTestScript("servlets/errorhandler/404.jsp", "sling/servlet/errorhandler/404.jsp");
- uploadTestScript("servlets/errorhandler/json.404.jsp", "sling/servlet/errorhandler/json.404.jsp");
uploadTestScript("servlets/errorhandler/Throwable.jsp", "sling/servlet/errorhandler/Throwable.jsp");
uploadTestScript("servlets/errorhandler/500.jsp", "sling/servlet/errorhandler/500.jsp");
uploadTestScript("servlets/errorhandler/401.jsp", "sling/servlet/errorhandler/401.jsp");
@@ -177,23 +171,4 @@ public class ErrorHandlingTest extends RenderingTestBase {
assertWithRetries(url, 500, expected, HTTP_METHOD_POST, params);
}
- /**
- * Test an error handling script registered for a json extension
- */
- public void test_404_errorhandling_JSON_extension() throws Throwable {
- final String url = testNodePath + NOT_EXISTING_NODE_PATH + ".json";
- List <NameValuePair> params=new ArrayList<NameValuePair>();
- String json = getContent(url, CONTENT_TYPE_JSON, params, 404, HTTP_METHOD_GET);
-
- // assert the error content is right.
- JsonObject jsonObj = null;
- try (JsonReader reader = Json.createReader(new StringReader(json))) {
- jsonObj = reader.readObject();
- }
- assertNotNull(jsonObj);
- assertEquals(404, jsonObj.getInt("status"));
- assertEquals("Resource at '/apps/testNode/notExisting.json' not found: No resource found", jsonObj.getString("message"));
- assertEquals("/apps/testNode/notExisting.json", jsonObj.getString("request_uri"));
- }
-
}
diff --git a/src/main/resources/integration-test/servlets/errorhandler/json.404.jsp b/src/main/resources/integration-test/servlets/errorhandler/json.404.jsp
deleted file mode 100644
index b15ae57..0000000
--- a/src/main/resources/integration-test/servlets/errorhandler/json.404.jsp
+++ /dev/null
@@ -1,52 +0,0 @@
-<%@page import="javax.json.JsonWriter"%>
-<%@page import="javax.json.JsonObject"%>
-<%@page import="javax.json.JsonObjectBuilder"%>
-<%@page import="javax.json.JsonBuilderFactory"%>
-<%@page import="javax.json.Json"%>
-<%@page import="java.util.Collections"%>
-<%@page import="org.apache.sling.api.SlingConstants"%>
-<%
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-int status = (Integer)request.getAttribute(SlingConstants.ERROR_STATUS);
-response.setStatus(status);
-response.setCharacterEncoding("UTF-8");
-response.setContentType("application/json");
-
-JsonBuilderFactory factory = Json.createBuilderFactory(Collections.emptyMap());
-JsonObjectBuilder jsonObjBuilder = factory.createObjectBuilder();
-
-jsonObjBuilder.add("status", status);
-
-String msg = (String)request.getAttribute(SlingConstants.ERROR_MESSAGE);
-if (msg != null && !msg.isEmpty()) {
- jsonObjBuilder.add("message", msg);
-}
-
-String requestUri = (String)request.getAttribute(SlingConstants.ERROR_REQUEST_URI);
-if (requestUri != null && !requestUri.isEmpty()) {
- jsonObjBuilder.add("request_uri", requestUri);
-}
-
-JsonObject jsonObj = jsonObjBuilder.build();
-JsonWriter jsonWriter = Json.createWriter(response.getWriter());
-jsonWriter.writeObject(jsonObj);
-jsonWriter.close();
-%>
\ No newline at end of file