Auf Thema antworten

Also es hängt wirklich nur an Zeile 16 in meiner SecurityConfig, sobald ich die raus nehme, laufen die Tests durch.

[CODE lang="java" highlight="16"]@Configuration

@EnableWebSecurity

@EnableGlobalMethodSecurity(prePostEnabled = true)

public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override

    protected void configure(HttpSecurity http) throws Exception {

        http.csrf().disable()

                .cors(Customizer.withDefaults())

                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)

                .and()

                .formLogin().disable()

                .anonymous().disable()

                .authorizeRequests()

                .anyRequest().authenticated()

                .and()

                .oauth2ResourceServer().jwt();

    }

}[/CODE]


Eine TestSecurityConfig ist jetzt erstmal mein Workaround.

[CODE=java]@Configuration

@EnableWebSecurity

@EnableGlobalMethodSecurity(prePostEnabled = true)

@Profile("test")

public class TestSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override

    protected void configure(HttpSecurity http) throws Exception {

        http.csrf().disable()

                .cors(Customizer.withDefaults())

                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)

                .and()

                .formLogin().disable()

                .anonymous().disable()

                .authorizeRequests()

                .anyRequest().authenticated()

                .and();

    }

}[/CODE]


Sollte doch noch jemandem was auffallen, würde ich mich sehr freuen.



Oben