From 4fc19c5a7ae61bbaf3b162d1e35a67ddb5122a68 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Thu, 28 Nov 2024 18:00:09 +0100 Subject: [PATCH] OZG-7014 add oauth2 resource server for jwt auth Sub task: OZG-7225 --- fachstelle-server/pom.xml | 4 + .../fachstelle/SecurityConfiguration.java | 145 ++++----- .../fachstelle/SpringJwtProperties.java | 20 ++ .../src/main/resources/application.yml | 6 + .../fachstelle/SecurityConfigurationTest.java | 18 +- .../AttachmentControllerITCase.java | 140 ++++----- .../command/CommandControllerITCase.java | 148 ++++----- .../historie/HistorieControllerITCase.java | 176 +++++------ .../KommentarByVorgangControllerITCase.java | 176 +++++------ .../kommentar/KommentarControllerITCase.java | 284 +++++++++--------- ...achstelleRegistrationControllerITCase.java | 42 +-- .../RepresentationControllerITCase.java | 140 ++++----- .../OzgcloudResourceControllerITCase.java | 124 ++++---- .../vorgang/VorgangControllerITCase.java | 196 ++++++------ 14 files changed, 836 insertions(+), 783 deletions(-) create mode 100644 fachstelle-server/src/main/java/de/ozgcloud/fachstelle/SpringJwtProperties.java diff --git a/fachstelle-server/pom.xml b/fachstelle-server/pom.xml index 450e804..c62e396 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 c6edb3c..33419eb 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 0000000..c98d83d --- /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 215712d..cd51a56 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 c20148a..7d79a96 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 63602fd..cdb9b1c 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 b39d995..0e797a0 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 bbfada8..29012bb 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 d516488..de9f735 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 2e31b46..cda969d 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 3cd293a..c0f6281 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 340c92a..1213ccc 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 1f218f9..ea1b025 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 2cd5570..0f8278a 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 -- GitLab