use of io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails in project gravitee-management-rest-api by gravitee-io.
the class GraviteeAuthenticationDetailsTest method shouldNotOverrideGetSession.
@Test
public void shouldNotOverrideGetSession() {
HttpSession sessionMock = mock(HttpSession.class);
when(httpServletRequest.getSession(false)).thenReturn(sessionMock);
when(sessionMock.getId()).thenReturn("sessionId");
GraviteeAuthenticationDetails authenticationDetails = new GraviteeAuthenticationDetails(httpServletRequest);
assertEquals("sessionId", authenticationDetails.getSessionId());
}
use of io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails in project gravitee-management-rest-api by gravitee-io.
the class GraviteeAuthenticationDetailsTest method shouldNotBeEqualsWhenCompareToParentType.
@Test
public void shouldNotBeEqualsWhenCompareToParentType() {
when(httpServletRequest.getHeader("X-Forwarded-For")).thenReturn("CORRECT_IP,PROXY_IP");
when(httpServletRequest.getRemoteAddr()).thenReturn("PROXY_IP");
GraviteeAuthenticationDetails authenticationDetails = new GraviteeAuthenticationDetails(httpServletRequest);
assertNotEquals(authenticationDetails, new WebAuthenticationDetails(httpServletRequest));
}
use of io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails in project gravitee-management-rest-api by gravitee-io.
the class GraviteeAuthenticationDetailsTest method shouldGetCorrectIPWithoutProxy.
@Test
public void shouldGetCorrectIPWithoutProxy() {
when(httpServletRequest.getRemoteAddr()).thenReturn("CORRECT_IP");
GraviteeAuthenticationDetails authenticationDetails = new GraviteeAuthenticationDetails(httpServletRequest);
assertEquals("CORRECT_IP", authenticationDetails.getRemoteAddress());
}
use of io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails in project gravitee-management-rest-api by gravitee-io.
the class GraviteeAuthenticationDetailsTest method shouldObjectBeEqualsForSameRequest.
@Test
public void shouldObjectBeEqualsForSameRequest() {
when(httpServletRequest.getHeader("X-Forwarded-For")).thenReturn("CORRECT_IP,PROXY_IP");
when(httpServletRequest.getRemoteAddr()).thenReturn("PROXY_IP");
GraviteeAuthenticationDetails authenticationDetails = new GraviteeAuthenticationDetails(httpServletRequest);
assertEquals(authenticationDetails, new GraviteeAuthenticationDetails(httpServletRequest));
}
use of io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails in project gravitee-management-rest-api by gravitee-io.
the class GraviteeAuthenticationDetailsTest method shouldHashCodeBeEqualsForSameValues.
@Test
public void shouldHashCodeBeEqualsForSameValues() {
when(httpServletRequest.getHeader("X-Forwarded-For")).thenReturn("CORRECT_IP,PROXY_IP");
when(httpServletRequest.getRemoteAddr()).thenReturn("PROXY_IP");
GraviteeAuthenticationDetails authenticationDetails = new GraviteeAuthenticationDetails(httpServletRequest);
Map<GraviteeAuthenticationDetails, String> map = new HashMap<>();
map.put(authenticationDetails, "found");
assertEquals("found", map.get(authenticationDetails));
}
Aggregations