Package com.adobe.cq.testing.junit.rules
Class TemporaryUser
java.lang.Object
org.junit.rules.ExternalResource
com.adobe.cq.testing.junit.rules.TemporaryUser
- All Implemented Interfaces:
org.junit.rules.TestRule
public class TemporaryUser
extends org.junit.rules.ExternalResource
TemporaryUser creates a user and deletes it at the end of the test.
Whether the delete is successful or not is not checked.
The create operation is retried until a timeout is reached.
The total wait time in the
before
method can be up to 30s.-
Constructor Summary
ConstructorDescriptionTemporaryUser
(Supplier<org.apache.sling.testing.clients.SlingClient> creatorSupplier, String... groups) Instantiate a new TemporaryUser rule, to be used with the@Rule
annotation. -
Method Summary
Methods inherited from class org.junit.rules.ExternalResource
apply
-
Constructor Details
-
TemporaryUser
public TemporaryUser(Supplier<org.apache.sling.testing.clients.SlingClient> creatorSupplier, String... groups) Instantiate a new TemporaryUser rule, to be used with the@Rule
annotation.- Parameters:
creatorSupplier
- supplier for the client used to create the temporary usergroups
- groups to which the temporary user is assigned
-
-
Method Details
-
getClient
- Returns:
- the CQClient matching the temporary user
-
getClientSupplier
- Returns:
- a
SlingClient
Supplier matching the temporary user
-
before
- Overrides:
before
in classorg.junit.rules.ExternalResource
- Throws:
Throwable
-
after
protected void after()- Overrides:
after
in classorg.junit.rules.ExternalResource
-
generateName
Generate a unique name for the user. Can be overridden if anther pattern is needed.- Returns:
- a unique username
-
generatePassword
Generate a unique password for the user. Can be overridden if another pattern is needed.- Returns:
- a unique, random password
-
deleteUsers
protected void deleteUsers()Delete all the created users. The delete operation is not retried and exceptions are ignored.
-