This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 769a5a4  SLING-10319 : Use the equals method if value comparison was 
intended
769a5a4 is described below

commit 769a5a4f5c1ba33c57555f2778685a89826fcb8f
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Mon Apr 19 16:56:56 2021 +0200

    SLING-10319 : Use the equals method if value comparison was intended
---
 .../sling/auth/core/impl/SlingAuthenticatorTest.java      | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git 
a/src/test/java/org/apache/sling/auth/core/impl/SlingAuthenticatorTest.java 
b/src/test/java/org/apache/sling/auth/core/impl/SlingAuthenticatorTest.java
index 2c14fef..52ae29c 100644
--- a/src/test/java/org/apache/sling/auth/core/impl/SlingAuthenticatorTest.java
+++ b/src/test/java/org/apache/sling/auth/core/impl/SlingAuthenticatorTest.java
@@ -419,6 +419,21 @@ public class SlingAuthenticatorTest {
         assertEquals("\"newsudo\"", argument.getValue().getValue());
     }
 
+    @Test public void testSetSudoCookieSudoBeforeNoSudoAfter() {
+        final SlingAuthenticator slingAuthenticator = 
this.createSlingAuthenticator();
+        final AuthenticationInfo info = new AuthenticationInfo("basic");
+        
+        final SlingHttpServletRequest req = 
Mockito.mock(SlingHttpServletRequest.class);
+        final Cookie cookie = new Cookie("sling.sudo", "\"oldsudo\"");
+        Mockito.when(req.getCookies()).thenReturn(new Cookie[] {cookie});
+        final SlingHttpServletResponse res = 
Mockito.mock(SlingHttpServletResponse.class);
+
+        assertTrue(slingAuthenticator.setSudoCookie(req, res, info));
+        ArgumentCaptor<Cookie> argument = 
ArgumentCaptor.forClass(Cookie.class);
+        Mockito.verify(res).addCookie(argument.capture());
+        assertEquals("\"\"", argument.getValue().getValue());
+    }
+
     //---------------------------- PRIVATE METHODS 
-----------------------------
 
     /**

Reply via email to