use of org.sonar.server.tester.AnonymousMockUserSession in project sonarqube by SonarSource.
the class UserSessionInitializerTest method assertPathIsIgnoredWithAnonymousAccess.
private void assertPathIsIgnoredWithAnonymousAccess(String path) {
when(request.getRequestURI()).thenReturn(path);
UserSession session = new AnonymousMockUserSession();
when(authenticator.authenticate(request, response)).thenReturn(session);
assertThat(underTest.initUserSession(request, response)).isTrue();
verify(threadLocalSession).set(session);
reset(threadLocalSession, authenticator);
}
use of org.sonar.server.tester.AnonymousMockUserSession in project sonarqube by SonarSource.
the class UserSessionInitializerTest method does_not_return_code_401_when_not_authenticated_and_with_force_authentication_off.
@Test
public void does_not_return_code_401_when_not_authenticated_and_with_force_authentication_off() {
when(threadLocalSession.isLoggedIn()).thenReturn(false);
when(authenticator.authenticate(request, response)).thenReturn(new AnonymousMockUserSession());
settings.setProperty("sonar.forceAuthentication", false);
assertThat(underTest.initUserSession(request, response)).isTrue();
verifyNoMoreInteractions(response);
}
use of org.sonar.server.tester.AnonymousMockUserSession in project sonarqube by SonarSource.
the class SystemWsTest method define.
@Test
public void define() {
RestartAction action1 = new RestartAction(mock(UserSession.class), mock(ProcessCommandWrapper.class), mock(RestartFlagHolder.class), mock(WebServer.class));
InfoAction action2 = new InfoAction(new AnonymousMockUserSession(), mock(SystemInfoWriter.class));
SystemWs ws = new SystemWs(action1, action2);
WebService.Context context = new WebService.Context();
ws.define(context);
assertThat(context.controllers()).hasSize(1);
assertThat(context.controller("api/system").actions()).hasSize(2);
assertThat(context.controller("api/system").action("info")).isNotNull();
}
Aggregations