Class AbstractAuthorizable
java.lang.Object
com.adobe.cq.testing.client.security.AbstractAuthorizable
-
Field Summary
FieldsFields inherited from interface com.adobe.cq.testing.client.security.Authorizable
ACTION_CREATE_GROUP, ACTION_CREATE_USER, AUTHORIZABLE_ID, IMPERSONATORS, IS_IMPERSONATED, MEMBER_OF, MEMBERS, PARAM_ADD_IMPERSONATORS, PARAM_ADD_MEMBERS, PARAM_AUTHORIZABLE_ID, PARAM_CREATE_GROUP, PARAM_CREATE_USER, PARAM_DELETE, PARAM_INTERMEDIATE_PATH, PARAM_PASSWORD, PARAM_REMOVE_IMPERSONATORS, PARAM_REMOVE_MEMBERS, PROFILE, SCHEMA_AUTHORIZABLE, SELECTOR, SELECTOR_USERPROPERTIES, TYPE, TYPE_GROUP, TYPE_USER, WILDCARD
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractAuthorizable
(T client, String authorizableId) Constructor for anAuthorizable
, default path to authorizable is expected -
Method Summary
Modifier and TypeMethodDescriptionprotected Map
<String, Authorizable> buildAuthorizableList
(com.fasterxml.jackson.databind.JsonNode authorizableJsonNode) Build list ofAuthorizable
s as Map: key = id of authorizable.static String
buildAuthorizablePath
(String authorizableId, String rootPath, String intermediatePath) Get home path of the authorizable (user/group) in repository.<T extends SecurityClient>
Authorizablecreate
(T client, Class<? extends AbstractAuthorizable> authorizableClass, String authorizableId, org.apache.sling.testing.clients.util.FormEntityBuilder formParameters, int... expectedStatus) Creates a newAuthorizable
.org.apache.sling.testing.clients.SlingHttpResponse
delete
(int... expectedStatus) Deletes an authorizable.org.apache.sling.testing.clients.SlingHttpResponse
GET request to AuthorizableServlet.org.apache.sling.testing.clients.SlingHttpResponse
doPost
(org.apache.sling.testing.clients.util.FormEntityBuilder formParameters, int... expectedStatus) POST request to AuthorizableServlet.protected static String
encodePathToURL
(String authorizableHomePath) Get url of the authorizable (user/group) in repository.protected static String
Escape path to URIboolean
exists()
Check if the authorizable existsstatic boolean
exists
(SecurityClient client, String authorizableId) boolean
static Class
<? extends AbstractAuthorizable> getAuthorizableClass
(String authorizableType) Get authorizable Class.Get any client implementing theSecurityClient
Get home path to authorizableGet home URL to authorizablegetId()
Get id of authorizableGet impersonators of the authorizable.getJsonAsString
(String propsFilter, int... expectedStatus) String representation of authorizable http://localhost:4502/home/groups/default/administrators.rw.json?props=replication,modification,memberOf, membersTotal,members,profile/*&ml=2000Get members authorizable is assigned to.Get members assigned to the authorizable.com.fasterxml.jackson.databind.JsonNode
Get profile attributes for authorizable.static String
getUserPropertiesJsonAsString
(int... expectedStatus) Get user properties JSON representation as stringboolean
Check if authorizable is impersonated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.adobe.cq.testing.client.security.Authorizable
getRootPath
-
Field Details
-
client
-
authorizableId
-
authorizablePath
-
-
Constructor Details
-
AbstractAuthorizable
public AbstractAuthorizable(T client, String authorizableId) throws org.apache.sling.testing.clients.ClientException, InterruptedException Constructor for anAuthorizable
, default path to authorizable is expected- Type Parameters:
T
- any class implementing tehSecurityClient
.- Parameters:
client
- any class implementing theSecurityClient
.authorizableId
- the authorizable ID.- Throws:
org.apache.sling.testing.clients.ClientException
- if the details of the authorizables cannot be retrievedInterruptedException
- to mark this method as "waiting"
-
-
Method Details
-
getClient
Description copied from interface:Authorizable
Get any client implementing theSecurityClient
- Specified by:
getClient
in interfaceAuthorizable
- Returns:
SecurityClient
-
getId
Description copied from interface:Authorizable
Get id of authorizable- Specified by:
getId
in interfaceAuthorizable
- Returns:
- authorizableId
-
getHomePath
Description copied from interface:Authorizable
Get home path to authorizable- Specified by:
getHomePath
in interfaceAuthorizable
- Returns:
- path to authorizable
-
getHomeUrl
Description copied from interface:Authorizable
Get home URL to authorizable- Specified by:
getHomeUrl
in interfaceAuthorizable
- Returns:
- URL to authorizable
-
getJsonAsString
public String getJsonAsString(String propsFilter, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException Description copied from interface:Authorizable
String representation of authorizable http://localhost:4502/home/groups/default/administrators.rw.json?props=replication,modification,memberOf, membersTotal,members,profile/*&ml=2000- Specified by:
getJsonAsString
in interfaceAuthorizable
- Parameters:
propsFilter
- properties filterexpectedStatus
- list of allowed HTTP Status to be returned.- Returns:
- the string representing a json
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycle
-
getUserPropertiesJsonAsString
public String getUserPropertiesJsonAsString(int... expectedStatus) throws org.apache.sling.testing.clients.ClientException Description copied from interface:Authorizable
Get user properties JSON representation as string- Specified by:
getUserPropertiesJsonAsString
in interfaceAuthorizable
- Parameters:
expectedStatus
- status to be- Returns:
- user properties JSON representation as String
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycle
-
exists
public static boolean exists(SecurityClient client, String authorizableId) throws org.apache.sling.testing.clients.ClientException - Throws:
org.apache.sling.testing.clients.ClientException
-
exists
public boolean exists() throws org.apache.sling.testing.clients.ClientExceptionDescription copied from interface:Authorizable
Check if the authorizable exists- Specified by:
exists
in interfaceAuthorizable
- Returns:
- true if the authorizable exists
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failed
-
exists
- Throws:
org.apache.sling.testing.clients.ClientException
-
delete
public org.apache.sling.testing.clients.SlingHttpResponse delete(int... expectedStatus) throws org.apache.sling.testing.clients.ClientException Description copied from interface:Authorizable
Deletes an authorizable.- Specified by:
delete
in interfaceAuthorizable
- Parameters:
expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
- Sling response
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycle
-
create
public <T extends SecurityClient> Authorizable create(T client, Class<? extends AbstractAuthorizable> authorizableClass, String authorizableId, org.apache.sling.testing.clients.util.FormEntityBuilder formParameters, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException Description copied from interface:Authorizable
Creates a newAuthorizable
.- Specified by:
create
in interfaceAuthorizable
- Type Parameters:
T
- client type- Parameters:
client
- any class implementing theSecurityClient
.authorizableClass
- Authorizable class to be created.authorizableId
- the ID for the new authorizable.formParameters
- form parameters.expectedStatus
- list of allowed HTTP Status to be returned. If not set, http status 201 (CREATED) is assumed.- Returns:
- created
Authorizable
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycle
-
getMemberOf
public Map<String,Authorizable> getMemberOf() throws org.apache.sling.testing.clients.ClientException, InterruptedExceptionDescription copied from interface:Authorizable
Get members authorizable is assigned to.- Specified by:
getMemberOf
in interfaceAuthorizable
- Returns:
- list of
Authorizable
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
getMembers
public Map<String,Authorizable> getMembers() throws org.apache.sling.testing.clients.ClientException, InterruptedExceptionDescription copied from interface:Authorizable
Get members assigned to the authorizable.- Specified by:
getMembers
in interfaceAuthorizable
- Returns:
- list of
Authorizable
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
getImpersonators
public Map<String,Authorizable> getImpersonators() throws org.apache.sling.testing.clients.ClientException, InterruptedExceptionDescription copied from interface:Authorizable
Get impersonators of the authorizable.- Specified by:
getImpersonators
in interfaceAuthorizable
- Returns:
- list of
Authorizable
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
isImpersonated
public boolean isImpersonated() throws org.apache.sling.testing.clients.ClientExceptionDescription copied from interface:Authorizable
Check if authorizable is impersonated.- Specified by:
isImpersonated
in interfaceAuthorizable
- Returns:
- true if authorizable is impersonated.
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycle
-
getProfile
public com.fasterxml.jackson.databind.JsonNode getProfile() throws org.apache.sling.testing.clients.ClientExceptionDescription copied from interface:Authorizable
Get profile attributes for authorizable.- Specified by:
getProfile
in interfaceAuthorizable
- Returns:
- JsonNode containing profile properties
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycle
-
doPost
public org.apache.sling.testing.clients.SlingHttpResponse doPost(org.apache.sling.testing.clients.util.FormEntityBuilder formParameters, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException POST request to AuthorizableServlet.- Parameters:
formParameters
- form parameters.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
- executed request
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failed
-
doGet
public org.apache.sling.testing.clients.SlingHttpResponse doGet(List<org.apache.http.NameValuePair> parameters, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException GET request to AuthorizableServlet.- Parameters:
parameters
- url parameters.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
- executed request
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failed
-
getAuthorizableClass
Get authorizable Class.- Parameters:
authorizableType
- Allowed values: "user" or "group" (fallback).- Returns:
- a Class extending
AbstractAuthorizable
-
getQuery
-
buildAuthorizablePath
public static String buildAuthorizablePath(String authorizableId, String rootPath, String intermediatePath) throws org.apache.sling.testing.clients.ClientException Get home path of the authorizable (user/group) in repository. Either user is created in a user defined structure (intermediatePath is set while creation) or within the default structure- Parameters:
authorizableId
- the ID of the authorizablerootPath
- the rootPath of the authorizableintermediatePath
- the parent path the user will be created.- Returns:
- the authorizable path
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failed
-
encodePathToURL
protected static String encodePathToURL(String authorizableHomePath) throws org.apache.sling.testing.clients.ClientException Get url of the authorizable (user/group) in repository. Either user is created in a user defined structure (intermediatePath is set while creation) or within the default structureJCR escaping works similar to URL encoding, meaning that special chars doGet %-encoded. so to avoid % being interpreted by the URL as an URL Encoding we must URL encode the % to doGet a valid URL
- Parameters:
authorizableHomePath
- the home path of the authorizable- Returns:
- authorizable url
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failed
-
encodeURI
-
buildAuthorizableList
protected Map<String,Authorizable> buildAuthorizableList(com.fasterxml.jackson.databind.JsonNode authorizableJsonNode) throws org.apache.sling.testing.clients.ClientException, InterruptedException Build list ofAuthorizable
s as Map: key = id of authorizable.- Parameters:
authorizableJsonNode
- JSON node of an authorizable; TODO; format- Returns:
- list of
Authorizable
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failedInterruptedException
- to mark this method as "waiting"
-