Search in sources :

Example 11 with IdmJwtAuthenticationDto

use of eu.bcvsolutions.idm.core.security.api.dto.IdmJwtAuthenticationDto in project CzechIdMng by bcvsolutions.

the class ExtendExpirationFilterTest method testSuccBasicAuthTokenExtension.

@Test
public void testSuccBasicAuthTokenExtension() throws Exception {
    IdmJwtAuthenticationDto authDto = AuthenticationTestUtils.getAuthDto(identityService.getByUsername(TEST_ADMIN_USERNAME), Lists.newArrayList(IdmAuthorityUtils.getAdminAuthority()));
    String token = getAuthToken(authDto);
    String basicAuth = AuthenticationTestUtils.getBasicAuth(TEST_ADMIN_USERNAME, TEST_ADMIN_PASSWORD);
    sleep();
    MvcResult result = getMockMvc().perform(get(AuthenticationTestUtils.getSelfPath(TEST_ADMIN_USERNAME)).header("Authorization", "Basic " + basicAuth).header(JwtAuthenticationMapper.AUTHENTICATION_TOKEN_NAME, token).contentType(HAL_CONTENT_TYPE)).andExpect(status().isOk()).andExpect(content().contentType(HAL_CONTENT_TYPE)).andExpect(jsonPath("$.username", equalTo(TEST_ADMIN_USERNAME))).andReturn();
    IdmJwtAuthenticationDto extendedDto = getIdmJwtDto(result);
    checkSuccessfulTokenExtension(authDto, extendedDto);
}
Also used : IdmJwtAuthenticationDto(eu.bcvsolutions.idm.core.security.api.dto.IdmJwtAuthenticationDto) MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.Test) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest)

Aggregations

IdmJwtAuthenticationDto (eu.bcvsolutions.idm.core.security.api.dto.IdmJwtAuthenticationDto)11 Test (org.junit.Test)5 AbstractRestTest (eu.bcvsolutions.idm.test.api.AbstractRestTest)3 IOException (java.io.IOException)3 IdmJwtAuthentication (eu.bcvsolutions.idm.core.security.api.domain.IdmJwtAuthentication)2 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)2 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)2 Jwt (org.springframework.security.jwt.Jwt)2 MvcResult (org.springframework.test.web.servlet.MvcResult)2 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)1 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)1 DefaultGrantedAuthorityDto (eu.bcvsolutions.idm.core.security.api.dto.DefaultGrantedAuthorityDto)1 IdmAuthenticationException (eu.bcvsolutions.idm.core.security.exception.IdmAuthenticationException)1 Authentication (org.springframework.security.core.Authentication)1 AuthenticationException (org.springframework.security.core.AuthenticationException)1 InvalidSignatureException (org.springframework.security.jwt.crypto.sign.InvalidSignatureException)1