use of org.sonar.server.tester.AnonymousMockUserSession in project sonarqube by SonarSource.
the class SetSeverityActionTest method fail_if_parameter_not_found.
@Test
public void fail_if_parameter_not_found() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Missing parameter : 'severity'");
action.verify(ImmutableMap.of("unknwown", MINOR), Lists.newArrayList(), new AnonymousMockUserSession());
}
use of org.sonar.server.tester.AnonymousMockUserSession in project sonarqube by SonarSource.
the class UserSessionInitializerTest method return_code_401_when_not_authenticated_and_with_force_authentication.
@Test
public void return_code_401_when_not_authenticated_and_with_force_authentication() {
ArgumentCaptor<AuthenticationException> exceptionArgumentCaptor = ArgumentCaptor.forClass(AuthenticationException.class);
when(threadLocalSession.isLoggedIn()).thenReturn(false);
when(authenticator.authenticate(request, response)).thenReturn(new AnonymousMockUserSession());
assertThat(underTest.initUserSession(request, response)).isTrue();
verifyNoMoreInteractions(response);
verify(authenticationEvent).loginFailure(eq(request), exceptionArgumentCaptor.capture());
verifyNoMoreInteractions(threadLocalSession);
AuthenticationException authenticationException = exceptionArgumentCaptor.getValue();
assertThat(authenticationException.getSource()).isEqualTo(Source.local(Method.BASIC));
assertThat(authenticationException.getLogin()).isNull();
assertThat(authenticationException.getMessage()).isEqualTo("User must be authenticated");
assertThat(authenticationException.getPublicMessage()).isNull();
}
use of org.sonar.server.tester.AnonymousMockUserSession in project sonarqube by SonarSource.
the class RequestAuthenticatorImplTest method setUp.
@Before
public void setUp() {
when(sessionFactory.create(A_USER)).thenReturn(new MockUserSession(A_USER));
when(sessionFactory.createAnonymous()).thenReturn(new AnonymousMockUserSession());
}
use of org.sonar.server.tester.AnonymousMockUserSession in project sonarqube by SonarSource.
the class CommentActionTest method should_verify_fail_if_parameter_not_found.
@Test
public void should_verify_fail_if_parameter_not_found() {
Map<String, Object> properties = singletonMap("unknwown", "unknown value");
try {
action.verify(properties, new ArrayList<>(), new AnonymousMockUserSession());
fail();
} catch (Exception e) {
assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("Missing parameter : 'comment'");
}
verifyZeroInteractions(issueUpdater);
}
use of org.sonar.server.tester.AnonymousMockUserSession in project sonarqube by SonarSource.
the class ThreadLocalUserSessionTest method get_session_for_anonymous.
@Test
public void get_session_for_anonymous() {
AnonymousMockUserSession expected = new AnonymousMockUserSession();
threadLocalUserSession.set(expected);
UserSession session = threadLocalUserSession.get();
assertThat(session).isSameAs(expected);
assertThat(threadLocalUserSession.getLogin()).isNull();
assertThat(threadLocalUserSession.isLoggedIn()).isFalse();
assertThat(threadLocalUserSession.shouldResetPassword()).isFalse();
assertThat(threadLocalUserSession.getGroups()).isEmpty();
}
Aggregations