File tree Expand file tree Collapse file tree
rentplace/src/test/java/kattsyn/dev/rentplace/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package kattsyn .dev .rentplace .utils ;
2+
3+ import io .jsonwebtoken .Claims ;
4+ import kattsyn .dev .rentplace .auth .JwtAuthentication ;
5+ import kattsyn .dev .rentplace .enums .Role ;
6+ import org .junit .jupiter .api .Test ;
7+ import static org .junit .jupiter .api .Assertions .*;
8+ import static org .mockito .Mockito .mock ;
9+ import static org .mockito .Mockito .when ;
10+
11+ class JwtUtilsTest {
12+
13+ @ Test
14+ void generate_JwtAuthenticationWithCorrectFields () {
15+ Claims claims = mock (Claims .class );
16+ when (claims .getSubject ()).thenReturn ("user@test.com" );
17+ when (claims .get ("name" , String .class )).thenReturn ("Test User" );
18+ when (claims .get ("role" , String .class )).thenReturn ("ROLE_USER" );
19+
20+ JwtAuthentication auth = JwtUtils .generate (claims );
21+
22+ assertEquals ("user@test.com" , auth .getEmail ());
23+ assertEquals (Role .ROLE_USER , auth .getRole ());
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments