@@ -0,0 +1,2355 @@
+package net.davidvoid.thor.lightning.service.security;%0A%0Aimport io.jsonwebtoken.Jwts;%0Aimport io.jsonwebtoken.SignatureAlgorithm;%0Aimport net.davidvoid.thor.lightning.config.RootConfig;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.mock.web.MockFilterChain;%0Aimport org.springframework.security.core.context.SecurityContextHolder;%0Aimport org.springframework.test.context.ActiveProfiles;%0Aimport org.springframework.test.context.ContextConfiguration;%0Aimport org.springframework.test.context.junit4.SpringJUnit4ClassRunner;%0A%0Aimport javax.servlet.FilterChain;%0Aimport javax.servlet.ServletRequest;%0Aimport javax.servlet.ServletResponse;%0Aimport javax.servlet.http.Cookie;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0Aimport java.util.Date;%0A%0Aimport static org.junit.Assert.*;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0A/**%0A * Created by david on 5/4/16.%0A */%0A@RunWith(SpringJUnit4ClassRunner.class)%0A@ActiveProfiles(%22test%22)%0A@ContextConfiguration(classes = %7B RootConfig.class %7D)%0Apublic class JwtAuthenticationFilterTest %7B%0A    @Autowired%0A    JwtAuthenticationFilter filter = null;%0A%0A    @Test%0A    public void doFilter_givenValidToken_WillSuccess() throws Exception %7B%0A        FilterChain filterChain = mock(FilterChain.class);%0A        Cookie cookie = mock(Cookie.class);%0A        HttpServletRequest request = mock(HttpServletRequest.class);%0A        HttpServletResponse response = mock(HttpServletResponse.class);%0A        Cookie%5B%5D cookies = %7Bcookie%7D;%0A        when(request.getCookies()).thenReturn(cookies);%0A%0A        String key = JwtAuthenticationServiceTest.load_key(%22config/key.hmac%22);%0A        String token = Jwts.builder().signWith(SignatureAlgorithm.HS512, key).claim(%22uid%22, 123).setSubject(%22david%22).setIssuedAt(new Date()).compact();%0A        when(cookie.getName()).thenReturn(%22jwt-token%22);%0A        when(cookie.getValue()).thenReturn(token);%0A%0A        filter.doFilter(request, response, filterChain);%0A        assertNotNull(SecurityContextHolder.getContext().getAuthentication());%0A        ThorAuthentication auth = (ThorAuthentication) SecurityContextHolder.getContext().getAuthentication();%0A        assertEquals(%22david%22, auth.getName());%0A        assertEquals(123, auth.getId());%0A    %7D%0A%7D

add test for JwtAuthenticationFilter