Class AbstractAuthorizable
- java.lang.Object
-
- com.adobe.cq.testing.client.security.AbstractAuthorizable
-
- All Implemented Interfaces:
Authorizable
public abstract class AbstractAuthorizable extends Object implements Authorizable
ExistingAuthorizable
-
-
Field Summary
Fields Modifier and Type Field Description protected StringauthorizableIdprotected StringauthorizablePathprotected SecurityClientclient-
Fields 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
Constructors Constructor Description AbstractAuthorizable(T client, String authorizableId)Constructor for anAuthorizable, default path to authorizable is expected
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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.SlingHttpResponsedoGet(List<org.apache.http.NameValuePair> parameters, int... expectedStatus)GET 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 StringencodeURI(String unescapedPath)Escape path to URIbooleanexists()Check if the authorizable existsstatic booleanexists(SecurityClient client, String authorizableId)booleanexists(String query)static Class<? extends AbstractAuthorizable>getAuthorizableClass(String authorizableType)Get authorizable Class.SecurityClientgetClient()Get any client implementing theSecurityClientStringgetHomePath()Get home path to authorizableStringgetHomeUrl()Get home URL to authorizableStringgetId()Get id of authorizableMap<String,Authorizable>getImpersonators()Get impersonators of the authorizable.StringgetJsonAsString(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=2000Map<String,Authorizable>getMemberOf()Get members authorizable is assigned to.Map<String,Authorizable>getMembers()Get members assigned to the authorizable.com.fasterxml.jackson.databind.JsonNodegetProfile()Get profile attributes for authorizable.static StringgetQuery(String authorizableId)StringgetUserPropertiesJsonAsString(int... expectedStatus)Get user properties JSON representation as stringbooleanisImpersonated()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 Detail
-
client
protected SecurityClient client
-
authorizableId
protected String authorizableId
-
authorizablePath
protected String authorizablePath
-
-
Constructor Detail
-
AbstractAuthorizable
public AbstractAuthorizable(T client, String authorizableId) throws org.apache.sling.testing.clients.ClientException, InterruptedExceptionConstructor 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 Detail
-
getClient
public SecurityClient getClient()
Description copied from interface:AuthorizableGet any client implementing theSecurityClient- Specified by:
getClientin interfaceAuthorizable- Returns:
SecurityClient
-
getId
public String getId()
Description copied from interface:AuthorizableGet id of authorizable- Specified by:
getIdin interfaceAuthorizable- Returns:
- authorizableId
-
getHomePath
public String getHomePath()
Description copied from interface:AuthorizableGet home path to authorizable- Specified by:
getHomePathin interfaceAuthorizable- Returns:
- path to authorizable
-
getHomeUrl
public String 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
public boolean exists(String query) throws org.apache.sling.testing.clients.ClientException
- Throws:
org.apache.sling.testing.clients.ClientException
-
delete
public org.apache.sling.testing.clients.SlingHttpResponse delete(int... expectedStatus) throws org.apache.sling.testing.clients.ClientExceptionDescription 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, InterruptedException
Description 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, InterruptedException
Description 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, InterruptedException
Description 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.ClientExceptionPOST 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
public static Class<? extends AbstractAuthorizable> getAuthorizableClass(String authorizableType)
Get authorizable Class.- Parameters:
authorizableType- Allowed values: "user" or "group" (fallback).- Returns:
- a Class extending
AbstractAuthorizable
-
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"
-
-