diff --git a/fachstelle-server/pom.xml b/fachstelle-server/pom.xml index 450e804f38aad4055ed8a86aecc2b9e04f6b4224..c62e3962e77d638efb0d049dd9a9f5df94390c20 100644 --- a/fachstelle-server/pom.xml +++ b/fachstelle-server/pom.xml @@ -148,6 +148,10 @@ <groupId>org.springframework.security</groupId> <artifactId>spring-security-saml2-service-provider</artifactId> </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-oauth2-resource-server</artifactId> + </dependency> <dependency> <groupId>org.springframework.hateoas</groupId> <artifactId>spring-hateoas</artifactId> diff --git a/fachstelle-server/src/main/java/de/ozgcloud/fachstelle/SecurityConfiguration.java b/fachstelle-server/src/main/java/de/ozgcloud/fachstelle/SecurityConfiguration.java index c6edb3c35af0710469da2d13489ec961790147f0..33419eb9b879a029feebf98a3e58be9a10e32ed1 100644 --- a/fachstelle-server/src/main/java/de/ozgcloud/fachstelle/SecurityConfiguration.java +++ b/fachstelle-server/src/main/java/de/ozgcloud/fachstelle/SecurityConfiguration.java @@ -1,7 +1,11 @@ package de.ozgcloud.fachstelle; -import java.util.List; - +import de.ozgcloud.fachstelle.security.FachstelleLogoutSuccessHandler; +import de.ozgcloud.fachstelle.security.InMemoryUserDetailService; +import de.ozgcloud.fachstelle.security.SecurityProvider; +import de.ozgcloud.fachstelle.security.UrlAuthenticationSuccessHandler; +import lombok.RequiredArgsConstructor; +import lombok.extern.log4j.Log4j2; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; @@ -10,6 +14,7 @@ import org.springframework.security.authentication.AuthenticationTrustResolverIm import org.springframework.security.config.Customizer; 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.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer; import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrationRepository; import org.springframework.security.saml2.provider.service.web.DefaultRelyingPartyRegistrationResolver; import org.springframework.security.saml2.provider.service.web.authentication.OpenSaml4AuthenticationRequestResolver; @@ -19,12 +24,7 @@ import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.filter.CorsFilter; -import de.ozgcloud.fachstelle.security.FachstelleLogoutSuccessHandler; -import de.ozgcloud.fachstelle.security.InMemoryUserDetailService; -import de.ozgcloud.fachstelle.security.SecurityProvider; -import de.ozgcloud.fachstelle.security.UrlAuthenticationSuccessHandler; -import lombok.RequiredArgsConstructor; -import lombok.extern.log4j.Log4j2; +import java.util.List; @Configuration @Log4j2 @@ -32,66 +32,71 @@ import lombok.extern.log4j.Log4j2; @RequiredArgsConstructor public class SecurityConfiguration { - private final InMemoryUserDetailService userDetailsService; - private final UrlAuthenticationSuccessHandler urlAuthenticationSuccessHandler; - private final FachstellenProperties properties; - - @Bean - public SecurityProvider securityProvider() { - return new SecurityProvider(); - } - - @Bean - public AuthenticationTrustResolver authenticationTrustResolver() { - return new AuthenticationTrustResolverImpl(); - } - - @Bean - public Saml2AuthenticationRequestResolver authenticationRequestResolver(RelyingPartyRegistrationRepository registrations) { - var registrationResolver = new DefaultRelyingPartyRegistrationResolver(registrations); - var authenticationRequestResolver = new OpenSaml4AuthenticationRequestResolver(registrationResolver); - authenticationRequestResolver.setAuthnRequestCustomizer(context -> context.getAuthnRequest().setForceAuthn(true)); - - return authenticationRequestResolver; - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - http - .authorizeHttpRequests(authorize -> authorize - .requestMatchers("/*", "/index**", "/success", "/actuator/**", "/error", "/favicon.ico", "/fonts/**", "/webjars/**", "/api/*", "/api", - "/api/environment") - .permitAll() - .requestMatchers("/preregister", "/register").authenticated() - .anyRequest().denyAll()); - - http.saml2Login(samlLogin -> samlLogin.successHandler(urlAuthenticationSuccessHandler)) - .saml2Logout(Customizer.withDefaults()) - .logout(logoutConfigurer -> logoutConfigurer.logoutSuccessHandler(getLogoutSuccessHandler())); - - return http.build(); - } - - FachstelleLogoutSuccessHandler getLogoutSuccessHandler() { - var handler = new FachstelleLogoutSuccessHandler(userDetailsService); - handler.setDefaultTargetUrl(properties.getLogoutSuccessUrl()); - - return handler; - } - - @Bean - public CorsFilter corsFilter() { - var source = new UrlBasedCorsConfigurationSource(); - var config = new CorsConfiguration(); - config.setAllowCredentials(false); - config.setAllowedOrigins(List.of(properties.getCors())); - config.setAllowedMethods(List.of("POST", "OPTIONS", "GET", "HEAD")); - config.setAllowedHeaders( - List.of(HttpHeaders.ORIGIN, HttpHeaders.CONTENT_TYPE, HttpHeaders.ACCEPT, HttpHeaders.AUTHORIZATION, "X-Requested-With", "X-Client")); - config.setExposedHeaders(List.of(HttpHeaders.LOCATION, HttpHeaders.CONTENT_DISPOSITION)); - source.registerCorsConfiguration("/**", config); - - return new CorsFilter(source); - } - + private final InMemoryUserDetailService userDetailsService; + private final UrlAuthenticationSuccessHandler urlAuthenticationSuccessHandler; + private final FachstellenProperties properties; + private final SpringJwtProperties springJwtProperties; + + @Bean + public SecurityProvider securityProvider() { + return new SecurityProvider(); + } + + @Bean + public AuthenticationTrustResolver authenticationTrustResolver() { + return new AuthenticationTrustResolverImpl(); + } + + @Bean + public Saml2AuthenticationRequestResolver authenticationRequestResolver(RelyingPartyRegistrationRepository registrations) { + var registrationResolver = new DefaultRelyingPartyRegistrationResolver(registrations); + var authenticationRequestResolver = new OpenSaml4AuthenticationRequestResolver(registrationResolver); + authenticationRequestResolver.setAuthnRequestCustomizer(context -> context.getAuthnRequest().setForceAuthn(true)); + + return authenticationRequestResolver; + } + + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + http + .authorizeHttpRequests(authorize -> authorize + .requestMatchers("/*", "/index**", "/success", "/actuator/**", "/error", "/favicon.ico", "/fonts/**", "/webjars/**", + "/api/environment") + .permitAll() + .requestMatchers("/api", "/api/**", "/preregister", "/register").authenticated() + .anyRequest().denyAll()); + + http.oauth2ResourceServer(this::setOAuth2ResourceServer); + http.saml2Login(samlLogin -> samlLogin.successHandler(urlAuthenticationSuccessHandler)) + .saml2Logout(Customizer.withDefaults()) + .logout(logoutConfigurer -> logoutConfigurer.logoutSuccessHandler(getLogoutSuccessHandler())); + + return http.build(); + } + + private void setOAuth2ResourceServer(OAuth2ResourceServerConfigurer<HttpSecurity> configurer) { + configurer.jwt().jwkSetUri(springJwtProperties.getJwkSetUri()); + } + + FachstelleLogoutSuccessHandler getLogoutSuccessHandler() { + var handler = new FachstelleLogoutSuccessHandler(userDetailsService); + handler.setDefaultTargetUrl(properties.getLogoutSuccessUrl()); + + return handler; + } + + @Bean + public CorsFilter corsFilter() { + var source = new UrlBasedCorsConfigurationSource(); + var config = new CorsConfiguration(); + config.setAllowCredentials(false); + config.setAllowedOrigins(List.of(properties.getCors())); + config.setAllowedMethods(List.of("POST", "OPTIONS", "GET", "HEAD")); + config.setAllowedHeaders( + List.of(HttpHeaders.ORIGIN, HttpHeaders.CONTENT_TYPE, HttpHeaders.ACCEPT, HttpHeaders.AUTHORIZATION, "X-Requested-With", "X-Client")); + config.setExposedHeaders(List.of(HttpHeaders.LOCATION, HttpHeaders.CONTENT_DISPOSITION)); + source.registerCorsConfiguration("/**", config); + + return new CorsFilter(source); + } } diff --git a/fachstelle-server/src/main/java/de/ozgcloud/fachstelle/SpringJwtProperties.java b/fachstelle-server/src/main/java/de/ozgcloud/fachstelle/SpringJwtProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..c98d83d1f49472eabcf57e3f57085cac709c2a30 --- /dev/null +++ b/fachstelle-server/src/main/java/de/ozgcloud/fachstelle/SpringJwtProperties.java @@ -0,0 +1,20 @@ +package de.ozgcloud.fachstelle; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Setter +@Getter +@Configuration +@ConfigurationProperties(prefix = SpringJwtProperties.PREFIX) +public class SpringJwtProperties { + + static final String PREFIX = "spring.security.oauth2.resourceserver.jwt"; + + /** + * Jwt jwk set uri + */ + private String jwkSetUri = null; +} \ No newline at end of file diff --git a/fachstelle-server/src/main/resources/application.yml b/fachstelle-server/src/main/resources/application.yml index 215712d6a66aa7dedaced163341a5dcabe7f94ad..cd51a56b216d7f81a113ffb49cd38b60943a6490 100644 --- a/fachstelle-server/src/main/resources/application.yml +++ b/fachstelle-server/src/main/resources/application.yml @@ -27,6 +27,11 @@ spring: application: name: Fachstellenbeteiligung security: + oauth2: + resourceserver: + jwt: + issuer-uri: ${ozgcloud.oauth2.issuer-uri} + jwk-set-uri: ${spring.security.oauth2.resourceserver.jwt.issuer-uri}/protocol/openid-connect/certs saml2: relyingparty: registration: @@ -49,5 +54,6 @@ ozgcloud: auth-server-url: ${keycloak.auth-server-url} realm: ${keycloak.realm} resource: ${keycloak.resource} + issuer-uri: ${ozgcloud.oauth2.auth-server-url}/realms/${ozgcloud.oauth2.realm} fachstellen-proxy: collaboration-manager-address-header: X-Grpc-Address \ No newline at end of file diff --git a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/SecurityConfigurationTest.java b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/SecurityConfigurationTest.java index c20148a1432ee96a5a788f8ed42cf074111c1b22..7d79a964a2636d45245a2b7d46355b6d62b81269 100644 --- a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/SecurityConfigurationTest.java +++ b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/SecurityConfigurationTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.security.config.annotation.web.builders.HttpSecurity; @@ -20,20 +21,19 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) class SecurityConfigurationTest { + @InjectMocks + private SecurityConfiguration securityConfiguration; + @Mock - InMemoryUserDetailService userDetailsService; + private InMemoryUserDetailService userDetailsService; @Mock - UrlAuthenticationSuccessHandler urlAuthenticationSuccessHandler; + private UrlAuthenticationSuccessHandler urlAuthenticationSuccessHandler; @Mock - FachstellenProperties fachstellenProperties; - - private SecurityConfiguration securityConfiguration; + private FachstellenProperties fachstellenProperties; + @Mock + private SpringJwtProperties springJwtProperties; - @BeforeEach - void setUp() { - securityConfiguration = new SecurityConfiguration(userDetailsService, urlAuthenticationSuccessHandler, fachstellenProperties); - } @Test void shouldCreateSecurityProvider() { diff --git a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/attachment/AttachmentControllerITCase.java b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/attachment/AttachmentControllerITCase.java index 63602fd0c626d973db89e63a4038eb6ff854a0bf..cdb9b1c342d01e9b6808b4d15915340baaaf96fb 100644 --- a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/attachment/AttachmentControllerITCase.java +++ b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/attachment/AttachmentControllerITCase.java @@ -24,77 +24,79 @@ import lombok.SneakyThrows; @SpringBootTest @AutoConfigureMockMvc(addFilters = false, printOnlyOnFailure = false) @TestPropertySource(properties = { - "ozgcloud.fachstelle.logout-success-url=http://logout", - "ozgcloud.fachstelle.login-redirect-url=http://login", - "ozgcloud.fachstelle.cors=http://login;http://saml-idp", - "ozgcloud.fachstellen-proxy.base-url=http://proxy", - "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" + "ozgcloud.fachstelle.logout-success-url=http://logout", + "ozgcloud.fachstelle.login-redirect-url=http://login", + "ozgcloud.fachstelle.cors=http://login;http://saml-idp", + "ozgcloud.fachstellen-proxy.base-url=http://proxy", + "keycloak.auth-server-url=http://keycloak", + "keycloak.realm=fachstelle", + "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" }) class AttachmentControllerITCase { - @Autowired - private MockMvc mockMvc; - - @SneakyThrows - @Test - void shouldReturnStatusOk() { - performRequest().andExpect(status().isOk()); - } - - @SneakyThrows - @Test - void shouldHaveContent() { - performRequest().andExpect(jsonPath("$._embedded").exists()); - } - - @SneakyThrows - @Test - void shouldHaveLinks() { - performRequest().andExpect(jsonPath("$._links").exists()); - } - - @SneakyThrows - @Test - void shouldHaveAttachmentList() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList").exists()); - } - - @SneakyThrows - @Test - void shouldHaveId() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].id.value").value(EingangTestFactory.ID)); - } - - @SneakyThrows - @Test - void shouldHaveName() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].name").value("TestFileName")); - } - - @SneakyThrows - @Test - void shouldHaveSize() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].size").value(1024)); - } - - @SneakyThrows - @Test - void shouldHaveContentType() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].contentType").value("text/plain")); - } - - @SneakyThrows - private ResultActions performRequest() { - return mockMvc.perform( - get(AttachmentController.PATH + "?eingangId=" + EingangTestFactory.ID) - .contentType(MediaType.APPLICATION_JSON).characterEncoding(Charset.defaultCharset()) - .with(csrf().asHeader())); - } + @Autowired + private MockMvc mockMvc; + + @SneakyThrows + @Test + void shouldReturnStatusOk() { + performRequest().andExpect(status().isOk()); + } + + @SneakyThrows + @Test + void shouldHaveContent() { + performRequest().andExpect(jsonPath("$._embedded").exists()); + } + + @SneakyThrows + @Test + void shouldHaveLinks() { + performRequest().andExpect(jsonPath("$._links").exists()); + } + + @SneakyThrows + @Test + void shouldHaveAttachmentList() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList").exists()); + } + + @SneakyThrows + @Test + void shouldHaveId() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].id.value").value(EingangTestFactory.ID)); + } + + @SneakyThrows + @Test + void shouldHaveName() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].name").value("TestFileName")); + } + + @SneakyThrows + @Test + void shouldHaveSize() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].size").value(1024)); + } + + @SneakyThrows + @Test + void shouldHaveContentType() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].contentType").value("text/plain")); + } + + @SneakyThrows + private ResultActions performRequest() { + return mockMvc.perform( + get(AttachmentController.PATH + "?eingangId=" + EingangTestFactory.ID) + .contentType(MediaType.APPLICATION_JSON).characterEncoding(Charset.defaultCharset()) + .with(csrf().asHeader())); + } } diff --git a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/command/CommandControllerITCase.java b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/command/CommandControllerITCase.java index b39d9950570b6833beb64eaec3d3ae0c91664d48..0e797a090cd750a12f91672228280fb3b33eac75 100644 --- a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/command/CommandControllerITCase.java +++ b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/command/CommandControllerITCase.java @@ -23,81 +23,83 @@ import lombok.SneakyThrows; @SpringBootTest @AutoConfigureMockMvc(addFilters = false, printOnlyOnFailure = false) @TestPropertySource(properties = { - "ozgcloud.fachstelle.logout-success-url=http://logout", - "ozgcloud.fachstelle.login-redirect-url=http://login", - "ozgcloud.fachstelle.cors=http://login;http://saml-idp", - "ozgcloud.fachstellen-proxy.base-url=http://proxy", - "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" + "ozgcloud.fachstelle.logout-success-url=http://logout", + "ozgcloud.fachstelle.login-redirect-url=http://login", + "ozgcloud.fachstelle.cors=http://login;http://saml-idp", + "ozgcloud.fachstellen-proxy.base-url=http://proxy", + "keycloak.auth-server-url=http://keycloak", + "keycloak.realm=fachstelle", + "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" }) class CommandControllerITCase { - @Autowired - private MockMvc mockMvc; - - @SneakyThrows - @Test - void shouldReturnStatusOk() { - performRequest().andExpect(status().isOk()); - } - - @SneakyThrows - @Test - void shouldHaveId() { - performRequest().andExpect(jsonPath("$.id").value(CommandTestFactory.ID)); - } - - @SneakyThrows - @Test - void shouldHaveCreatedAt() { - performRequest().andExpect(jsonPath("$.createdAt").exists()); - } - - @SneakyThrows - @Test - void shouldHaveFinishedAt() { - performRequest().andExpect(jsonPath("$.finishedAt").exists()); - } - - @SneakyThrows - @Test - void shouldHaveStatus() { - performRequest().andExpect(jsonPath("$.status").value(CommandStatus.FINISHED.toString())); - } - - @SneakyThrows - @Test - void shouldHaveVorgangId() { - performRequest().andExpect(jsonPath("$.vorgangId").value("TestVorgangId")); - } - - @SneakyThrows - @Test - void shouldHaveOrder() { - performRequest().andExpect(jsonPath("$.order").value("TestOrder")); - } - - @SneakyThrows - @Test - void shouldHaveErrorMessage() { - performRequest().andExpect(jsonPath("$.errorMessage").value("")); - } - - @SneakyThrows - @Test - void shouldHaveLinks() { - performRequest().andExpect(jsonPath("$._links").exists()); - } - - @SneakyThrows - private ResultActions performRequest() { - return mockMvc.perform(get(CommandController.PATH + "/" + CommandTestFactory.ID).contentType(MediaType.APPLICATION_JSON) - .characterEncoding(Charset.defaultCharset()).with(csrf().asHeader())); - } + @Autowired + private MockMvc mockMvc; + + @SneakyThrows + @Test + void shouldReturnStatusOk() { + performRequest().andExpect(status().isOk()); + } + + @SneakyThrows + @Test + void shouldHaveId() { + performRequest().andExpect(jsonPath("$.id").value(CommandTestFactory.ID)); + } + + @SneakyThrows + @Test + void shouldHaveCreatedAt() { + performRequest().andExpect(jsonPath("$.createdAt").exists()); + } + + @SneakyThrows + @Test + void shouldHaveFinishedAt() { + performRequest().andExpect(jsonPath("$.finishedAt").exists()); + } + + @SneakyThrows + @Test + void shouldHaveStatus() { + performRequest().andExpect(jsonPath("$.status").value(CommandStatus.FINISHED.toString())); + } + + @SneakyThrows + @Test + void shouldHaveVorgangId() { + performRequest().andExpect(jsonPath("$.vorgangId").value("TestVorgangId")); + } + + @SneakyThrows + @Test + void shouldHaveOrder() { + performRequest().andExpect(jsonPath("$.order").value("TestOrder")); + } + + @SneakyThrows + @Test + void shouldHaveErrorMessage() { + performRequest().andExpect(jsonPath("$.errorMessage").value("")); + } + + @SneakyThrows + @Test + void shouldHaveLinks() { + performRequest().andExpect(jsonPath("$._links").exists()); + } + + @SneakyThrows + private ResultActions performRequest() { + return mockMvc.perform(get(CommandController.PATH + "/" + CommandTestFactory.ID).contentType(MediaType.APPLICATION_JSON) + .characterEncoding(Charset.defaultCharset()).with(csrf().asHeader())); + } } \ No newline at end of file diff --git a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/historie/HistorieControllerITCase.java b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/historie/HistorieControllerITCase.java index bbfada877f8832a1146875a9bb0f6a63d7fb0a3a..29012bb7b50fe33c440689e1220dd033e704be4b 100644 --- a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/historie/HistorieControllerITCase.java +++ b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/historie/HistorieControllerITCase.java @@ -25,95 +25,97 @@ import lombok.SneakyThrows; @SpringBootTest @AutoConfigureMockMvc(addFilters = false, printOnlyOnFailure = false) @TestPropertySource(properties = { - "ozgcloud.fachstelle.logout-success-url=http://logout", - "ozgcloud.fachstelle.login-redirect-url=http://login", - "ozgcloud.fachstelle.cors=http://login;http://saml-idp", - "ozgcloud.fachstellen-proxy.base-url=http://proxy", - "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" + "ozgcloud.fachstelle.logout-success-url=http://logout", + "ozgcloud.fachstelle.login-redirect-url=http://login", + "ozgcloud.fachstelle.cors=http://login;http://saml-idp", + "ozgcloud.fachstellen-proxy.base-url=http://proxy", + "keycloak.auth-server-url=http://keycloak", + "keycloak.realm=fachstelle", + "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" }) class HistorieControllerITCase { - @Autowired - private MockMvc mockMvc; - - @SneakyThrows - @Test - void shouldReturnStatusOk() { - performRequest().andExpect(status().isOk()); - } - - @SneakyThrows - @Test - void shouldHaveContent() { - performRequest().andExpect(jsonPath("$._embedded").exists()); - } - - @SneakyThrows - @Test - void shouldHaveLinks() { - performRequest().andExpect(jsonPath("$._links").exists()); - } - - @SneakyThrows - @Test - void shouldHaveCommandList() { - performRequest().andExpect(jsonPath("$._embedded.commandList").exists()); - } - - @SneakyThrows - @Test - void shouldHaveId() { - performRequest().andExpect(jsonPath("$._embedded.commandList[0].id").value("TestCommandId")); - } - - @SneakyThrows - @Test - void shouldHaveCreatedAt() { - performRequest().andExpect(jsonPath("$._embedded.commandList[0].createdAt").exists()); - } - - @SneakyThrows - @Test - void shouldHaveFinishedAt() { - performRequest().andExpect(jsonPath("$._embedded.commandList[0].finishedAt").exists()); - } - - @SneakyThrows - @Test - void shouldHaveStatus() { - performRequest().andExpect(jsonPath("$._embedded.commandList[0].status").value(CommandStatus.FINISHED.toString())); - } - - @SneakyThrows - @Test - void shouldHaveVorgangId() { - performRequest().andExpect(jsonPath("$._embedded.commandList[0].vorgangId").value(VorgangTestFactory.ID)); - } - - @SneakyThrows - @Test - void shouldHaveOrder() { - performRequest().andExpect(jsonPath("$._embedded.commandList[0].order").value("TestOrder")); - } - - @SneakyThrows - @Test - void shouldHaveErrorMessage() { - performRequest().andExpect(jsonPath("$._embedded.commandList[0].errorMessage").value("")); - } - - @SneakyThrows - private ResultActions performRequest() { - return mockMvc.perform( - get(HistorieController.PATH + "?vorgangId=" + VorgangTestFactory.ID) - .contentType(MediaType.APPLICATION_JSON).characterEncoding(Charset.defaultCharset()) - .with(csrf().asHeader())); - } + @Autowired + private MockMvc mockMvc; + + @SneakyThrows + @Test + void shouldReturnStatusOk() { + performRequest().andExpect(status().isOk()); + } + + @SneakyThrows + @Test + void shouldHaveContent() { + performRequest().andExpect(jsonPath("$._embedded").exists()); + } + + @SneakyThrows + @Test + void shouldHaveLinks() { + performRequest().andExpect(jsonPath("$._links").exists()); + } + + @SneakyThrows + @Test + void shouldHaveCommandList() { + performRequest().andExpect(jsonPath("$._embedded.commandList").exists()); + } + + @SneakyThrows + @Test + void shouldHaveId() { + performRequest().andExpect(jsonPath("$._embedded.commandList[0].id").value("TestCommandId")); + } + + @SneakyThrows + @Test + void shouldHaveCreatedAt() { + performRequest().andExpect(jsonPath("$._embedded.commandList[0].createdAt").exists()); + } + + @SneakyThrows + @Test + void shouldHaveFinishedAt() { + performRequest().andExpect(jsonPath("$._embedded.commandList[0].finishedAt").exists()); + } + + @SneakyThrows + @Test + void shouldHaveStatus() { + performRequest().andExpect(jsonPath("$._embedded.commandList[0].status").value(CommandStatus.FINISHED.toString())); + } + + @SneakyThrows + @Test + void shouldHaveVorgangId() { + performRequest().andExpect(jsonPath("$._embedded.commandList[0].vorgangId").value(VorgangTestFactory.ID)); + } + + @SneakyThrows + @Test + void shouldHaveOrder() { + performRequest().andExpect(jsonPath("$._embedded.commandList[0].order").value("TestOrder")); + } + + @SneakyThrows + @Test + void shouldHaveErrorMessage() { + performRequest().andExpect(jsonPath("$._embedded.commandList[0].errorMessage").value("")); + } + + @SneakyThrows + private ResultActions performRequest() { + return mockMvc.perform( + get(HistorieController.PATH + "?vorgangId=" + VorgangTestFactory.ID) + .contentType(MediaType.APPLICATION_JSON).characterEncoding(Charset.defaultCharset()) + .with(csrf().asHeader())); + } } diff --git a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/kommentar/KommentarByVorgangControllerITCase.java b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/kommentar/KommentarByVorgangControllerITCase.java index d516488d62182053cea0b1d374f9eee43e58a2cb..de9f735a4ada7c12ef01c5fb1ad83ee368118f2c 100644 --- a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/kommentar/KommentarByVorgangControllerITCase.java +++ b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/kommentar/KommentarByVorgangControllerITCase.java @@ -24,95 +24,97 @@ import lombok.SneakyThrows; @SpringBootTest @AutoConfigureMockMvc(addFilters = false, printOnlyOnFailure = false) @TestPropertySource(properties = { - "ozgcloud.fachstelle.logout-success-url=http://logout", - "ozgcloud.fachstelle.login-redirect-url=http://login", - "ozgcloud.fachstelle.cors=http://login;http://saml-idp", - "ozgcloud.fachstellen-proxy.base-url=http://proxy", - "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" + "ozgcloud.fachstelle.logout-success-url=http://logout", + "ozgcloud.fachstelle.login-redirect-url=http://login", + "ozgcloud.fachstelle.cors=http://login;http://saml-idp", + "ozgcloud.fachstellen-proxy.base-url=http://proxy", + "keycloak.auth-server-url=http://keycloak", + "keycloak.realm=fachstelle", + "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" }) class KommentarByVorgangControllerITCase { - @Autowired - private MockMvc mockMvc; - - @SneakyThrows - @Test - void shouldReturnStatusOk() { - performRequest().andExpect(status().isOk()); - } - - @SneakyThrows - @Test - void shouldHaveContent() { - performRequest().andExpect(jsonPath("$._embedded").exists()); - } - - @SneakyThrows - @Test - void shouldHaveLinks() { - performRequest().andExpect(jsonPath("$._links").exists()); - } - - @SneakyThrows - @Test - void shouldHaveKommentarList() { - performRequest().andExpect(jsonPath("$._embedded.kommentarList").exists()); - } - - @SneakyThrows - @Test - void shouldHaveId() { - performRequest().andExpect(jsonPath("$._embedded.kommentarList[0].id").value("TestKommentarId")); - } - - @SneakyThrows - @Test - void shouldHaveVersion() { - performRequest().andExpect(jsonPath("$._embedded.kommentarList[0].version").value(1)); - } - - @SneakyThrows - @Test - void shouldHaveVorgangId() { - performRequest().andExpect(jsonPath("$._embedded.kommentarList[0].vorgangId").value(VorgangTestFactory.ID)); - } - - @SneakyThrows - @Test - void shouldHaveCreatedAt() { - performRequest().andExpect(jsonPath("$._embedded.kommentarList[0].createdAt").exists()); - } - - @SneakyThrows - @Test - void shouldHaveCreatedBy() { - performRequest().andExpect(jsonPath("$._embedded.kommentarList[0].createdBy").value("TestName")); - } - - @SneakyThrows - @Test - void shouldHaveText() { - performRequest().andExpect(jsonPath("$._embedded.kommentarList[0].text").value("TestText")); - } - - @SneakyThrows - @Test - void shouldHaveAttachments() { - performRequest().andExpect(jsonPath("$._embedded.kommentarList[0].attachments").exists()); - } - - @SneakyThrows - private ResultActions performRequest() { - return mockMvc.perform( - get(KommentarController.KommentarByVorgangController.PATH + "/" + VorgangTestFactory.ID + "/kommentars") - .contentType(MediaType.APPLICATION_JSON).characterEncoding(Charset.defaultCharset()) - .with(csrf().asHeader())); - } + @Autowired + private MockMvc mockMvc; + + @SneakyThrows + @Test + void shouldReturnStatusOk() { + performRequest().andExpect(status().isOk()); + } + + @SneakyThrows + @Test + void shouldHaveContent() { + performRequest().andExpect(jsonPath("$._embedded").exists()); + } + + @SneakyThrows + @Test + void shouldHaveLinks() { + performRequest().andExpect(jsonPath("$._links").exists()); + } + + @SneakyThrows + @Test + void shouldHaveKommentarList() { + performRequest().andExpect(jsonPath("$._embedded.kommentarList").exists()); + } + + @SneakyThrows + @Test + void shouldHaveId() { + performRequest().andExpect(jsonPath("$._embedded.kommentarList[0].id").value("TestKommentarId")); + } + + @SneakyThrows + @Test + void shouldHaveVersion() { + performRequest().andExpect(jsonPath("$._embedded.kommentarList[0].version").value(1)); + } + + @SneakyThrows + @Test + void shouldHaveVorgangId() { + performRequest().andExpect(jsonPath("$._embedded.kommentarList[0].vorgangId").value(VorgangTestFactory.ID)); + } + + @SneakyThrows + @Test + void shouldHaveCreatedAt() { + performRequest().andExpect(jsonPath("$._embedded.kommentarList[0].createdAt").exists()); + } + + @SneakyThrows + @Test + void shouldHaveCreatedBy() { + performRequest().andExpect(jsonPath("$._embedded.kommentarList[0].createdBy").value("TestName")); + } + + @SneakyThrows + @Test + void shouldHaveText() { + performRequest().andExpect(jsonPath("$._embedded.kommentarList[0].text").value("TestText")); + } + + @SneakyThrows + @Test + void shouldHaveAttachments() { + performRequest().andExpect(jsonPath("$._embedded.kommentarList[0].attachments").exists()); + } + + @SneakyThrows + private ResultActions performRequest() { + return mockMvc.perform( + get(KommentarController.KommentarByVorgangController.PATH + "/" + VorgangTestFactory.ID + "/kommentars") + .contentType(MediaType.APPLICATION_JSON).characterEncoding(Charset.defaultCharset()) + .with(csrf().asHeader())); + } } diff --git a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/kommentar/KommentarControllerITCase.java b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/kommentar/KommentarControllerITCase.java index 2e31b46dbedf0da9eb932331a4ee16fabc520d3a..cda969dc02fa2bf7f9dc7a498ec7d5ef9dc86848 100644 --- a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/kommentar/KommentarControllerITCase.java +++ b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/kommentar/KommentarControllerITCase.java @@ -24,149 +24,151 @@ import lombok.SneakyThrows; @SpringBootTest @AutoConfigureMockMvc(addFilters = false, printOnlyOnFailure = false) @TestPropertySource(properties = { - "ozgcloud.fachstelle.logout-success-url=http://logout", - "ozgcloud.fachstelle.login-redirect-url=http://login", - "ozgcloud.fachstelle.cors=http://login;http://saml-idp", - "ozgcloud.fachstellen-proxy.base-url=http://proxy", - "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" + "ozgcloud.fachstelle.logout-success-url=http://logout", + "ozgcloud.fachstelle.login-redirect-url=http://login", + "ozgcloud.fachstelle.cors=http://login;http://saml-idp", + "ozgcloud.fachstellen-proxy.base-url=http://proxy", + "keycloak.auth-server-url=http://keycloak", + "keycloak.realm=fachstelle", + "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" }) class KommentarControllerITCase { - @Autowired - private MockMvc mockMvc; - - @Nested - class TestGetById { - - @SneakyThrows - @Test - void shouldReturnStatusOk() { - performRequest().andExpect(status().isOk()); - } - - @SneakyThrows - @Test - void shouldHaveId() { - performRequest().andExpect(jsonPath("$.id").value(KommentarTestFactory.ID)); - } - - @SneakyThrows - @Test - void shouldHaveVersion() { - performRequest().andExpect(jsonPath("$.version").value(1)); - } - - @SneakyThrows - @Test - void shouldHaveVorgangId() { - performRequest().andExpect(jsonPath("$.vorgangId").value("TestVorgangId")); - } - - @SneakyThrows - @Test - void shouldHaveCreatedAt() { - performRequest().andExpect(jsonPath("$.createdAt").exists()); - } - - @SneakyThrows - @Test - void shouldHaveCreatedBy() { - performRequest().andExpect(jsonPath("$.createdBy").value("TestName")); - } - - @SneakyThrows - @Test - void shouldHaveText() { - performRequest().andExpect(jsonPath("$.text").value("TestText")); - } - - @SneakyThrows - @Test - void shouldHaveAttachments() { - performRequest().andExpect(jsonPath("$.attachments").exists()); - } - - @SneakyThrows - @Test - void shouldHaveLinks() { - performRequest().andExpect(jsonPath("$._links").exists()); - } - - @SneakyThrows - private ResultActions performRequest() { - return mockMvc.perform( - get(KommentarController.PATH + "/" + KommentarTestFactory.ID) - .contentType(MediaType.APPLICATION_JSON).characterEncoding(Charset.defaultCharset()) - .with(csrf().asHeader())); - } - - } - - @Nested - class TestGetAttachments { - - @SneakyThrows - @Test - void shouldReturnStatusOk() { - performRequest().andExpect(status().isOk()); - } - - @SneakyThrows - @Test - void shouldHaveContent() { - performRequest().andExpect(jsonPath("$._embedded").exists()); - } - - @SneakyThrows - @Test - void shouldHaveLinks() { - performRequest().andExpect(jsonPath("$._links").exists()); - } - - @SneakyThrows - @Test - void shouldHaveCommandList() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList").exists()); - } - - @SneakyThrows - @Test - void shouldHaveId() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].id.value").value(KommentarTestFactory.ID)); - } - - @SneakyThrows - @Test - void shouldHaveName() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].name").value("TestFileName")); - } - - @SneakyThrows - @Test - void shouldHaveSize() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].size").value(1024)); - } - - @SneakyThrows - @Test - void shouldHaveContentType() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].contentType").value("text/plain")); - } - - @SneakyThrows - private ResultActions performRequest() { - return mockMvc.perform( - get(KommentarController.PATH + "/" + KommentarTestFactory.ID + "/attachments") - .contentType(MediaType.APPLICATION_JSON).characterEncoding(Charset.defaultCharset()) - .with(csrf().asHeader())); - } - - } + @Autowired + private MockMvc mockMvc; + + @Nested + class TestGetById { + + @SneakyThrows + @Test + void shouldReturnStatusOk() { + performRequest().andExpect(status().isOk()); + } + + @SneakyThrows + @Test + void shouldHaveId() { + performRequest().andExpect(jsonPath("$.id").value(KommentarTestFactory.ID)); + } + + @SneakyThrows + @Test + void shouldHaveVersion() { + performRequest().andExpect(jsonPath("$.version").value(1)); + } + + @SneakyThrows + @Test + void shouldHaveVorgangId() { + performRequest().andExpect(jsonPath("$.vorgangId").value("TestVorgangId")); + } + + @SneakyThrows + @Test + void shouldHaveCreatedAt() { + performRequest().andExpect(jsonPath("$.createdAt").exists()); + } + + @SneakyThrows + @Test + void shouldHaveCreatedBy() { + performRequest().andExpect(jsonPath("$.createdBy").value("TestName")); + } + + @SneakyThrows + @Test + void shouldHaveText() { + performRequest().andExpect(jsonPath("$.text").value("TestText")); + } + + @SneakyThrows + @Test + void shouldHaveAttachments() { + performRequest().andExpect(jsonPath("$.attachments").exists()); + } + + @SneakyThrows + @Test + void shouldHaveLinks() { + performRequest().andExpect(jsonPath("$._links").exists()); + } + + @SneakyThrows + private ResultActions performRequest() { + return mockMvc.perform( + get(KommentarController.PATH + "/" + KommentarTestFactory.ID) + .contentType(MediaType.APPLICATION_JSON).characterEncoding(Charset.defaultCharset()) + .with(csrf().asHeader())); + } + + } + + @Nested + class TestGetAttachments { + + @SneakyThrows + @Test + void shouldReturnStatusOk() { + performRequest().andExpect(status().isOk()); + } + + @SneakyThrows + @Test + void shouldHaveContent() { + performRequest().andExpect(jsonPath("$._embedded").exists()); + } + + @SneakyThrows + @Test + void shouldHaveLinks() { + performRequest().andExpect(jsonPath("$._links").exists()); + } + + @SneakyThrows + @Test + void shouldHaveCommandList() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList").exists()); + } + + @SneakyThrows + @Test + void shouldHaveId() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].id.value").value(KommentarTestFactory.ID)); + } + + @SneakyThrows + @Test + void shouldHaveName() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].name").value("TestFileName")); + } + + @SneakyThrows + @Test + void shouldHaveSize() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].size").value(1024)); + } + + @SneakyThrows + @Test + void shouldHaveContentType() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].contentType").value("text/plain")); + } + + @SneakyThrows + private ResultActions performRequest() { + return mockMvc.perform( + get(KommentarController.PATH + "/" + KommentarTestFactory.ID + "/attachments") + .contentType(MediaType.APPLICATION_JSON).characterEncoding(Charset.defaultCharset()) + .with(csrf().asHeader())); + } + + } } diff --git a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/registration/FachstelleRegistrationControllerITCase.java b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/registration/FachstelleRegistrationControllerITCase.java index 3cd293ab06f04b862066660e80e7dfd2b6da04b6..c0f6281e6e632d48ed2bf7e7d4a809d1276e0240 100644 --- a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/registration/FachstelleRegistrationControllerITCase.java +++ b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/registration/FachstelleRegistrationControllerITCase.java @@ -17,29 +17,31 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; @SpringBootTest @AutoConfigureMockMvc(printOnlyOnFailure = false) @TestPropertySource(properties = { - "ozgcloud.fachstelle.logout-success-url=http://logout", - "ozgcloud.fachstelle.login-redirect-url=http://login", - "ozgcloud.fachstelle.cors=http://login;http://saml-idp", - "ozgcloud.fachstellen-proxy.base-url=http://proxy", - "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" + "ozgcloud.fachstelle.logout-success-url=http://logout", + "ozgcloud.fachstelle.login-redirect-url=http://login", + "ozgcloud.fachstelle.cors=http://login;http://saml-idp", + "ozgcloud.fachstellen-proxy.base-url=http://proxy", + "keycloak.auth-server-url=http://keycloak", + "keycloak.realm=fachstelle", + "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" }) class FachstelleRegistrationControllerITCase { - @Autowired - private MockMvc mockMvc; + @Autowired + private MockMvc mockMvc; - @Test - void whenCallIndexPage_ThenReturnPage() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.get("") - .header("Accept-Language", "de")) - .andExpect(status().isOk()) - .andExpect(content().string(containsString("Registrierung als Fachstelle"))); - } + @Test + void whenCallIndexPage_ThenReturnPage() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("") + .header("Accept-Language", "de")) + .andExpect(status().isOk()) + .andExpect(content().string(containsString("Registrierung als Fachstelle"))); + } } \ No newline at end of file diff --git a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/representation/RepresentationControllerITCase.java b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/representation/RepresentationControllerITCase.java index 340c92afee651bbb0e8d59de8f6000c78b2e1711..1213ccc0d4143077ecde7e950bc639f4a30fd4bf 100644 --- a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/representation/RepresentationControllerITCase.java +++ b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/representation/RepresentationControllerITCase.java @@ -24,77 +24,79 @@ import lombok.SneakyThrows; @SpringBootTest @AutoConfigureMockMvc(addFilters = false, printOnlyOnFailure = false) @TestPropertySource(properties = { - "ozgcloud.fachstelle.logout-success-url=http://logout", - "ozgcloud.fachstelle.login-redirect-url=http://login", - "ozgcloud.fachstelle.cors=http://login;http://saml-idp", - "ozgcloud.fachstellen-proxy.base-url=http://proxy", - "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" + "ozgcloud.fachstelle.logout-success-url=http://logout", + "ozgcloud.fachstelle.login-redirect-url=http://login", + "ozgcloud.fachstelle.cors=http://login;http://saml-idp", + "ozgcloud.fachstellen-proxy.base-url=http://proxy", + "keycloak.auth-server-url=http://keycloak", + "keycloak.realm=fachstelle", + "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" }) class RepresentationControllerITCase { - @Autowired - private MockMvc mockMvc; - - @SneakyThrows - @Test - void shouldReturnStatusOk() { - performRequest().andExpect(status().isOk()); - } - - @SneakyThrows - @Test - void shouldHaveContent() { - performRequest().andExpect(jsonPath("$._embedded").exists()); - } - - @SneakyThrows - @Test - void shouldHaveLinks() { - performRequest().andExpect(jsonPath("$._links").exists()); - } - - @SneakyThrows - @Test - void shouldHaveRepresentationList() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList").exists()); - } - - @SneakyThrows - @Test - void shouldHaveId() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].id.value").value(EingangTestFactory.ID)); - } - - @SneakyThrows - @Test - void shouldHaveName() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].name").value("TestFileName")); - } - - @SneakyThrows - @Test - void shouldHaveSize() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].size").value(1024)); - } - - @SneakyThrows - @Test - void shouldHaveContentType() { - performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].contentType").value("text/plain")); - } - - @SneakyThrows - private ResultActions performRequest() { - return mockMvc.perform( - get(RepresentationController.PATH + "?eingangId=" + EingangTestFactory.ID) - .contentType(MediaType.APPLICATION_JSON).characterEncoding(Charset.defaultCharset()) - .with(csrf().asHeader())); - } + @Autowired + private MockMvc mockMvc; + + @SneakyThrows + @Test + void shouldReturnStatusOk() { + performRequest().andExpect(status().isOk()); + } + + @SneakyThrows + @Test + void shouldHaveContent() { + performRequest().andExpect(jsonPath("$._embedded").exists()); + } + + @SneakyThrows + @Test + void shouldHaveLinks() { + performRequest().andExpect(jsonPath("$._links").exists()); + } + + @SneakyThrows + @Test + void shouldHaveRepresentationList() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList").exists()); + } + + @SneakyThrows + @Test + void shouldHaveId() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].id.value").value(EingangTestFactory.ID)); + } + + @SneakyThrows + @Test + void shouldHaveName() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].name").value("TestFileName")); + } + + @SneakyThrows + @Test + void shouldHaveSize() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].size").value(1024)); + } + + @SneakyThrows + @Test + void shouldHaveContentType() { + performRequest().andExpect(jsonPath("$._embedded.ozgFileList[0].contentType").value("text/plain")); + } + + @SneakyThrows + private ResultActions performRequest() { + return mockMvc.perform( + get(RepresentationController.PATH + "?eingangId=" + EingangTestFactory.ID) + .contentType(MediaType.APPLICATION_JSON).characterEncoding(Charset.defaultCharset()) + .with(csrf().asHeader())); + } } diff --git a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/resource/OzgcloudResourceControllerITCase.java b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/resource/OzgcloudResourceControllerITCase.java index 1f218f98b9154be117a6a57f6e22e32e4ebd142c..ea1b025b6cef5411c65443d693407c39d9ffd1df 100644 --- a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/resource/OzgcloudResourceControllerITCase.java +++ b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/resource/OzgcloudResourceControllerITCase.java @@ -28,87 +28,89 @@ import lombok.SneakyThrows; @SpringBootTest @AutoConfigureMockMvc(addFilters = false, printOnlyOnFailure = false) @TestPropertySource(properties = { - "ozgcloud.fachstelle.logout-success-url=http://logout", - "ozgcloud.fachstelle.login-redirect-url=http://login", - "ozgcloud.fachstelle.cors=http://login;http://saml-idp", - "ozgcloud.fachstellen-proxy.base-url=http://proxy", - "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" + "ozgcloud.fachstelle.logout-success-url=http://logout", + "ozgcloud.fachstelle.login-redirect-url=http://login", + "ozgcloud.fachstelle.cors=http://login;http://saml-idp", + "ozgcloud.fachstellen-proxy.base-url=http://proxy", + "keycloak.auth-server-url=http://keycloak", + "keycloak.realm=fachstelle", + "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" }) class OzgcloudResourceControllerITCase { - @Autowired - private MockMvc mockMvc; + @Autowired + private MockMvc mockMvc; - @Nested - class TestGetOzgcloudResource { + @Nested + class TestGetOzgcloudResource { - private static final String COLLABORATION_MANAGER_ADDRESS = VorgangWithCollaborationManagerAddressTestFactory.COLLABORATION_MANAGER_ADDRESS; - private static final String VORGANG_ID = VorgangTestFactory.ID; - private static final String VALID_URI = COLLABORATION_MANAGER_ADDRESS + "/vorgangs/" + VORGANG_ID; - private static final String INVALID_URI = COLLABORATION_MANAGER_ADDRESS + ":123/" + VORGANG_ID; + private static final String COLLABORATION_MANAGER_ADDRESS = VorgangWithCollaborationManagerAddressTestFactory.COLLABORATION_MANAGER_ADDRESS; + private static final String VORGANG_ID = VorgangTestFactory.ID; + private static final String VALID_URI = COLLABORATION_MANAGER_ADDRESS + "/vorgangs/" + VORGANG_ID; + private static final String INVALID_URI = COLLABORATION_MANAGER_ADDRESS + ":123/" + VORGANG_ID; - @Test - void shouldReturnStatusOk() throws Exception { - var response = doRequest(VALID_URI); + @Test + void shouldReturnStatusOk() throws Exception { + var response = doRequest(VALID_URI); - response.andExpect(status().isOk()); - } + response.andExpect(status().isOk()); + } - @Test - void shouldHaveVorgangLink() throws Exception { - var response = doRequest(VALID_URI); + @Test + void shouldHaveVorgangLink() throws Exception { + var response = doRequest(VALID_URI); - response.andExpect(jsonPath("$._links.vorgang.href").value(StringEndsWith.endsWith( - "/api/vorgangs/" + VORGANG_ID + "?" + PARAM_COLLABORATION_MANAGER_ADDRESS + "=" + COLLABORATION_MANAGER_ADDRESS))); - } + response.andExpect(jsonPath("$._links.vorgang.href").value(StringEndsWith.endsWith( + "/api/vorgangs/" + VORGANG_ID + "?" + PARAM_COLLABORATION_MANAGER_ADDRESS + "=" + COLLABORATION_MANAGER_ADDRESS))); + } - @Test - void shouldHaveSelfLink() throws Exception { - var encodedUri = URLEncoder.encode(VALID_URI, StandardCharsets.UTF_8); + @Test + void shouldHaveSelfLink() throws Exception { + var encodedUri = URLEncoder.encode(VALID_URI, StandardCharsets.UTF_8); - var response = doRequest(VALID_URI); + var response = doRequest(VALID_URI); - response.andExpect( - jsonPath("$._links.self.href").value(StringEndsWith.endsWith(OzgcloudResourceController.PATH + "?" + PARAM_URI + "=" + encodedUri))); - } + response.andExpect( + jsonPath("$._links.self.href").value(StringEndsWith.endsWith(OzgcloudResourceController.PATH + "?" + PARAM_URI + "=" + encodedUri))); + } - @Test - void shouldReturnStatusNotFound() throws Exception { - var response = doRequest(INVALID_URI); + @Test + void shouldReturnStatusNotFound() throws Exception { + var response = doRequest(INVALID_URI); - response.andExpect(status().isNotFound()); - } + response.andExpect(status().isNotFound()); + } - @Test - void shouldReturnBadRequestOnNoRequestParam() throws Exception { - var response = doRequestWithQueryString(""); + @Test + void shouldReturnBadRequestOnNoRequestParam() throws Exception { + var response = doRequestWithQueryString(""); - response.andExpect(status().isBadRequest()); - } + response.andExpect(status().isBadRequest()); + } - @Test - void shouldReturnBadRequestOnEmptyUri() throws Exception { - var response = doRequestWithQueryString("?" + PARAM_URI + "="); + @Test + void shouldReturnBadRequestOnEmptyUri() throws Exception { + var response = doRequestWithQueryString("?" + PARAM_URI + "="); - response.andExpect(status().isBadRequest()); - } + response.andExpect(status().isBadRequest()); + } - @SneakyThrows - private ResultActions doRequest(String uri) { - return doRequestWithQueryString("?" + PARAM_URI + "=" + uri); - } + @SneakyThrows + private ResultActions doRequest(String uri) { + return doRequestWithQueryString("?" + PARAM_URI + "=" + uri); + } - @SneakyThrows - private ResultActions doRequestWithQueryString(String queryString) { - return mockMvc.perform(get(OzgcloudResourceController.PATH + queryString)); - } + @SneakyThrows + private ResultActions doRequestWithQueryString(String queryString) { + return mockMvc.perform(get(OzgcloudResourceController.PATH + queryString)); + } - } + } } diff --git a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/vorgang/VorgangControllerITCase.java b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/vorgang/VorgangControllerITCase.java index 2cd55700dfdaa7fd7bec1d5c4751541b11810893..0f8278a12a6619e6f3009dc4782d5c7a0c97885f 100644 --- a/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/vorgang/VorgangControllerITCase.java +++ b/fachstelle-server/src/test/java/de/ozgcloud/fachstelle/vorgang/VorgangControllerITCase.java @@ -28,105 +28,107 @@ import lombok.SneakyThrows; @SpringBootTest @AutoConfigureMockMvc(addFilters = false, printOnlyOnFailure = false) @TestPropertySource(properties = { - "ozgcloud.fachstelle.logout-success-url=http://logout", - "ozgcloud.fachstelle.login-redirect-url=http://login", - "ozgcloud.fachstelle.cors=http://login;http://saml-idp", - "ozgcloud.fachstellen-proxy.base-url=http://proxy", - "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", - "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", - "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" + "ozgcloud.fachstelle.logout-success-url=http://logout", + "ozgcloud.fachstelle.login-redirect-url=http://login", + "ozgcloud.fachstelle.cors=http://login;http://saml-idp", + "ozgcloud.fachstellen-proxy.base-url=http://proxy", + "keycloak.auth-server-url=http://keycloak", + "keycloak.realm=fachstelle", + "spring.security.saml2.relyingparty.registration.muk.entity-id=http://mock-idp", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.signing.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].private-key-location=classpath:/mujina-test.key", + "spring.security.saml2.relyingparty.registration.muk.decryption.credentials[0].certificate-location=classpath:/mujina-test.crt", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.singlesignon.sign-request=false", + "spring.security.saml2.relyingparty.registration.muk.assertingparty.metadata-uri=classpath:/metadata.xml" }) class VorgangControllerITCase { - @Autowired - private MockMvc mockMvc; - - @MockBean - private VorgangRemoteService vorgangRemoteService; - - @Nested - class TestGetVorgang { - - private static final String COLLABORATION_MANAGER_ADDRESS = VorgangWithCollaborationManagerAddressTestFactory.COLLABORATION_MANAGER_ADDRESS; - - @BeforeEach - void init() { - when(vorgangRemoteService.findVorgang(VorgangTestFactory.ID, COLLABORATION_MANAGER_ADDRESS)).thenReturn(VorgangTestFactory.create()); - } - - @SneakyThrows - @Test - void shouldReturnStatusOk() { - performRequest().andExpect(status().isOk()); - } - - @SneakyThrows - @Test - void shouldHaveId() { - performRequest().andExpect(jsonPath("$.id").value(VorgangTestFactory.ID)); - } - - @SneakyThrows - @Test - void shouldHaveVersion() { - performRequest().andExpect(jsonPath("$.version").value(VorgangTestFactory.VERSION)); - } - - @SneakyThrows - @Test - void shouldHaveName() { - performRequest().andExpect(jsonPath("$.name").value(VorgangTestFactory.NAME)); - } - - @SneakyThrows - @Test - void shouldHaveNummer() { - performRequest().andExpect(jsonPath("$.nummer").value(VorgangTestFactory.NUMMER)); - } - - @SneakyThrows - @Test - void shouldHaveAktenzeichen() { - performRequest().andExpect(jsonPath("$.aktenzeichen").value(VorgangTestFactory.AKTENZEICHEN)); - } - - @SneakyThrows - @Test - void shouldHaveCreatedAt() { - performRequest().andExpect(jsonPath("$.createdAt").exists()); - } - - @SneakyThrows - @Test - void shouldHaveEingang() { - performRequest().andExpect(jsonPath("$.eingang").exists()); - } - - @SneakyThrows - @Test - void shouldHaveStatus() { - performRequest().andExpect(jsonPath("$.status").value(VorgangTestFactory.STATUS.toString())); - } - - @SneakyThrows - @Test - void shouldHaveLinks() { - performRequest().andExpect(jsonPath("$._links").exists()); - } - - @SneakyThrows - private ResultActions performRequest() { - return mockMvc.perform( - get(VorgangController.PATH + "/" + VorgangTestFactory.ID + "?" + PARAM_COLLABORATION_MANAGER_ADDRESS + "=" - + COLLABORATION_MANAGER_ADDRESS) - .contentType(MediaType.APPLICATION_JSON).characterEncoding(Charset.defaultCharset()) - .with(csrf().asHeader())); - } - - } + @Autowired + private MockMvc mockMvc; + + @MockBean + private VorgangRemoteService vorgangRemoteService; + + @Nested + class TestGetVorgang { + + private static final String COLLABORATION_MANAGER_ADDRESS = VorgangWithCollaborationManagerAddressTestFactory.COLLABORATION_MANAGER_ADDRESS; + + @BeforeEach + void init() { + when(vorgangRemoteService.findVorgang(VorgangTestFactory.ID, COLLABORATION_MANAGER_ADDRESS)).thenReturn(VorgangTestFactory.create()); + } + + @SneakyThrows + @Test + void shouldReturnStatusOk() { + performRequest().andExpect(status().isOk()); + } + + @SneakyThrows + @Test + void shouldHaveId() { + performRequest().andExpect(jsonPath("$.id").value(VorgangTestFactory.ID)); + } + + @SneakyThrows + @Test + void shouldHaveVersion() { + performRequest().andExpect(jsonPath("$.version").value(VorgangTestFactory.VERSION)); + } + + @SneakyThrows + @Test + void shouldHaveName() { + performRequest().andExpect(jsonPath("$.name").value(VorgangTestFactory.NAME)); + } + + @SneakyThrows + @Test + void shouldHaveNummer() { + performRequest().andExpect(jsonPath("$.nummer").value(VorgangTestFactory.NUMMER)); + } + + @SneakyThrows + @Test + void shouldHaveAktenzeichen() { + performRequest().andExpect(jsonPath("$.aktenzeichen").value(VorgangTestFactory.AKTENZEICHEN)); + } + + @SneakyThrows + @Test + void shouldHaveCreatedAt() { + performRequest().andExpect(jsonPath("$.createdAt").exists()); + } + + @SneakyThrows + @Test + void shouldHaveEingang() { + performRequest().andExpect(jsonPath("$.eingang").exists()); + } + + @SneakyThrows + @Test + void shouldHaveStatus() { + performRequest().andExpect(jsonPath("$.status").value(VorgangTestFactory.STATUS.toString())); + } + + @SneakyThrows + @Test + void shouldHaveLinks() { + performRequest().andExpect(jsonPath("$._links").exists()); + } + + @SneakyThrows + private ResultActions performRequest() { + return mockMvc.perform( + get(VorgangController.PATH + "/" + VorgangTestFactory.ID + "?" + PARAM_COLLABORATION_MANAGER_ADDRESS + "=" + + COLLABORATION_MANAGER_ADDRESS) + .contentType(MediaType.APPLICATION_JSON).characterEncoding(Charset.defaultCharset()) + .with(csrf().asHeader())); + } + + } } \ No newline at end of file