Search in sources :

Example 1 with ExternalIdKeyFactory

use of com.google.gerrit.server.account.externalids.ExternalIdKeyFactory in project gerrit by GerritCodeReview.

the class ProjectBasicAuthFilterTest method setUp.

@Before
public void setUp() throws Exception {
    req = new FakeHttpServletRequest("gerrit.example.com", 80, "", "");
    res = new FakeHttpServletResponse();
    extIdKeyFactory = new ExternalIdKeyFactory(new ExternalIdKeyFactory.ConfigImpl(authConfig));
    extIdFactory = new ExternalIdFactory(extIdKeyFactory, authConfig);
    authRequestFactory = new AuthRequest.Factory(extIdKeyFactory);
    pwdVerifier = new PasswordVerifier(extIdKeyFactory, authConfig);
    authSuccessful = new AuthResult(AUTH_ACCOUNT_ID, extIdKeyFactory.create("username", AUTH_USER), false);
    doReturn(Optional.of(accountState)).when(accountCache).getByUsername(AUTH_USER);
    doReturn(Optional.of(accountState)).when(accountCache).get(AUTH_ACCOUNT_ID);
    doReturn(account).when(accountState).account();
    doReturn(true).when(account).isActive();
    doReturn(authSuccessful).when(accountManager).authenticate(any());
    doReturn(new WebSessionManager.Key(AUTH_COOKIE_VALUE)).when(webSessionManager).createKey(any());
    WebSessionManager.Val webSessionValue = new WebSessionManager.Val(AUTH_ACCOUNT_ID, 0L, false, null, 0L, "", "");
    doReturn(webSessionValue).when(webSessionManager).createVal(any(), any(), eq(false), any(), any(), any());
}
Also used : AuthRequest(com.google.gerrit.server.account.AuthRequest) FakeHttpServletRequest(com.google.gerrit.util.http.testutil.FakeHttpServletRequest) ExternalIdFactory(com.google.gerrit.server.account.externalids.ExternalIdFactory) AuthResult(com.google.gerrit.server.account.AuthResult) PasswordVerifier(com.google.gerrit.server.account.externalids.PasswordVerifier) ExternalIdKeyFactory(com.google.gerrit.server.account.externalids.ExternalIdKeyFactory) FakeHttpServletResponse(com.google.gerrit.util.http.testutil.FakeHttpServletResponse) Before(org.junit.Before)

Aggregations

AuthRequest (com.google.gerrit.server.account.AuthRequest)1 AuthResult (com.google.gerrit.server.account.AuthResult)1 ExternalIdFactory (com.google.gerrit.server.account.externalids.ExternalIdFactory)1 ExternalIdKeyFactory (com.google.gerrit.server.account.externalids.ExternalIdKeyFactory)1 PasswordVerifier (com.google.gerrit.server.account.externalids.PasswordVerifier)1 FakeHttpServletRequest (com.google.gerrit.util.http.testutil.FakeHttpServletRequest)1 FakeHttpServletResponse (com.google.gerrit.util.http.testutil.FakeHttpServletResponse)1 Before (org.junit.Before)1