use of tech.jhipster.config.JHipsterProperties in project ArTEMiS by ls1intum.
the class TokenProviderSecurityMetersTests method setup.
@BeforeEach
public void setup() {
JHipsterProperties jHipsterProperties = new JHipsterProperties();
String base64Secret = "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8";
jHipsterProperties.getSecurity().getAuthentication().getJwt().setBase64Secret(base64Secret);
meterRegistry = new SimpleMeterRegistry();
SecurityMetersService securityMetersService = new SecurityMetersService(meterRegistry);
tokenProvider = new TokenProvider(jHipsterProperties, securityMetersService);
Key key = Keys.hmacShaKeyFor(Decoders.BASE64.decode(base64Secret));
ReflectionTestUtils.setField(tokenProvider, "key", key);
ReflectionTestUtils.setField(tokenProvider, "tokenValidityInMilliseconds", ONE_MINUTE);
}
use of tech.jhipster.config.JHipsterProperties in project ArTEMiS by ls1intum.
the class JWTFilterTest method setup.
@BeforeEach
public void setup() {
JHipsterProperties jHipsterProperties = new JHipsterProperties();
String base64Secret = "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8";
jHipsterProperties.getSecurity().getAuthentication().getJwt().setBase64Secret(base64Secret);
SecurityMetersService securityMetersService = new SecurityMetersService(new SimpleMeterRegistry());
tokenProvider = new TokenProvider(jHipsterProperties, securityMetersService);
ReflectionTestUtils.setField(tokenProvider, "key", Keys.hmacShaKeyFor(Decoders.BASE64.decode(base64Secret)));
ReflectionTestUtils.setField(tokenProvider, "tokenValidityInMilliseconds", 60000);
jwtFilter = new JWTFilter(tokenProvider);
SecurityContextHolder.getContext().setAuthentication(null);
}
use of tech.jhipster.config.JHipsterProperties in project ArTEMiS by ls1intum.
the class TokenProviderTest method setup.
@BeforeEach
public void setup() {
JHipsterProperties jHipsterProperties = new JHipsterProperties();
String base64Secret = "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8";
jHipsterProperties.getSecurity().getAuthentication().getJwt().setBase64Secret(base64Secret);
SecurityMetersService securityMetersService = new SecurityMetersService(new SimpleMeterRegistry());
tokenProvider = new TokenProvider(jHipsterProperties, securityMetersService);
key = Keys.hmacShaKeyFor(Decoders.BASE64.decode(base64Secret));
ReflectionTestUtils.setField(tokenProvider, "key", key);
ReflectionTestUtils.setField(tokenProvider, "tokenValidityInMilliseconds", ONE_MINUTE);
}
use of tech.jhipster.config.JHipsterProperties in project ArTEMiS by ls1intum.
the class TokenProviderTest method testKeyIsSetFromBase64SecretWhenSecretIsEmpty.
@Test
void testKeyIsSetFromBase64SecretWhenSecretIsEmpty() {
final String base64Secret = "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8";
JHipsterProperties jHipsterProperties = new JHipsterProperties();
jHipsterProperties.getSecurity().getAuthentication().getJwt().setBase64Secret(base64Secret);
SecurityMetersService securityMetersService = new SecurityMetersService(new SimpleMeterRegistry());
TokenProvider tokenProvider = new TokenProvider(jHipsterProperties, securityMetersService);
tokenProvider.init();
Key key = (Key) ReflectionTestUtils.getField(tokenProvider, "key");
assertThat(key).isNotNull().isEqualTo(Keys.hmacShaKeyFor(Decoders.BASE64.decode(base64Secret)));
}
use of tech.jhipster.config.JHipsterProperties in project jhipster-bom by jhipster.
the class CachingHttpHeadersFilterTest method setup.
@BeforeEach
void setup() {
request = new MockHttpServletRequest();
response = spy(new MockHttpServletResponse());
chain = spy(new MockFilterChain());
properties = new JHipsterProperties();
filter = new CachingHttpHeadersFilter(properties);
}
Aggregations