feat(codepipeline): add AWS CodePipeline emulation (#1469)

* feat(codepipeline): add AWS CodePipeline emulation

* fix(codepipeline): align webhook and rollback response shapes
This commit is contained in:
kotov228 authored and GitHub committed 2026-06-21 09:01:44 -05:00
1 parent c2cd31216b
commit 3f314dcb4e
19 files changed
+2624 -8

No files matched your search

@@ -175,6 +175,7 @@ public interface EmulatorConfig {
CloudFrontStorageConfig cloudfront();
AppSyncStorageConfig appsync();
BatchStorageConfig batch();
CodePipelineStorageConfig codepipeline();
S3VectorsStorageConfig s3vectors();
}
@@ -314,6 +315,13 @@ public interface EmulatorConfig {
long flushIntervalMs();
}
interface CodePipelineStorageConfig {
Optional<String> mode();
@WithDefault("5000")
long flushIntervalMs();
}
interface S3VectorsStorageConfig {
Optional<String> mode();
@@ -384,6 +392,7 @@ public interface EmulatorConfig {
ElbV2ServiceConfig elbv2();
CodeBuildServiceConfig codebuild();
CodeDeployServiceConfig codedeploy();
CodePipelineServiceConfig codepipeline();
AutoScalingServiceConfig autoscaling();
BackupServiceConfig backup();
NeptuneServiceConfig neptune();
@@ -478,6 +487,11 @@ public interface EmulatorConfig {
boolean enabled();
}
interface CodePipelineServiceConfig {
@WithDefault("true")
boolean enabled();
}
interface SsmServiceConfig {
@WithDefault("true")
boolean enabled();
@@ -6,6 +6,7 @@ import io.github.hectorvent.floci.services.acm.AcmJsonHandler;
import io.github.hectorvent.floci.services.athena.AthenaJsonHandler;
import io.github.hectorvent.floci.services.codebuild.CodeBuildJsonHandler;
import io.github.hectorvent.floci.services.codedeploy.CodeDeployJsonHandler;
import io.github.hectorvent.floci.services.codepipeline.CodePipelineJsonHandler;
import io.github.hectorvent.floci.services.ecr.EcrJsonHandler;
import io.github.hectorvent.floci.services.transfer.TransferHandler;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
@@ -78,6 +79,7 @@ public class AwsJson11Controller {
private final ResourceGroupsTaggingJsonHandler resourceGroupsTaggingJsonHandler;
private final CodeBuildJsonHandler codeBuildJsonHandler;
private final CodeDeployJsonHandler codeDeployJsonHandler;
private final CodePipelineJsonHandler codePipelineJsonHandler;
private final Ec2MessagesJsonHandler ec2MessagesJsonHandler;
private final TransferHandler transferHandler;
private final TextractJsonHandler textractJsonHandler;
@@ -109,6 +111,7 @@ public class AwsJson11Controller {
ResourceGroupsTaggingJsonHandler resourceGroupsTaggingJsonHandler,
CodeBuildJsonHandler codeBuildJsonHandler,
CodeDeployJsonHandler codeDeployJsonHandler,
CodePipelineJsonHandler codePipelineJsonHandler,
Ec2MessagesJsonHandler ec2MessagesJsonHandler,
TransferHandler transferHandler,
TextractJsonHandler textractJsonHandler,
@@ -143,6 +146,7 @@ public class AwsJson11Controller {
this.resourceGroupsTaggingJsonHandler = resourceGroupsTaggingJsonHandler;
this.codeBuildJsonHandler = codeBuildJsonHandler;
this.codeDeployJsonHandler = codeDeployJsonHandler;
this.codePipelineJsonHandler = codePipelineJsonHandler;
this.ec2MessagesJsonHandler = ec2MessagesJsonHandler;
this.transferHandler = transferHandler;
this.textractJsonHandler = textractJsonHandler;
@@ -202,6 +206,8 @@ public class AwsJson11Controller {
case "tagging" -> resourceGroupsTaggingJsonHandler.handle(action, request, region);
case "codebuild" -> codeBuildJsonHandler.handle(action, request, region, regionResolver.getAccountId());
case "codedeploy" -> codeDeployJsonHandler.handle(action, request, region);
case "codepipeline" -> codePipelineJsonHandler.handle(
action, request, region, regionResolver.getAccountId());
case "ec2messages" -> ec2MessagesJsonHandler.handle(action, request, region);
case "transfer" -> transferHandler.handle(action, request, region);
case "textract" -> textractJsonHandler.handle(action, request, region);
@@ -263,6 +263,12 @@ public class ResolvedServiceCatalog {
null, null, 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
Set.of("CodeDeploy_20141006."), Set.of("codedeploy"), Set.of(), Set.of()),
descriptor("codepipeline", "codepipeline", config.services().codepipeline().enabled(), true,
"codepipeline",
storageMode(config.storage().services().codepipeline().mode(), config.storage().mode()),
config.storage().services().codepipeline().flushIntervalMs(), null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
Set.of("CodePipeline_20150709."), Set.of("codepipeline"), Set.of(), Set.of()),
descriptor("config", "configservice", config.services().configservice().enabled(), true,
null, null, 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
@@ -0,0 +1,21 @@
package io.github.hectorvent.floci.services.codepipeline;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.Response;
@ApplicationScoped
public class CodePipelineJsonHandler {
private final CodePipelineService service;
@Inject
public CodePipelineJsonHandler(CodePipelineService service) {
this.service = service;
}
public Response handle(String action, JsonNode request, String region, String account) {
JsonNode response = service.handle(action, request, region, account);
return Response.ok(response).build();
}
}
@@ -0,0 +1,349 @@
package io.github.hectorvent.floci.services.codepipeline.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CodePipelineExecution {
public CodePipelineExecution() {
}
private String accountId;
private String region;
private String pipelineExecutionId;
private String pipelineName;
private Integer pipelineVersion;
private String status;
private String statusSummary;
private String executionMode;
private String executionType;
private Double startTime;
private Double lastUpdateTime;
private List<Map<String, Object>> artifactRevisions = new ArrayList<>();
private List<Map<String, Object>> sourceRevisions = new ArrayList<>();
private List<Map<String, String>> variables = new ArrayList<>();
private Map<String, String> trigger = new LinkedHashMap<>();
private List<ActionExecution> actionExecutions = new ArrayList<>();
private String currentStage;
private boolean stopRequested;
private boolean abandon;
private String rollbackTargetPipelineExecutionId;
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getPipelineExecutionId() {
return pipelineExecutionId;
}
public void setPipelineExecutionId(String pipelineExecutionId) {
this.pipelineExecutionId = pipelineExecutionId;
}
public String getPipelineName() {
return pipelineName;
}
public void setPipelineName(String pipelineName) {
this.pipelineName = pipelineName;
}
public Integer getPipelineVersion() {
return pipelineVersion;
}
public void setPipelineVersion(Integer pipelineVersion) {
this.pipelineVersion = pipelineVersion;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getStatusSummary() {
return statusSummary;
}
public void setStatusSummary(String statusSummary) {
this.statusSummary = statusSummary;
}
public String getExecutionMode() {
return executionMode;
}
public void setExecutionMode(String executionMode) {
this.executionMode = executionMode;
}
public String getExecutionType() {
return executionType;
}
public void setExecutionType(String executionType) {
this.executionType = executionType;
}
public Double getStartTime() {
return startTime;
}
public void setStartTime(Double startTime) {
this.startTime = startTime;
}
public Double getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(Double lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
public List<Map<String, Object>> getArtifactRevisions() {
return artifactRevisions;
}
public void setArtifactRevisions(List<Map<String, Object>> artifactRevisions) {
this.artifactRevisions = artifactRevisions;
}
public List<Map<String, Object>> getSourceRevisions() {
return sourceRevisions;
}
public void setSourceRevisions(List<Map<String, Object>> sourceRevisions) {
this.sourceRevisions = sourceRevisions;
}
public List<Map<String, String>> getVariables() {
return variables;
}
public void setVariables(List<Map<String, String>> variables) {
this.variables = variables;
}
public Map<String, String> getTrigger() {
return trigger;
}
public void setTrigger(Map<String, String> trigger) {
this.trigger = trigger;
}
public List<ActionExecution> getActionExecutions() {
return actionExecutions;
}
public void setActionExecutions(List<ActionExecution> actionExecutions) {
this.actionExecutions = actionExecutions;
}
public String getCurrentStage() {
return currentStage;
}
public void setCurrentStage(String currentStage) {
this.currentStage = currentStage;
}
public boolean isStopRequested() {
return stopRequested;
}
public void setStopRequested(boolean stopRequested) {
this.stopRequested = stopRequested;
}
public boolean isAbandon() {
return abandon;
}
public void setAbandon(boolean abandon) {
this.abandon = abandon;
}
public String getRollbackTargetPipelineExecutionId() {
return rollbackTargetPipelineExecutionId;
}
public void setRollbackTargetPipelineExecutionId(String rollbackTargetPipelineExecutionId) {
this.rollbackTargetPipelineExecutionId = rollbackTargetPipelineExecutionId;
}
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class ActionExecution {
public ActionExecution() {
}
private String actionExecutionId;
private String stageName;
private String actionName;
private String category;
private String owner;
private String provider;
private Integer runOrder;
private String status;
private Double startTime;
private Double lastUpdateTime;
private String summary;
private String externalExecutionId;
private String externalExecutionUrl;
private String token;
private Map<String, String> outputVariables = new LinkedHashMap<>();
private Map<String, Object> errorDetails;
public String getActionExecutionId() {
return actionExecutionId;
}
public void setActionExecutionId(String actionExecutionId) {
this.actionExecutionId = actionExecutionId;
}
public String getStageName() {
return stageName;
}
public void setStageName(String stageName) {
this.stageName = stageName;
}
public String getActionName() {
return actionName;
}
public void setActionName(String actionName) {
this.actionName = actionName;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getProvider() {
return provider;
}
public void setProvider(String provider) {
this.provider = provider;
}
public Integer getRunOrder() {
return runOrder;
}
public void setRunOrder(Integer runOrder) {
this.runOrder = runOrder;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Double getStartTime() {
return startTime;
}
public void setStartTime(Double startTime) {
this.startTime = startTime;
}
public Double getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(Double lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getExternalExecutionId() {
return externalExecutionId;
}
public void setExternalExecutionId(String externalExecutionId) {
this.externalExecutionId = externalExecutionId;
}
public String getExternalExecutionUrl() {
return externalExecutionUrl;
}
public void setExternalExecutionUrl(String externalExecutionUrl) {
this.externalExecutionUrl = externalExecutionUrl;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public Map<String, String> getOutputVariables() {
return outputVariables;
}
public void setOutputVariables(Map<String, String> outputVariables) {
this.outputVariables = outputVariables;
}
public Map<String, Object> getErrorDetails() {
return errorDetails;
}
public void setErrorDetails(Map<String, Object> errorDetails) {
this.errorDetails = errorDetails;
}
}
}
@@ -0,0 +1,150 @@
package io.github.hectorvent.floci.services.codepipeline.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.JsonNode;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.LinkedHashMap;
import java.util.Map;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CodePipelinePipeline {
public CodePipelinePipeline() {
}
private String accountId;
private String region;
private String name;
private String arn;
private Integer version;
private Double created;
private Double updated;
private JsonNode declaration;
private Map<String, String> tags = new LinkedHashMap<>();
private Map<String, TransitionState> transitions = new LinkedHashMap<>();
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getArn() {
return arn;
}
public void setArn(String arn) {
this.arn = arn;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
public Double getCreated() {
return created;
}
public void setCreated(Double created) {
this.created = created;
}
public Double getUpdated() {
return updated;
}
public void setUpdated(Double updated) {
this.updated = updated;
}
public JsonNode getDeclaration() {
return declaration;
}
public void setDeclaration(JsonNode declaration) {
this.declaration = declaration;
}
public Map<String, String> getTags() {
return tags;
}
public void setTags(Map<String, String> tags) {
this.tags = tags;
}
public Map<String, TransitionState> getTransitions() {
return transitions;
}
public void setTransitions(Map<String, TransitionState> transitions) {
this.transitions = transitions;
}
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class TransitionState {
public TransitionState() {
}
private boolean enabled = true;
private String reason;
private Double lastChangedAt;
private String lastChangedBy;
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public Double getLastChangedAt() {
return lastChangedAt;
}
public void setLastChangedAt(Double lastChangedAt) {
this.lastChangedAt = lastChangedAt;
}
public String getLastChangedBy() {
return lastChangedBy;
}
public void setLastChangedBy(String lastChangedBy) {
this.lastChangedBy = lastChangedBy;
}
}
}
@@ -0,0 +1,85 @@
package io.github.hectorvent.floci.services.codepipeline.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.JsonNode;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CodePipelineStoredItem {
public CodePipelineStoredItem() {
}
private String accountId;
private String region;
private String id;
private String type;
private String status;
private Double created;
private Double updated;
private JsonNode data;
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Double getCreated() {
return created;
}
public void setCreated(Double created) {
this.created = created;
}
public Double getUpdated() {
return updated;
}
public void setUpdated(Double updated) {
this.updated = updated;
}
public JsonNode getData() {
return data;
}
public void setData(JsonNode data) {
this.data = data;
}
}
+4 -1
View File
@@ -94,6 +94,8 @@ floci:
flush-interval-ms: 5000
batch:
flush-interval-ms: 5000
codepipeline:
flush-interval-ms: 5000
s3vectors:
flush-interval-ms: 5000
rds:
@@ -330,6 +332,8 @@ floci:
# docker-network: floci-network
codedeploy:
enabled: true
codepipeline:
enabled: true
autoscaling:
enabled: true
backup:
@@ -363,4 +367,3 @@ floci:
enabled: true
s3vectors:
enabled: true
@@ -0,0 +1,383 @@
package io.github.hectorvent.floci.services.codepipeline;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.Response;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.time.Duration;
import java.time.Instant;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
@QuarkusTest
class CodePipelineIntegrationTest {
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
private static final String TARGET = "CodePipeline_20150709.";
@BeforeAll
static void configureRestAssured() {
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
void pipelineLifecycleExecutesS3SourceAndDeployActions() throws Exception {
createBucket("codepipeline-source");
createBucket("codepipeline-destination");
putObject("codepipeline-source", "source.zip", "pipeline artifact");
String pipelineName = "s3-copy-pipeline";
post("CreatePipeline", pipeline(pipelineName, """
{
"name": "Source",
"actions": [{
"name": "SourceObject",
"actionTypeId": {
"category": "Source",
"owner": "AWS",
"provider": "S3",
"version": "1"
},
"configuration": {
"S3Bucket": "codepipeline-source",
"S3ObjectKey": "source.zip"
},
"outputArtifacts": [{"name": "SourceOutput"}],
"runOrder": 1
}]
},
{
"name": "Deploy",
"actions": [{
"name": "DeployObject",
"actionTypeId": {
"category": "Deploy",
"owner": "AWS",
"provider": "S3",
"version": "1"
},
"configuration": {
"BucketName": "codepipeline-destination",
"ObjectKey": "deployed.zip"
},
"inputArtifacts": [{"name": "SourceOutput"}],
"runOrder": 1
}]
}
"""))
.then()
.statusCode(200)
.body("pipeline.name", equalTo(pipelineName))
.body("pipeline.version", equalTo(1))
.body("pipeline.executionMode", equalTo("SUPERSEDED"));
String executionId = post("StartPipelineExecution", """
{"name": "%s", "clientRequestToken": "s3-copy-token"}
""".formatted(pipelineName))
.then()
.statusCode(200)
.body("pipelineExecutionId", notNullValue())
.extract().path("pipelineExecutionId");
waitForExecution(pipelineName, executionId, "Succeeded");
given()
.get("/codepipeline-destination/deployed.zip")
.then()
.statusCode(200)
.body(equalTo("pipeline artifact"));
post("GetPipelineExecution", """
{"pipelineName": "%s", "pipelineExecutionId": "%s"}
""".formatted(pipelineName, executionId))
.then()
.statusCode(200)
.body("pipelineExecution.pipelineName", equalTo(pipelineName))
.body("pipelineExecution.status", equalTo("Succeeded"))
.body("pipelineExecution.artifactRevisions", hasSize(1))
.body("pipelineExecution.artifactRevisions[0].name", equalTo("SourceObject"));
post("GetPipelineState", """
{"name": "%s"}
""".formatted(pipelineName))
.then()
.statusCode(200)
.body("stageStates", hasSize(2))
.body("stageStates[0].actionStates[0].latestExecution.status", equalTo("Succeeded"));
post("ListActionExecutions", """
{
"pipelineName": "%s",
"filter": {"pipelineExecutionId": "%s"}
}
""".formatted(pipelineName, executionId))
.then()
.statusCode(200)
.body("actionExecutionDetails", hasSize(2));
String rollbackExecutionId = post("RollbackStage", """
{
"pipelineName": "%s",
"stageName": "Deploy",
"targetPipelineExecutionId": "%s"
}
""".formatted(pipelineName, executionId))
.then()
.statusCode(200)
.body("pipelineExecutionId", notNullValue())
.extract().path("pipelineExecutionId");
waitForExecution(pipelineName, rollbackExecutionId, "Succeeded");
post("GetPipelineExecution", """
{"pipelineName": "%s", "pipelineExecutionId": "%s"}
""".formatted(pipelineName, rollbackExecutionId))
.then()
.statusCode(200)
.body("pipelineExecution.executionType", equalTo("ROLLBACK"))
.body("pipelineExecution.rollbackMetadata.rollbackTargetPipelineExecutionId", equalTo(executionId))
.body("pipelineExecution.rollbackTargetPipelineExecutionId", nullValue());
post("TagResource", """
{
"resourceArn": "arn:aws:codepipeline:us-east-1:000000000000:%s",
"tags": [{"key": "environment", "value": "test"}]
}
""".formatted(pipelineName)).then().statusCode(200);
post("ListTagsForResource", """
{"resourceArn": "arn:aws:codepipeline:us-east-1:000000000000:%s"}
""".formatted(pipelineName))
.then()
.statusCode(200)
.body("tags[0].key", equalTo("environment"));
post("ListPipelines", "{}")
.then()
.statusCode(200)
.body("pipelines.name", hasItem(pipelineName));
post("DeletePipeline", """
{"name": "%s"}
""".formatted(pipelineName)).then().statusCode(200);
}
@Test
void customActionUsesAwsWorkerJobProtocol() throws Exception {
createBucket("codepipeline-custom-source");
putObject("codepipeline-custom-source", "source.zip", "custom artifact");
post("CreateCustomActionType", """
{
"category": "Build",
"provider": "FlociWorker",
"version": "1",
"inputArtifactDetails": {"minimumCount": 0, "maximumCount": 1},
"outputArtifactDetails": {"minimumCount": 0, "maximumCount": 1}
}
""")
.then()
.statusCode(200)
.body("actionType.id.owner", equalTo("Custom"));
String pipelineName = "custom-worker-pipeline";
post("CreatePipeline", pipeline(pipelineName, """
{
"name": "Source",
"actions": [{
"name": "SourceObject",
"actionTypeId": {
"category": "Source",
"owner": "AWS",
"provider": "S3",
"version": "1"
},
"configuration": {
"S3Bucket": "codepipeline-custom-source",
"S3ObjectKey": "source.zip"
},
"outputArtifacts": [{"name": "SourceOutput"}]
}]
},
{
"name": "Build",
"actions": [{
"name": "WorkerBuild",
"actionTypeId": {
"category": "Build",
"owner": "Custom",
"provider": "FlociWorker",
"version": "1"
},
"inputArtifacts": [{"name": "SourceOutput"}]
}]
}
""")).then().statusCode(200);
String executionId = post("StartPipelineExecution", """
{"name": "%s"}
""".formatted(pipelineName)).then().extract().path("pipelineExecutionId");
Response poll = waitForJob();
String jobId = poll.path("jobs[0].id");
String nonce = poll.path("jobs[0].nonce");
post("AcknowledgeJob", """
{"jobId": "%s", "nonce": "%s"}
""".formatted(jobId, nonce))
.then()
.statusCode(200)
.body("status", equalTo("InProgress"));
post("PutJobSuccessResult", """
{
"jobId": "%s",
"executionDetails": {
"summary": "worker completed",
"externalExecutionId": "worker-1",
"percentComplete": 100
},
"outputVariables": {"result": "ok"}
}
""".formatted(jobId)).then().statusCode(200);
waitForExecution(pipelineName, executionId, "Succeeded");
post("DeleteCustomActionType", """
{"category": "Build", "provider": "FlociWorker", "version": "1"}
""").then().statusCode(200);
}
@Test
void webhookStageTransitionAndValidationErrorsUseAwsShapes() {
post("PutWebhook", """
{
"webhook": {
"name": "source-hook",
"targetPipeline": "pipeline",
"targetAction": "source",
"filters": [{"jsonPath": "$.ref", "matchEquals": "refs/heads/main"}],
"authentication": "UNAUTHENTICATED"
}
}
""")
.then()
.statusCode(200)
.body("webhook.definition.name", equalTo("source-hook"))
.body("webhook.definition.targetPipeline", equalTo("pipeline"))
.body("webhook.definition.targetAction", equalTo("source"))
.body("webhook.registrationStatus", nullValue());
post("RegisterWebhookWithThirdParty", """
{"webhookName": "source-hook"}
""").then().statusCode(200);
post("ListWebhooks", "{}")
.then()
.statusCode(200)
.body("webhooks.definition.name", hasItem("source-hook"))
.body("webhooks[0].definition.filters[0].jsonPath", equalTo("$.ref"))
.body("webhooks[0].registrationStatus", nullValue());
post("DeleteWebhook", """
{"name": "source-hook"}
""")
.then()
.statusCode(200)
.body(equalTo("{}"));
post("CreatePipeline", """
{"pipeline": {"name": "invalid", "roleArn": "role", "stages": []}}
""")
.then()
.statusCode(400)
.body("__type", containsString("InvalidStructureException"));
}
private Response waitForJob() throws Exception {
Instant deadline = Instant.now().plus(Duration.ofSeconds(5));
Response response;
do {
response = post("PollForJobs", """
{
"actionTypeId": {
"category": "Build",
"owner": "Custom",
"provider": "FlociWorker",
"version": "1"
}
}
""");
if (response.jsonPath().getList("jobs").size() == 1) {
return response;
}
Thread.sleep(50);
} while (Instant.now().isBefore(deadline));
throw new AssertionError("Custom action job was not created");
}
private void waitForExecution(String pipelineName, String executionId, String expected) throws Exception {
Instant deadline = Instant.now().plus(Duration.ofSeconds(5));
String status;
do {
status = post("GetPipelineExecution", """
{"pipelineName": "%s", "pipelineExecutionId": "%s"}
""".formatted(pipelineName, executionId))
.jsonPath().getString("pipelineExecution.status");
if (expected.equals(status)) {
return;
}
if ("Failed".equals(status)) {
throw new AssertionError("Pipeline failed");
}
Thread.sleep(50);
} while (Instant.now().isBefore(deadline));
throw new AssertionError("Pipeline did not reach " + expected + ", last status: " + status);
}
private static Response post(String action, String body) {
return given()
.header("X-Amz-Target", TARGET + action)
.contentType(CONTENT_TYPE)
.body(body)
.when()
.post("/");
}
private static String pipeline(String name, String stages) {
return """
{
"pipeline": {
"name": "%s",
"roleArn": "arn:aws:iam::000000000000:role/codepipeline-role",
"artifactStore": {
"type": "S3",
"location": "codepipeline-artifacts"
},
"stages": [%s]
}
}
""".formatted(name, stages);
}
private static void createBucket(String bucket) {
given().when().put("/" + bucket).then().statusCode(200);
}
private static void putObject(String bucket, String key, String body) {
given()
.contentType("application/octet-stream")
.body(body.getBytes(java.nio.charset.StandardCharsets.UTF_8))
.when()
.put("/" + bucket + "/" + key)
.then()
.statusCode(200);
}
}
+4 -1
View File
@@ -38,6 +38,8 @@ floci:
flush-interval-ms: 60000
batch:
flush-interval-ms: 60000
codepipeline:
flush-interval-ms: 60000
s3vectors:
flush-interval-ms: 60000
cloudfront:
@@ -201,6 +203,8 @@ floci:
runner-mode: immediate
codedeploy:
enabled: true
codepipeline:
enabled: true
autoscaling:
enabled: true
transfer:
@@ -230,4 +234,3 @@ floci:
enabled: true
s3vectors:
enabled: true