Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
southeo committed Dec 12, 2024
1 parent b26192c commit 32d6396
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.springframework.boot.actuate.health.HealthEndpoint;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.http.SessionCreationPolicy;
Expand All @@ -22,9 +21,10 @@ public class WebSecurityConfig {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(authorizeHttpRequests -> authorizeHttpRequests
.requestMatchers(EndpointRequest.to(HealthEndpoint.class)).permitAll()
.requestMatchers(HttpMethod.GET, "**").permitAll()
.anyRequest().authenticated());
.requestMatchers(EndpointRequest.to(HealthEndpoint.class))
.permitAll()
.anyRequest()
.hasRole("orchestration-admin"));

http.oauth2ResourceServer(jwtoauth2ResourceServer -> jwtoauth2ResourceServer.jwt((
jwt -> jwt.jwtAuthenticationConverter(jwtAuthConverter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,10 @@ void testDataCiteConflict() throws Exception {
.setResponseCode(HttpStatus.UNPROCESSABLE_ENTITY.value())
.setBody(givenDataCiteErrorResponse(true))
.addHeader("Content-Type", "application/json"));
var expectedMessage = "DOI " + PID + " has already been taken";

// When
var e = assertThrows(DataCiteApiException.class,
// When / Then
assertThrows(DataCiteApiException.class,
() -> dataCiteClient.sendDoiRequest(request, HttpMethod.POST, DOI));

assertThat(e.getMessage()).contains(expectedMessage);
}

@Test
Expand All @@ -169,13 +166,11 @@ void testDataCiteNotFound() throws Exception {
.setResponseCode(HttpStatus.NOT_FOUND.value())
.setBody(givenDataCiteErrorResponse(false))
.addHeader("Content-Type", "application/json"));
var expectedMessage = ALT_ERROR + " DataCite credentials may be incorrect";

// When
var e = assertThrows(DataCiteApiException.class,
// When / Then
assertThrows(DataCiteApiException.class,
() -> dataCiteClient.sendDoiRequest(request, HttpMethod.POST, DOI));

assertThat(e.getMessage()).contains(expectedMessage);
}

@Test
Expand Down

0 comments on commit 32d6396

Please sign in to comment.