use of org.zaproxy.zap.users.AuthenticationState in project zaproxy by zaproxy.
the class AuthenticationMethodIndicatorsUnitTest method shouldIdentifyLoggedOutResponseWithComplexRegex.
@Test
void shouldIdentifyLoggedOutResponseWithComplexRegex() {
// Given
method.setLoggedOutIndicatorPattern(LOGGED_OUT_COMPLEX_INDICATOR);
loginMessage.setResponseBody(LOGGED_OUT_COMPLEX_BODY);
User user = mock(User.class);
given(user.getAuthenticationState()).willReturn(new AuthenticationState());
// When/Then
assertThat(method.isAuthenticated(loginMessage, user), is(false));
}
use of org.zaproxy.zap.users.AuthenticationState in project zaproxy by zaproxy.
the class AuthenticationMethodIndicatorsUnitTest method shouldIdentifyLoggedInResponseBodyWhenLoggedOutIndicatorIsSet.
@Test
void shouldIdentifyLoggedInResponseBodyWhenLoggedOutIndicatorIsSet() {
// Given
method.setLoggedOutIndicatorPattern(LOGGED_OUT_INDICATOR);
loginMessage.setResponseBody(LOGGED_IN_BODY);
User user = mock(User.class);
given(user.getAuthenticationState()).willReturn(new AuthenticationState());
// When/Then
assertThat(method.isAuthenticated(loginMessage, user), is(true));
}
use of org.zaproxy.zap.users.AuthenticationState in project zaproxy by zaproxy.
the class AuthenticationMethodIndicatorsUnitTest method shouldIdentifyLoggedInResponseHeaderWhenLoggedInIndicatorIsSet.
@Test
void shouldIdentifyLoggedInResponseHeaderWhenLoggedInIndicatorIsSet() {
// Given
method.setLoggedInIndicatorPattern(LOGGED_IN_INDICATOR);
loginMessage.getResponseHeader().addHeader("test", LOGGED_IN_INDICATOR);
User user = mock(User.class);
given(user.getAuthenticationState()).willReturn(new AuthenticationState());
// When/Then
assertThat(method.isAuthenticated(loginMessage, user), is(true));
}
use of org.zaproxy.zap.users.AuthenticationState in project zaproxy by zaproxy.
the class AuthenticationMethodIndicatorsUnitTest method shouldIdentifyLoggedOutRequestBodyWhenLoggedInIndicatorIsSet.
@Test
void shouldIdentifyLoggedOutRequestBodyWhenLoggedInIndicatorIsSet() {
// Given
method.setLoggedInIndicatorPattern(LOGGED_IN_INDICATOR);
method.setAuthCheckingStrategy(AuthCheckingStrategy.EACH_REQ);
loginMessage.setRequestBody(LOGGED_OUT_BODY);
User user = mock(User.class);
given(user.getAuthenticationState()).willReturn(new AuthenticationState());
// When/Then
assertThat(method.isAuthenticated(loginMessage, user), is(false));
}
use of org.zaproxy.zap.users.AuthenticationState in project zaproxy by zaproxy.
the class AuthenticationMethodIndicatorsUnitTest method shouldIdentifyLoggedOutResponseHeaderWhenLoggedInIndicatorIsSet.
@Test
void shouldIdentifyLoggedOutResponseHeaderWhenLoggedInIndicatorIsSet() {
// Given
method.setLoggedInIndicatorPattern(LOGGED_IN_INDICATOR);
loginMessage.getResponseHeader().addHeader("test", LOGGED_OUT_INDICATOR);
User user = mock(User.class);
given(user.getAuthenticationState()).willReturn(new AuthenticationState());
// When/Then
assertThat(method.isAuthenticated(loginMessage, user), is(false));
}
Aggregations