Package com.adobe.cq.testing.client
Class SecurityClient
java.lang.Object
org.apache.sling.testing.clients.AbstractSlingClient
org.apache.sling.testing.clients.SlingClient
com.adobe.cq.testing.client.CQClient
com.adobe.cq.testing.client.SecurityClient
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.apache.http.client.HttpClient
- Direct Known Subclasses:
CQSecurityClient
Client for managing authorizables, such as users or groups
-
Nested Class Summary
Nested classes/interfaces inherited from class com.adobe.cq.testing.client.CQClient
CQClient.Builder, CQClient.InternalBuilder<T extends CQClient>
-
Field Summary
Fields inherited from class com.adobe.cq.testing.client.CQClient
LOG, STATISTICS_ROOT, wcmCommands
Fields inherited from class org.apache.sling.testing.clients.SlingClient
CLIENT_CONNECTION_TIMEOUT_PROP, DEFAULT_NODE_TYPE, SUDO_COOKIE_NAME
-
Constructor Summary
ConstructorDescriptionSecurityClient
(URI serverUrl, String user, String password) SecurityClient
(org.apache.http.impl.client.CloseableHttpClient http, org.apache.sling.testing.clients.SlingClientConfig config) -
Method Summary
Modifier and TypeMethodDescriptioncreateGroup
(String groupId, int... expectedStatus) Creates a new group.createGroup
(String groupId, Group[] assignedGroups, int... expectedStatus) Creates a new group and assigns him to a list of givenAuthorizable
s.createGroup
(String groupId, String intermediatePath, int... expectedStatus) Creates a new group.createGroup
(String groupId, String intermediatePath, String givenName, String aboutMe, Group[] assignedGroups, int... expectedStatus) Creates a new group and assigns him to a list of givenAuthorizable
s.createUser
(String userId, int... expectedStatus) Creates a new user with password the same as userId.createUser
(String userId, String intermediatePath, int... expectedStatus) Creates a new user with password the same as userId in a defined root path.createUser
(String userId, String password, String intermediatePath, Map<String, String> profileMap, boolean waitForIndexing, T[] assignedGroups, int... expectedStatus) Deprecated.waitForIndexing is not used anymore and it's ignored.createUser
(String userId, String password, String intermediatePath, Map<String, String> profileMap, T[] assignedGroups, int... expectedStatus) Creates a new user with aProfile
and assigns him to a list of givenAuthorizable
s.createUser
(String userId, String password, T[] assignedGroups, int... expectedStatus) Creates a new user and assigns him to a list of givenAuthorizable
s.void
deleteAuthorizables
(Authorizable[] authorizables, int... expectedStatus) Delete a list of authorizables.URL for Security AdmingetLoginTokenCookie
(int... expectedStatus) Get the login token cookie to authenticate future requests.Get the login pageGetAuthorizableManager
to get and createAuthorizable
s: User / GroupsMethods inherited from class com.adobe.cq.testing.client.CQClient
copyLanguages, copyPage, createPage, createPageWithRetry, createVersion, deletePage, deletePageWithRetry, getAuthorSitesPage, lockPage, movePage, movePage, pageExists, pageExistsWithRetry, pageExistsWithRetry, resetPageStatistics, restoreTree, restoreVersion, rolloutPage, searchAndReplaceInPages, searchInPages, setPageProperties, setPageProperty, setPagePropertyImage, unlockPage, uploadFileCQStyle
Methods inherited from class org.apache.sling.testing.clients.SlingClient
createFolder, createNode, createNodeRecursive, deletePath, doGetJson, endImpersonation, exists, getJsonNode, getJsonNode, getNodeNameFromPath, getParentPath, getUser, getUUId, getUUID, impersonate, importContent, importContent, importJson, move, setPropertiesString, setPropertyString, setPropertyStringArray, upload, waitExists, waitUntilExists
Methods inherited from class org.apache.sling.testing.clients.AbstractSlingClient
adaptTo, addValue, close, doDelete, doGet, doGet, doGet, doHead, doPatch, doPost, doPost, doPut, doRawRequest, doRequest, doStreamGet, doStreamPost, doStreamRequest, execute, execute, execute, execute, execute, execute, execute, execute, getClientId, getConnectionManager, getCookieStore, getCredentialsProvider, getParams, getPassword, getPath, getPath, getUrl, getUrl, getUrl, getValue, getValues, hasValue
-
Field Details
-
LOGIN_URL
- See Also:
-
ADMIN_URL
- See Also:
-
-
Constructor Details
-
SecurityClient
public SecurityClient(org.apache.http.impl.client.CloseableHttpClient http, org.apache.sling.testing.clients.SlingClientConfig config) throws org.apache.sling.testing.clients.ClientException - Throws:
org.apache.sling.testing.clients.ClientException
-
SecurityClient
public SecurityClient(URI serverUrl, String user, String password) throws org.apache.sling.testing.clients.ClientException - Throws:
org.apache.sling.testing.clients.ClientException
-
-
Method Details
-
getLoginUrl
Get the login page- Returns:
- the login url
-
getAdminUrl
URL for Security Admin- Returns:
- the admin url
-
getManager
GetAuthorizableManager
to get and createAuthorizable
s: User / Groups- Returns:
AuthorizableManager
-
deleteAuthorizables
public void deleteAuthorizables(Authorizable[] authorizables, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException Delete a list of authorizables.- Parameters:
authorizables
-Authorizable
expectedStatus
- list of allowed HTTP Status to be returned- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failed
-
createUser
public User createUser(String userId, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException Creates a new user with password the same as userId.- Parameters:
userId
- the user ID for the new user.expectedStatus
- list of allowed HTTP Status to be returned- Returns:
User
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failedInterruptedException
- to mark this method as "waiting"
-
createUser
public User createUser(String userId, String intermediatePath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException Creates a new user with password the same as userId in a defined root path.- Parameters:
userId
- the user ID for the new user.intermediatePath
- the root path user will be created.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
User
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
createUser
public <T extends Group> User createUser(String userId, String password, T[] assignedGroups, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException Creates a new user and assigns him to a list of givenAuthorizable
s.- Type Parameters:
T
- group type- Parameters:
userId
- the user ID for the new user.password
- the password to be assigned.assignedGroups
- groups the user will be assigned to asGroup
-Array.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
User
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
createUser
public <T extends Group> User createUser(String userId, String password, String intermediatePath, Map<String, String> profileMap, T[] assignedGroups, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedExceptionCreates a new user with aProfile
and assigns him to a list of givenAuthorizable
s.- Type Parameters:
T
- group type- Parameters:
userId
- the user ID for the new user.password
- the password to be assigned.intermediatePath
- the root path user will be created.profileMap
- profile properties to be set for the new user.assignedGroups
- groups the user will be assigned to asAuthorizable
-Array.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
User
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/ response cycleInterruptedException
- to mark this method as "waiting"
-
createUser
@Deprecated public <T extends Group> User createUser(String userId, String password, String intermediatePath, Map<String, String> profileMap, boolean waitForIndexing, T[] assignedGroups, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedExceptionDeprecated.waitForIndexing is not used anymore and it's ignored. UsecreateGroup(String, String, String, String, Group[], int...)
.Creates a new user with aProfile
and assigns him to a list of givenAuthorizable
s.- Type Parameters:
T
- group type- Parameters:
userId
- the user ID for the new user.password
- the password to be assigned.intermediatePath
- the root path user will be created.profileMap
- profile properties to be set for the new user.waitForIndexing
- whether or not to wait for indexing to be completed after creating the userassignedGroups
- groups the user will be assigned to asAuthorizable
-Array.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
User
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/ response cycleInterruptedException
- to mark this method as "waiting"
-
createGroup
public Group createGroup(String groupId, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException Creates a new group.- Parameters:
groupId
- the group ID for the new group.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
Group
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
createGroup
public Group createGroup(String groupId, String intermediatePath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException Creates a new group.- Parameters:
groupId
- the group ID for the new group.intermediatePath
- the root path user will be created.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
Group
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
createGroup
public Group createGroup(String groupId, Group[] assignedGroups, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException Creates a new group and assigns him to a list of givenAuthorizable
s.- Parameters:
groupId
- the group ID for the new group.assignedGroups
- groups the user will be assigned to asAuthorizable
-Array.expectedStatus
- list of allowed HTTP Status to be returned.- Returns:
Group
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
createGroup
public Group createGroup(String groupId, String intermediatePath, String givenName, String aboutMe, Group[] assignedGroups, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException Creates a new group and assigns him to a list of givenAuthorizable
s.- Parameters:
groupId
- the group ID for the new group.intermediatePath
- the root path user will be created.givenName
- the name of the group.aboutMe
- description of the group.assignedGroups
- groups the user will be assigned toexpectedStatus
- list of allowed HTTP Status to be returned.- Returns:
Group
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycleInterruptedException
- to mark this method as "waiting"
-
getLoginTokenCookie
public String getLoginTokenCookie(int... expectedStatus) throws org.apache.sling.testing.clients.ClientException Get the login token cookie to authenticate future requests.- Parameters:
expectedStatus
- list of allowed HTTP Status to be returned. If not set, http status 302 (REDIRECT (to the requested resource)) is assumed.- Returns:
- the login-token cookie to be used for further requests.
- Throws:
org.apache.sling.testing.clients.ClientException
- If something fails during request/response cycle
-