Class AuthorizableManager
java.lang.Object
com.adobe.cq.testing.client.security.AuthorizableManager
- Direct Known Subclasses:
CQAuthorizableManager
Manager for getting and creating
Authorizables-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringPOST path for Authorizablestatic final Stringstatic final StringPath to JSON representing the authorizablesprotected final SecurityClientThe security granite HTTP client -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<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.SlingHttpResponsedoPost(org.apache.sling.testing.clients.util.FormEntityBuilder formParameters, int... expectedStatus) POST request to AuthorizableServlet.protected <T extends AbstractAuthorizable>
TgetAuthorizable(Class<T> authorizableClass, String authorizableId) Get an instance of any class extendingAbstractAuthorizablewith given ID.getAuthorizables(String query) Get all authorizables from Json as list ofAuthorizables.getAuthorizablesJson(String query) Get all authorizables as json String.Get an existing group object from the id.Get built-in group "administrators"Get built-in group "contributor"Get built-in group "everyone"Get built-in group "user-administrators"Get an existing user object from the id.
-
Field Details
-
AUTHORIZABLE_POST_PATH
POST path for Authorizable- See Also:
-
AUTHORIZABLES_PATH
Path to JSON representing the authorizables- See Also:
-
AUTHORIZABLES
- See Also:
-
client
The security granite HTTP client
-
-
Constructor Details
-
AuthorizableManager
public AuthorizableManager(T client)
-
-
Method Details
-
getGroupAdministrators
Get built-in group "administrators"- Returns:
- administrators'
Group - Throws:
org.apache.sling.testing.clients.ClientException- if the request failed
-
getGroupContributor
Get built-in group "contributor"- Returns:
- contributor'
Group - Throws:
org.apache.sling.testing.clients.ClientException- if the request failed
-
getGroupEveryone
Get built-in group "everyone"- Returns:
- everyone'
Group - Throws:
org.apache.sling.testing.clients.ClientException- if the request failed
-
getGroupUserAdministrators
Get built-in group "user-administrators"- Returns:
- user-administrators'
Group - Throws:
org.apache.sling.testing.clients.ClientException- if the request failed
-
getUser
Get an existing user object from the id.- Parameters:
userId- the user ID.- Returns:
User- Throws:
org.apache.sling.testing.clients.ClientException- If something fails during request/response cycle
-
getGroup
Get an existing group object from the id.- Parameters:
groupId- the group ID.- Returns:
Group- 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 Creates a newAuthorizable.- 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
-
getAuthorizable
protected <T extends AbstractAuthorizable> T getAuthorizable(Class<T> authorizableClass, String authorizableId) throws org.apache.sling.testing.clients.ClientException Get an instance of any class extendingAbstractAuthorizablewith given ID. Home path for authorizable is assumed in default structure.- Type Parameters:
T- any class extendingAbstractAuthorizable- Parameters:
authorizableClass- any class extending theAbstractAuthorizableauthorizableId- the authorizable ID.- Returns:
- the client
- Throws:
org.apache.sling.testing.clients.ClientException- if client can't be instantiated
-
getAuthorizables
public List<Authorizable> getAuthorizables(String query) throws org.apache.sling.testing.clients.ClientException Get all authorizables from Json as list ofAuthorizables.- Parameters:
query- search query for authorizables- Returns:
- authorizables as
Authorizable - Throws:
org.apache.sling.testing.clients.ClientException- if the request failed
-
getAuthorizablesJson
public String getAuthorizablesJson(String query) throws org.apache.sling.testing.clients.ClientException Get all authorizables as json String.- Parameters:
query- search query for authorizables- Returns:
- authorizables as JSON String
- Throws:
org.apache.sling.testing.clients.ClientException- if the request failed
-
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
-