Class AuthorizableManager
- java.lang.Object
-
- com.adobe.cq.testing.client.security.AuthorizableManager
-
- Direct Known Subclasses:
CQAuthorizableManager
public class AuthorizableManager extends Object
Manager for getting and creatingAuthorizable
s
-
-
Field Summary
Fields Modifier and Type Field Description static String
AUTHORIZABLE_POST_PATH
POST path for Authorizablestatic String
AUTHORIZABLES
static String
AUTHORIZABLES_PATH
Path to JSON representing the authorizablesprotected SecurityClient
client
The security granite HTTP client
-
Constructor Summary
Constructors Constructor Description AuthorizableManager(T client)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <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
doPost(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 extendingAbstractAuthorizable
with given ID.List<Authorizable>
getAuthorizables(String query)
Get all authorizables from Json as list ofAuthorizable
s.String
getAuthorizablesJson(String query)
Get all authorizables as json String.Group
getGroup(String groupId)
Get an existing group object from the id.Group
getGroupAdministrators()
Get built-in group "administrators"Group
getGroupContributor()
Get built-in group "contributor"Group
getGroupEveryone()
Get built-in group "everyone"Group
getGroupUserAdministrators()
Get built-in group "user-administrators"User
getUser(String userId)
Get an existing user object from the id.
-
-
-
Field Detail
-
AUTHORIZABLE_POST_PATH
public static final String AUTHORIZABLE_POST_PATH
POST path for Authorizable- See Also:
- Constant Field Values
-
AUTHORIZABLES_PATH
public static final String AUTHORIZABLES_PATH
Path to JSON representing the authorizables- See Also:
- Constant Field Values
-
AUTHORIZABLES
public static final String AUTHORIZABLES
- See Also:
- Constant Field Values
-
client
protected final SecurityClient client
The security granite HTTP client
-
-
Method Detail
-
getGroupAdministrators
public Group getGroupAdministrators() throws org.apache.sling.testing.clients.ClientException
Get built-in group "administrators"- Returns:
- administrators'
Group
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failed
-
getGroupContributor
public Group getGroupContributor() throws org.apache.sling.testing.clients.ClientException
Get built-in group "contributor"- Returns:
- contributor'
Group
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failed
-
getGroupEveryone
public Group getGroupEveryone() throws org.apache.sling.testing.clients.ClientException
Get built-in group "everyone"- Returns:
- everyone'
Group
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failed
-
getGroupUserAdministrators
public Group getGroupUserAdministrators() throws org.apache.sling.testing.clients.ClientException
Get built-in group "user-administrators"- Returns:
- user-administrators'
Group
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failed
-
getUser
public User getUser(String userId) throws org.apache.sling.testing.clients.ClientException
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
public Group getGroup(String groupId) throws org.apache.sling.testing.clients.ClientException
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 extendingAbstractAuthorizable
with given ID. Home path for authorizable is assumed in default structure.- Type Parameters:
T
- any class extendingAbstractAuthorizable
- Parameters:
authorizableClass
- any class extending theAbstractAuthorizable
authorizableId
- 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 ofAuthorizable
s.- 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
-
-