use of org.springframework.security.jwt.crypto.sign.MacSigner in project faf-java-server by FAForever.
the class CustomIceServersProviderTest method getIceServerList.
@Test
@SuppressWarnings("unchecked")
public void getIceServerList() throws Exception {
String claim = "{\"expiresAt\": \"ff\"}";
when(objectMapper.writeValueAsString(any())).thenReturn(claim);
properties.getIce().setServers(Arrays.asList(new Server().setUrl("http://localhost:1234"), new Server().setUrl("http://localhost:2345")));
IceServerList result = instance.getIceServerList();
ArgumentCaptor<Map<String, Object>> captor = ArgumentCaptor.forClass((Class) Map.class);
verify(objectMapper, times(2)).writeValueAsString(captor.capture());
Map<String, Object> map = captor.getValue();
assertThat(map.get("expiresAt"), is(notNullValue()));
List<IceServer> servers = result.getServers();
assertThat(servers, hasSize(2));
assertThat(servers.get(0).getUrl(), is(URI.create("http://localhost:1234")));
assertThat(servers.get(0).getCredential(), is(notNullValue()));
assertThat(servers.get(0).getUsername(), is(notNullValue()));
assertThat(servers.get(1).getUrl(), is(URI.create("http://localhost:2345")));
assertThat(servers.get(1).getCredential(), is(notNullValue()));
assertThat(servers.get(1).getUsername(), is(notNullValue()));
MacSigner macSigner = new MacSigner(properties.getJwt().getSecret());
Jwt jwt = JwtHelper.decodeAndVerify(servers.get(0).getCredential(), macSigner);
assertThat(jwt.getClaims(), is(claim));
}
Aggregations