Search in sources :

Example 1 with ThreadLocalUserSession

use of org.sonar.server.user.ThreadLocalUserSession in project sonarqube by SonarSource.

the class BaseContextFactoryTest method authenticate.

@Test
public void authenticate() throws Exception {
    BaseIdentityProvider.Context context = underTest.newContext(request, response, identityProvider);
    HttpSession session = mock(HttpSession.class);
    when(request.getSession()).thenReturn(session);
    context.authenticate(USER_IDENTITY);
    verify(userIdentityAuthenticator).authenticate(USER_IDENTITY, identityProvider, AuthenticationEvent.Source.external(identityProvider));
    verify(jwtHttpHandler).generateToken(any(UserDto.class), eq(request), eq(response));
    verify(threadLocalUserSession).set(any(UserSession.class));
}
Also used : HttpSession(javax.servlet.http.HttpSession) UserDto(org.sonar.db.user.UserDto) UserTesting.newUserDto(org.sonar.db.user.UserTesting.newUserDto) ThreadLocalUserSession(org.sonar.server.user.ThreadLocalUserSession) UserSession(org.sonar.server.user.UserSession) BaseIdentityProvider(org.sonar.api.server.authentication.BaseIdentityProvider) Test(org.junit.Test)

Aggregations

HttpSession (javax.servlet.http.HttpSession)1 Test (org.junit.Test)1 BaseIdentityProvider (org.sonar.api.server.authentication.BaseIdentityProvider)1 UserDto (org.sonar.db.user.UserDto)1 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)1 ThreadLocalUserSession (org.sonar.server.user.ThreadLocalUserSession)1 UserSession (org.sonar.server.user.UserSession)1