use of org.zaproxy.zap.users.AuthenticationState in project zaproxy by zaproxy.
the class AuthenticationMethodIndicatorsUnitTest method shouldIdentifyLoggedInRequestHeaderWhenLoggedInIndicatorIsSet.
@Test
void shouldIdentifyLoggedInRequestHeaderWhenLoggedInIndicatorIsSet() {
// Given
method.setLoggedInIndicatorPattern(LOGGED_IN_INDICATOR);
method.setAuthCheckingStrategy(AuthCheckingStrategy.EACH_REQ);
loginMessage.getRequestHeader().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 shouldIdentifyLoggedOutResponseBodyWhenLoggedOutIndicatorIsSet.
@Test
void shouldIdentifyLoggedOutResponseBodyWhenLoggedOutIndicatorIsSet() {
// Given
method.setLoggedOutIndicatorPattern(LOGGED_OUT_INDICATOR);
loginMessage.setResponseBody(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 shouldIdentifyLoggedInResponseWithComplexRegex.
@Test
void shouldIdentifyLoggedInResponseWithComplexRegex() {
// Given
method.setLoggedOutIndicatorPattern(LOGGED_OUT_COMPLEX_INDICATOR);
loginMessage.setResponseBody(LOGGED_OUT_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 shouldIdentifyLoggedOutRequestHeaderWhenLoggedInIndicatorIsSet.
@Test
void shouldIdentifyLoggedOutRequestHeaderWhenLoggedInIndicatorIsSet() {
// Given
method.setLoggedInIndicatorPattern(LOGGED_IN_INDICATOR);
method.setAuthCheckingStrategy(AuthCheckingStrategy.EACH_REQ);
loginMessage.getRequestHeader().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));
}
use of org.zaproxy.zap.users.AuthenticationState in project zaproxy by zaproxy.
the class AuthenticationMethodIndicatorsUnitTest method shouldIdentifyLoggedOutRequestHeaderWhenLoggedOutIndicatorIsSet.
@Test
void shouldIdentifyLoggedOutRequestHeaderWhenLoggedOutIndicatorIsSet() {
// Given
method.setLoggedOutIndicatorPattern(LOGGED_OUT_INDICATOR);
method.setAuthCheckingStrategy(AuthCheckingStrategy.EACH_REQ);
loginMessage.getRequestHeader().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