Skip to content
This repository was archived by the owner on Dec 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Call<Map> webhooks(
Call<List<Map<String, String>>> getPubsubSubscriptions();

@POST("/")
Call<String> postEvent(@Body Map event);
Call<Void> postEvent(@Body Map event);

@GET("/quietPeriod")
Call<Map> getQuietPeriodState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
Expand Down Expand Up @@ -58,6 +59,7 @@
@TestPropertySource(
properties = {
"spring.config.location=classpath:gate-test.yml",
"services.echo.enabled=true",
"services.front50.applicationRefreshInitialDelayMs=3600000"
})
public class PipelineServiceTest {
Expand All @@ -67,6 +69,10 @@ public class PipelineServiceTest {
static WireMockExtension wmOrca =
WireMockExtension.newInstance().options(wireMockConfig().dynamicPort()).build();

@RegisterExtension
static WireMockExtension wmEcho =
WireMockExtension.newInstance().options(wireMockConfig().dynamicPort()).build();

@Autowired private WebApplicationContext webApplicationContext;

ObjectMapper objectMapper = new ObjectMapper();
Expand All @@ -90,6 +96,8 @@ public class PipelineServiceTest {
/** To prevent periodic calls to load accounts from clouddriver */
@MockBean DefaultProviderLookupService defaultProviderLookupService;

private static final String APPLICATION_NAME = "my-application";
private static final String PIPELINE_NAME = "my-pipeline-name";
private static final String USERNAME = "some user";
private static final String ACCOUNT = "my-account";
private static final String PIPELINE_EXECUTION_ID = "my-pipeline-execution-id";
Expand All @@ -99,6 +107,8 @@ static void registerUrls(DynamicPropertyRegistry registry) {
// Configure wiremock's random ports into gate
System.out.println("wiremock orca url: " + wmOrca.baseUrl());
registry.add("services.orca.base-url", wmOrca::baseUrl);
System.out.println("wiremock echo url: " + wmEcho.baseUrl());
registry.add("services.echo.base-url", wmEcho::baseUrl);
}

@BeforeEach
Expand Down Expand Up @@ -143,4 +153,21 @@ void invokeDeletePipelineExecution() throws Exception {
.andDo(print())
.andExpect(status().is2xxSuccessful());
}

@Test
void invokePipelineConfigViaEcho() throws Exception {
wmEcho.stubFor(WireMock.post(urlEqualTo("/")).willReturn(aResponse().withStatus(200)));

webAppMockMvc
.perform(
post("/pipelines/v2/" + APPLICATION_NAME + "/" + PIPELINE_NAME)
.header(
USER.getHeader(),
USERNAME) // to silence warning when X-SPINNAKER-USER is missing
.header(
ACCOUNTS.getHeader(),
ACCOUNT)) // to silence warning when X-SPINNAKER-ACCOUNTS is missing
.andDo(print())
.andExpect(status().is2xxSuccessful());
}
}