klcodanr commented on a change in pull request #21:
URL: 
https://github.com/apache/sling-org-apache-sling-testing-clients/pull/21#discussion_r683744467



##########
File path: src/main/java/org/apache/sling/testing/clients/SlingClient.java
##########
@@ -580,6 +588,34 @@ public String getUUId(JsonNode jsonNode) throws 
ClientException {
         return uuidNode.getValueAsText();
     }
 
+    @Override
+    public String getUser() {
+        // get the username from the sudo cookie or default from client config
+        return getCookieStore().getCookies().stream().filter(c -> 
c.getName().equals(getSudoCookieName())).findFirst()
+                .map(c -> c.getValue().replace("\"", 
"")).orElse(super.getUser());
+    }
+
+    /**
+     * Impersonate user with the given <code>userId</code>
+     * <p>
+     * By impersonating a user SlingClient can access content from that user 
eye view.
+     * </p>
+     *Passing a <code>null</code> will clear impersonation.
+     *
+     * @param userId   the user to impersonate. A <code>null</code> value 
clears impersonation

Review comment:
       Removed the ability and added endImpersonation method.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to