Class AbstractAuthorizable
java.lang.Object
com.adobe.cq.testing.client.security.AbstractAuthorizable
- All Implemented Interfaces:
Authorizable
Existing
Authorizable-
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 ofAuthorizables as Map: key = id of authorizable.static StringbuildAuthorizablePath(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.SlingHttpResponsedelete(int... expectedStatus) Deletes an authorizable.org.apache.sling.testing.clients.SlingHttpResponseGET request to AuthorizableServlet.org.apache.sling.testing.clients.SlingHttpResponsedoPost(org.apache.sling.testing.clients.util.FormEntityBuilder formParameters, int... expectedStatus) POST request to AuthorizableServlet.protected static StringencodePathToURL(String authorizableHomePath) Get url of the authorizable (user/group) in repository.protected static StringEscape path to URIbooleanexists()Check if the authorizable existsstatic booleanexists(SecurityClient client, String authorizableId) booleanstatic Class<? extends AbstractAuthorizable>getAuthorizableClass(String authorizableType) Get authorizable Class.Get any client implementing theSecurityClientGet 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.JsonNodeGet profile attributes for authorizable.static StringgetUserPropertiesJsonAsString(int... expectedStatus) Get user properties JSON representation as stringbooleanCheck if authorizable is impersonated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:AuthorizableGet any client implementing theSecurityClient- Specified by:
getClientin interfaceAuthorizable- Returns:
SecurityClient
-
getId
Description copied from interface:AuthorizableGet id of authorizable- Specified by:
getIdin interfaceAuthorizable- Returns:
- authorizableId
-
getHomePath
Description copied from interface:AuthorizableGet home path to authorizable- Specified by:
getHomePathin interfaceAuthorizable- Returns:
- path to authorizable
-
getHomeUrl
Description copied from interface:AuthorizableGet home URL to authorizable- Specified by:
getHomeUrlin interfaceAuthorizable- Returns:
- URL to authorizable
-
getJsonAsString
public String getJsonAsString(String propsFilter, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException Description copied from interface:AuthorizableString representation of authorizable http://localhost:4502/home/groups/default/administrators.rw.json?props=replication,modification,memberOf, membersTotal,members,profile/*&ml=2000- Specified by:
getJsonAsStringin 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:AuthorizableGet user properties JSON representation as string- Specified by:
getUserPropertiesJsonAsStringin 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:AuthorizableCheck if the authorizable exists- Specified by:
existsin 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:AuthorizableDeletes an authorizable.- Specified by:
deletein 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:AuthorizableCreates a newAuthorizable.- Specified by:
createin 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:AuthorizableGet members authorizable is assigned to.- Specified by:
getMemberOfin 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:AuthorizableGet members assigned to the authorizable.- Specified by:
getMembersin 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:AuthorizableGet impersonators of the authorizable.- Specified by:
getImpersonatorsin 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:AuthorizableCheck if authorizable is impersonated.- Specified by:
isImpersonatedin 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:AuthorizableGet profile attributes for authorizable.- Specified by:
getProfilein 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
protected static String encodeURI(String unescapedPath) throws org.apache.sling.testing.clients.ClientException Escape path to URI- Parameters:
unescapedPath- unescaped path- Returns:
- escaped path
- Throws:
org.apache.sling.testing.clients.ClientException- if the request failed
-
buildAuthorizableList
protected Map<String,Authorizable> buildAuthorizableList(com.fasterxml.jackson.databind.JsonNode authorizableJsonNode) throws org.apache.sling.testing.clients.ClientException, InterruptedException Build list ofAuthorizables 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"
-