|
10 | 10 | */ |
11 | 11 | public class TestHarness { |
12 | 12 |
|
13 | | - @Test |
14 | | - public void testHarness() throws Exception { |
15 | | - |
16 | | - final String secret = "This is a secret"; |
17 | | - final Algorithm algorithm = Algorithm.HS256; |
18 | | - |
19 | | - User user = new User(); |
20 | | - user.setUsername("jwt"); |
21 | | - user.setPassword("mypassword"); |
22 | | - |
23 | | - JwtProxy proxy = new JwtProxyImpl(); |
24 | | - proxy.setPayloadHandler(new BasicPayloadHandler()); |
25 | | - |
26 | | - ClaimSet claimSet = new ClaimSet(); |
27 | | - claimSet.setExp(24 * 60 * 60); // expire in 24 hours |
28 | | - String token = proxy.encode(algorithm, user, secret, claimSet); |
29 | | - |
30 | | - Object payload = proxy.decode(algorithm, token, secret); |
31 | | - assertEquals("{\"username\":\"jwt\",\"password\":\"mypassword\"}",payload); |
32 | | - } |
| 13 | + @Test |
| 14 | + public void testHarness() throws Exception { |
| 15 | + |
| 16 | + final String secret = "This is a secret"; |
| 17 | + final Algorithm algorithm = Algorithm.HS256; |
| 18 | + |
| 19 | + User user = new User(); |
| 20 | + user.setUsername("jwt"); |
| 21 | + user.setPassword("mypassword"); |
| 22 | + |
| 23 | + JwtProxy proxy = new JwtProxyImpl(); |
| 24 | + proxy.setPayloadHandler(new BasicPayloadHandler()); |
| 25 | + |
| 26 | + ClaimSet claimSet = new ClaimSet(); |
| 27 | + claimSet.setExp(24 * 60 * 60); // expire in 24 hours |
| 28 | + String token = proxy.encode(algorithm, user, secret, claimSet); |
| 29 | + |
| 30 | + Object payload = proxy.decode(algorithm, token, secret); |
| 31 | + assertEquals("{\"username\":\"jwt\",\"password\":\"mypassword\"}",payload); |
| 32 | + } |
33 | 33 | } |
0 commit comments