Acceptance tests: Add a helper method to renew the request context

Renewing the request context is e.g. needed for email tests, because the
IdentifiedUser caches the email addresses and needs to be recreated if
new emails were added.

Change-Id: Ib5699baab32febe62e904b65ee02c25f23c17a7c
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2017-02-10 08:59:11 +01:00
parent 87a788d54b
commit 6baa2422f1
3 changed files with 19 additions and 15 deletions

View File

@@ -696,6 +696,16 @@ public abstract class AbstractDaemonTest {
identifiedUserFactory.create(account.getId()));
}
/**
* Enforce a new request context for the current API user.
*
* <p>This recreates the IdentifiedUser, hence everything which is cached in the IdentifiedUser is
* reloaded (e.g. the email addresses of the user).
*/
protected Context resetCurrentApiUser() {
return atrScope.set(newRequestContext(atrScope.get().getSession().getAccount()));
}
protected Context setApiUser(TestAccount account) {
return atrScope.set(newRequestContext(account));
}