use of org.zaproxy.zap.users.AuthenticationState in project zaproxy by zaproxy.
the class AuthenticationMethodIndicatorsUnitTest method shouldIdentifyLoggedInRequestHeaderWhenLoggedOutIndicatorIsSet.
@Test
void shouldIdentifyLoggedInRequestHeaderWhenLoggedOutIndicatorIsSet() {
// Given
method.setLoggedOutIndicatorPattern(LOGGED_OUT_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 shouldIdentifyLoggedOutRequestWithComplexRegex.
@Test
void shouldIdentifyLoggedOutRequestWithComplexRegex() {
// Given
method.setLoggedOutIndicatorPattern(LOGGED_OUT_COMPLEX_INDICATOR);
method.setAuthCheckingStrategy(AuthCheckingStrategy.EACH_REQ);
loginMessage.setRequestBody(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 shouldIdentifyLoggedOutResponseHeaderWhenLoggedOutIndicatorIsSet.
@Test
void shouldIdentifyLoggedOutResponseHeaderWhenLoggedOutIndicatorIsSet() {
// Given
method.setLoggedOutIndicatorPattern(LOGGED_OUT_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));
}
use of org.zaproxy.zap.users.AuthenticationState in project zaproxy by zaproxy.
the class AuthenticationMethodIndicatorsUnitTest method shouldIdentifyRequestAsLoggedInWhenNoIndicatorIsSet.
@Test
void shouldIdentifyRequestAsLoggedInWhenNoIndicatorIsSet() {
// Given
loginMessage.setRequestBody(LOGGED_OUT_BODY);
method.setAuthCheckingStrategy(AuthCheckingStrategy.EACH_REQ);
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 shouldIdentifyLoggedInResponseBodyWhenLoggedInIndicatorIsSet.
@Test
void shouldIdentifyLoggedInResponseBodyWhenLoggedInIndicatorIsSet() {
// Given
method.setLoggedInIndicatorPattern(LOGGED_IN_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));
}
Aggregations