Search in sources :

Example 6 with JHipsterProperties

use of tech.jhipster.config.JHipsterProperties in project ArTEMiS by ls1intum.

the class TokenProviderTest method testKeyIsSetFromSecretWhenSecretIsNotEmpty.

@Test
void testKeyIsSetFromSecretWhenSecretIsNotEmpty() {
    final String secret = "NwskoUmKHZtzGRKJKVjsJF7BtQMMxNWi";
    JHipsterProperties jHipsterProperties = new JHipsterProperties();
    jHipsterProperties.getSecurity().getAuthentication().getJwt().setSecret(secret);
    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(secret.getBytes(StandardCharsets.UTF_8)));
}
Also used : JHipsterProperties(tech.jhipster.config.JHipsterProperties) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) SecurityMetersService(de.tum.in.www1.artemis.management.SecurityMetersService) Key(java.security.Key) Test(org.junit.jupiter.api.Test)

Example 7 with JHipsterProperties

use of tech.jhipster.config.JHipsterProperties in project ArTEMiS by ls1intum.

the class MailServiceTest method setUp.

/**
 * Prepares the needed values and objects for testing
 */
@BeforeEach
public void setUp() {
    student1 = new User();
    student1.setId(555L);
    String EMAIL_ADDRESS_A = "benige8246@omibrown.com";
    student1.setEmail(EMAIL_ADDRESS_A);
    subject = "subject";
    content = "content";
    mimeMessage = mock(MimeMessage.class);
    javaMailSender = mock(JavaMailSender.class);
    when(javaMailSender.createMimeMessage()).thenReturn(mimeMessage);
    mail = mock(JHipsterProperties.Mail.class);
    String EMAIL_ADDRESS_B = "alex2713@gmail.com";
    when(mail.getFrom()).thenReturn(EMAIL_ADDRESS_B);
    jHipsterProperties = mock(JHipsterProperties.class);
    when(jHipsterProperties.getMail()).thenReturn(mail);
    mailService = new MailService(jHipsterProperties, javaMailSender, messageSource, templateEngine, timeService);
}
Also used : User(de.tum.in.www1.artemis.domain.User) JHipsterProperties(tech.jhipster.config.JHipsterProperties) MimeMessage(javax.mail.internet.MimeMessage) JavaMailSender(org.springframework.mail.javamail.JavaMailSender) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with JHipsterProperties

use of tech.jhipster.config.JHipsterProperties in project auth0-full-stack-java-example by oktadev.

the class StaticResourcesWebConfigurerTest method setUp.

@BeforeEach
void setUp() {
    servletContext = spy(new MockServletContext());
    applicationContext = mock(WebApplicationContext.class);
    resourceHandlerRegistry = spy(new ResourceHandlerRegistry(applicationContext, servletContext));
    props = new JHipsterProperties();
    staticResourcesWebConfiguration = spy(new StaticResourcesWebConfiguration(props));
}
Also used : JHipsterProperties(tech.jhipster.config.JHipsterProperties) StaticResourcesWebConfiguration(com.auth0.flickr2.config.StaticResourcesWebConfiguration) ResourceHandlerRegistry(org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry) MockServletContext(org.springframework.mock.web.MockServletContext) WebApplicationContext(org.springframework.web.context.WebApplicationContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 9 with JHipsterProperties

use of tech.jhipster.config.JHipsterProperties in project auth0-full-stack-java-example by oktadev.

the class WebConfigurerTest method setup.

@BeforeEach
public void setup() {
    servletContext = spy(new MockServletContext());
    doReturn(mock(FilterRegistration.Dynamic.class)).when(servletContext).addFilter(anyString(), any(Filter.class));
    doReturn(mock(ServletRegistration.Dynamic.class)).when(servletContext).addServlet(anyString(), any(Servlet.class));
    env = new MockEnvironment();
    props = new JHipsterProperties();
    webConfigurer = new WebConfigurer(env, props);
}
Also used : JHipsterProperties(tech.jhipster.config.JHipsterProperties) MockEnvironment(org.springframework.mock.env.MockEnvironment) WebServlet(org.h2.server.web.WebServlet) MockServletContext(org.springframework.mock.web.MockServletContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

JHipsterProperties (tech.jhipster.config.JHipsterProperties)9 BeforeEach (org.junit.jupiter.api.BeforeEach)7 SecurityMetersService (de.tum.in.www1.artemis.management.SecurityMetersService)5 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)5 Key (java.security.Key)3 Test (org.junit.jupiter.api.Test)2 MockServletContext (org.springframework.mock.web.MockServletContext)2 StaticResourcesWebConfiguration (com.auth0.flickr2.config.StaticResourcesWebConfiguration)1 User (de.tum.in.www1.artemis.domain.User)1 MimeMessage (javax.mail.internet.MimeMessage)1 WebServlet (org.h2.server.web.WebServlet)1 JavaMailSender (org.springframework.mail.javamail.JavaMailSender)1 MockEnvironment (org.springframework.mock.env.MockEnvironment)1 MockFilterChain (org.springframework.mock.web.MockFilterChain)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 WebApplicationContext (org.springframework.web.context.WebApplicationContext)1 ResourceHandlerRegistry (org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry)1