Skip to content

Commit

Permalink
Feat(receiver): Add endpoint for callback
Browse files Browse the repository at this point in the history
  • Loading branch information
zechmeister committed Oct 17, 2024
1 parent 597f7cf commit 3485cc7
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public class SecurityConfig {

@Bean
public SecurityFilterChain springSecurityWebFilterChain(HttpSecurity http) throws Exception {
return http.csrf(csrf -> csrf.ignoringRequestMatchers("/api/sender/submit"))
return http.csrf(
csrf -> csrf.ignoringRequestMatchers("/api/sender/submit", "/callbacks/fit-connect"))
.authorizeHttpRequests(
requests ->
requests
Expand All @@ -23,6 +24,8 @@ public SecurityFilterChain springSecurityWebFilterChain(HttpSecurity http) throw
.permitAll()
.requestMatchers("/api/sender/**")
.permitAll()
.requestMatchers("/callbacks/fit-connect")
.permitAll()
.anyRequest()
.denyAll())
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package de.bund.digitalservice.a2j.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ReceiverController {

public ReceiverController() {}
;

@PostMapping("callbacks/fit-connect")
public void newSubmission() {
System.out.println("new Submission via callback!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package de.bund.digitalservice.a2j.integration;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.web.servlet.MockMvc;

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
@Tag("integration")
public class ReceiverIntegrationTest {
@Autowired private MockMvc mockMvc;

@Test
void shouldExposeSecurityTxt() throws Exception {
mockMvc.perform(post("/callbacks/fit-connect")).andExpect(status().isOk());
}
}

0 comments on commit 3485cc7

Please sign in to comment.