Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9853B7430 for ; Wed, 23 Nov 2011 20:15:08 +0000 (UTC) Received: (qmail 10624 invoked by uid 500); 23 Nov 2011 20:15:08 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 10590 invoked by uid 500); 23 Nov 2011 20:15:08 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 10579 invoked by uid 99); 23 Nov 2011 20:15:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Nov 2011 20:15:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Nov 2011 20:15:07 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 00C072388860; Wed, 23 Nov 2011 20:14:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1205563 - /sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java Date: Wed, 23 Nov 2011 20:14:46 -0000 To: commits@sling.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111123201447.00C072388860@eris.apache.org> Author: fmeschbe Date: Wed Nov 23 20:14:46 2011 New Revision: 1205563 URL: http://svn.apache.org/viewvc?rev=1205563&view=rev Log: SLING-2299 Browser check in the Sling Authenticator now uses the User-Agent (and not the Accept) header. Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java?rev=1205563&r1=1205562&r2=1205563&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java Wed Nov 23 20:14:46 2011 @@ -34,7 +34,7 @@ public class RedirectOnLoginErrorTest ex /** Execute a POST request and check status * @return the HttpMethod executed * @throws IOException */ - private HttpMethod assertPostStatus(String url, int expectedStatusCode, List postParams, + private HttpMethod assertPostStatus(String url, int expectedStatusCode, List postParams, String assertMessage, String referer) throws IOException { final PostMethod post = new PostMethod(url); post.setFollowRedirects(false); @@ -42,9 +42,9 @@ public class RedirectOnLoginErrorTest ex //set the referer to indicate where we came from post.setRequestHeader("Referer", referer); - + //set Accept header to trick sling into treating the request as from a browser - post.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); + post.setRequestHeader("User-Agent", "Mozilla/5.0 Sling Integration Test"); if(postParams!=null) { final NameValuePair [] nvp = {}; @@ -64,11 +64,11 @@ public class RedirectOnLoginErrorTest ex } return post; } - + /** * Test SLING-2165. Login Error should redirect back to the referrer * login page. - * + * * @throws Exception */ public void testRedirectToSelectorLoginFormAfterLoginError() throws Exception { @@ -77,12 +77,12 @@ public class RedirectOnLoginErrorTest ex params.add(new NameValuePair("j_username", "___bogus___")); params.add(new NameValuePair("j_password", "not_a_real_user")); final String loginPageUrl = String.format("%s/system/sling/selector/login", HTTP_BASE_URL); - PostMethod post = (PostMethod)assertPostStatus(HTTP_BASE_URL + "/j_security_check", - HttpServletResponse.SC_MOVED_TEMPORARILY, - params, + PostMethod post = (PostMethod)assertPostStatus(HTTP_BASE_URL + "/j_security_check", + HttpServletResponse.SC_MOVED_TEMPORARILY, + params, null, loginPageUrl); - + final Header locationHeader = post.getResponseHeader("Location"); String location = locationHeader.getValue(); int queryStrStart = location.indexOf('?'); @@ -95,7 +95,7 @@ public class RedirectOnLoginErrorTest ex /** * Test SLING-2165. Login Error should redirect back to the referrer * login page. - * + * * @throws Exception */ public void testRedirectToOpenIDLoginFormAfterLoginError() throws Exception { @@ -103,12 +103,12 @@ public class RedirectOnLoginErrorTest ex List params = new ArrayList(); params.add(new NameValuePair("openid_identifier", "___bogus___")); final String loginPageUrl = String.format("%s/system/sling/openid/login", HTTP_BASE_URL); - PostMethod post = (PostMethod)assertPostStatus(HTTP_BASE_URL + "/j_security_check", - HttpServletResponse.SC_MOVED_TEMPORARILY, - params, + PostMethod post = (PostMethod)assertPostStatus(HTTP_BASE_URL + "/j_security_check", + HttpServletResponse.SC_MOVED_TEMPORARILY, + params, null, loginPageUrl); - + final Header locationHeader = post.getResponseHeader("Location"); String location = locationHeader.getValue(); int queryStrStart = location.indexOf('?'); @@ -121,7 +121,7 @@ public class RedirectOnLoginErrorTest ex /** * Test SLING-2165. Login Error should redirect back to the referrer * login page. - * + * * @throws Exception */ public void testRedirectToLoginFormAfterLoginError() throws Exception { @@ -130,12 +130,12 @@ public class RedirectOnLoginErrorTest ex params.add(new NameValuePair("j_username", "___bogus___")); params.add(new NameValuePair("j_password", "not_a_real_user")); final String loginPageUrl = String.format("%s/system/sling/form/login", HTTP_BASE_URL); - PostMethod post = (PostMethod)assertPostStatus(HTTP_BASE_URL + "/j_security_check", - HttpServletResponse.SC_MOVED_TEMPORARILY, - params, + PostMethod post = (PostMethod)assertPostStatus(HTTP_BASE_URL + "/j_security_check", + HttpServletResponse.SC_MOVED_TEMPORARILY, + params, null, loginPageUrl); - + final Header locationHeader = post.getResponseHeader("Location"); String location = locationHeader.getValue(); int queryStrStart = location.indexOf('?');