Fix failing tests.

This commit is contained in:
Paulo Gustavo Veiga 2023-07-30 18:21:25 -07:00
parent 0090464d88
commit 963ed70d8d
3 changed files with 21 additions and 21 deletions

View File

@ -37,6 +37,6 @@ Template Path: /service/admin/users/{userId}/password
Creating a new user: Creating a new user:
* Template Path: /service/admin/users/ * Template Path: /service/admin/users/
* Method: Post * Method: Post
* curl "http://{host.name}:{host.port}/{context.path}/service/admin/users" --request POST --basic -u "admin@wisemapping.org:test" -H "Content-Type:application/json" --data '{"email": "te2@mydomain.de", "lastname": "lastname", "firstname":"myfirstname","password":"password"}' * curl "http://{host.name}:{host.port}/{context.path}/service/admin/users/" --request POST --basic -u "admin@wisemapping.org:test" -H "Content-Type:application/json" --data '{"email": "te2@mydomain.de", "lastname": "lastname", "firstname":"myfirstname","password":"password"}'

View File

@ -175,16 +175,16 @@
<artifactId>commons-dbcp2</artifactId> <artifactId>commons-dbcp2</artifactId>
<version>2.9.0</version> <version>2.9.0</version>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>org.hibernate</groupId> <!-- <groupId>org.hibernate</groupId>-->
<artifactId>hibernate-ehcache</artifactId> <!-- <artifactId>hibernate-ehcache</artifactId>-->
<version>5.6.15.Final</version> <!-- <version>5.6.15.Final</version>-->
</dependency> <!-- </dependency>-->
<dependency> <!-- <dependency>-->
<groupId>javax.cache</groupId> <!-- <groupId>javax.cache</groupId>-->
<artifactId>cache-api</artifactId> <!-- <artifactId>cache-api</artifactId>-->
<version>1.1.1</version> <!-- <version>1.1.1</version>-->
</dependency> <!-- </dependency>-->
<dependency> <dependency>
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId> <artifactId>log4j-core</artifactId>

View File

@ -11,7 +11,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.SecurityFilterChain;
@ -21,7 +20,7 @@ import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
@Configuration @Configuration
@EnableWebSecurity(debug = true) @EnableWebSecurity
public class SecurityConfig { public class SecurityConfig {
@Autowired @Autowired
UserService userService; UserService userService;
@ -62,7 +61,7 @@ public class SecurityConfig {
@Bean @Bean
@Order(1) @Order(1)
public SecurityFilterChain filterChain(@NotNull final HttpSecurity http, @NotNull final HandlerMappingIntrospector introspector) throws Exception { public SecurityFilterChain mvcFilterChain(@NotNull final HttpSecurity http, @NotNull final HandlerMappingIntrospector introspector) throws Exception {
final AuthenticationSuccessHandler authenticationSuccessHandler = new AuthenticationSuccessHandler(); final AuthenticationSuccessHandler authenticationSuccessHandler = new AuthenticationSuccessHandler();
authenticationSuccessHandler.setAlwaysUseDefaultTargetUrl(false); authenticationSuccessHandler.setAlwaysUseDefaultTargetUrl(false);
authenticationSuccessHandler.setDefaultTargetUrl("/c/maps/"); authenticationSuccessHandler.setDefaultTargetUrl("/c/maps/");
@ -78,12 +77,9 @@ public class SecurityConfig {
(auth) -> (auth) ->
auth auth
.requestMatchers("/login", "logout").permitAll() .requestMatchers("/login", "logout").permitAll()
.requestMatchers("/registration", "registration-success").permitAll() .requestMatchers("/registration", "registration-success", "/registration-google").permitAll()
.requestMatchers("/registration-google").permitAll()
.requestMatchers("/forgot-password", "/forgot-password-success").permitAll() .requestMatchers("/forgot-password", "/forgot-password-success").permitAll()
.requestMatchers("/maps/*/embed").permitAll() .requestMatchers("/maps/*/embed", "/maps/*/try", "/maps/*/public").permitAll()
.requestMatchers("/maps/*/try").permitAll()
.requestMatchers("/maps/*/public").permitAll()
.requestMatchers("/restful/maps/*/document/xml-pub").permitAll() .requestMatchers("/restful/maps/*/document/xml-pub").permitAll()
.requestMatchers("/**").hasAnyRole("USER", "ADMIN") .requestMatchers("/**").hasAnyRole("USER", "ADMIN")
.anyRequest().authenticated()) .anyRequest().authenticated())
@ -112,8 +108,12 @@ public class SecurityConfig {
} }
@Bean @Bean
public WebSecurityCustomizer webSecurityCustomizer() { @Order(3)
return (web) -> web.ignoring().requestMatchers("/static/**", "/css/**", "/js/**", "/images/**"); public SecurityFilterChain shareResourcesFilterChain(@NotNull final HttpSecurity http, @NotNull final HandlerMappingIntrospector introspector) throws Exception {
return http.authorizeHttpRequests(
(auth) ->
auth.requestMatchers("/static/**", "/css/**", "/js/**", "/images/**", "/").permitAll()
).build();
} }
@Bean @Bean