Search in sources :

Example 1 with GraviteeAuthenticationDetails

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());
}
Also used : GraviteeAuthenticationDetails(io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails) HttpSession(javax.servlet.http.HttpSession) Test(org.junit.Test)

Example 2 with GraviteeAuthenticationDetails

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));
}
Also used : GraviteeAuthenticationDetails(io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails) WebAuthenticationDetails(org.springframework.security.web.authentication.WebAuthenticationDetails) Test(org.junit.Test)

Example 3 with GraviteeAuthenticationDetails

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());
}
Also used : GraviteeAuthenticationDetails(io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails) Test(org.junit.Test)

Example 4 with GraviteeAuthenticationDetails

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));
}
Also used : GraviteeAuthenticationDetails(io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails) Test(org.junit.Test)

Example 5 with GraviteeAuthenticationDetails

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));
}
Also used : GraviteeAuthenticationDetails(io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

GraviteeAuthenticationDetails (io.gravitee.rest.api.security.authentication.GraviteeAuthenticationDetails)7 Test (org.junit.Test)6 HashMap (java.util.HashMap)1 HttpSession (javax.servlet.http.HttpSession)1 WebAuthenticationDetails (org.springframework.security.web.authentication.WebAuthenticationDetails)1