mirror of
https://github.com/floci-io/floci.git
synced 2026-12-04 10:38:00 -05:00
Floci had zero CodeArtifact support: no service package, no docs, nothing. Any terraform apply touching aws_codeartifact_domain, aws_codeartifact_repository, or either permissions-policy resource failed outright. This adds the full CodeArtifact control plane: domain and repository CRUD, resource policies with optimistic-locking revisions, tags, and the fixed set of real AWS-hosted external (upstream) connections (public:npmjs, public:pypi, public:maven-central, etc.). Package publish/fetch endpoints per format (npm, PyPI, Maven, NuGet, generic) are intentionally out of scope here: this closes the terraform apply gap, not real package serving. ListTagsForResource (POST /v1/tags?resourceArn=) is CodeArtifact's one tag operation that addresses the resource with a query parameter on the bare path rather than a path segment, unlike every other V1TagsController/SharedTagsController handler. That method lives on V1TagsController itself rather than the shared AbstractTagsController base: SharedTagsController (mounted at /tags) already declares its own bare POST (tagResourceByBody, for TagResource), so a bare POST on the shared base collides with it and Quarkus refuses to start. CodeArtifact's handler is @V1Tags-qualified and only ever registered against V1TagsController, so the method belongs there. core/common stays service-free: CodeArtifactTagHandler registers itself as a bean the same way MskTagHandler does, and TagHandler gained a default for the lowercase key/value entry names CodeArtifact uses instead of AWS's usual capitalized Key/Value. Known, documented limitations (see docs/services/codeartifact.md): no cycle detection across upstream chains, no referential-integrity check when deleting a repository other repositories reference as an upstream, and no authorization check on cross-account domainOwner addressing (consistent with Floci's opt-in IAM enforcement elsewhere). Verified against the real botocore codeartifact service-2.json (protocol, exact querystring vs. body placement per operation, exact ARN format, epoch-seconds timestamps, real error shapes) and the live AWS API docs for behavioral rules not in the wire model (DeleteDomain blocked while repositories exist, the real fixed external-connection name/format list, PutDomainPermissionsPolicy's all-body field placement vs. the sibling repository operation's querystring placement). Live-verified three ways: - Unit tests including a concurrent-create race test proving the synchronized guard actually holds under contention, plus full-stack QuarkusTest/RestAssured integration tests. - A real terraform init/apply/plan/destroy cycle against a running Floci instance, independently confirming destroy actually tore the domain down via a follow-up describe-domain call. - A live AWS SDK v2 Java test exercising the real CodeartifactClient against a live instance.
89 lines
3.7 KiB
Bash
89 lines
3.7 KiB
Bash
#!/usr/bin/env bats
|
|
# CodeArtifact Control Plane Compatibility Test
|
|
#
|
|
# Floci previously had no CodeArtifact support at all. This verifies aws_codeartifact_domain,
|
|
# aws_codeartifact_domain_permissions_policy, aws_codeartifact_repository (with tags and an
|
|
# upstream), and aws_codeartifact_repository_permissions_policy can all apply, that a second
|
|
# plan is clean, and that destroy tears everything down in dependency order.
|
|
|
|
setup_file() {
|
|
load 'test_helper/common-setup'
|
|
|
|
CA_TF_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/codeartifact-domain-repo-tf" && pwd)"
|
|
cd "$CA_TF_DIR"
|
|
|
|
echo "# === CodeArtifact Domain/Repository Test ===" >&3
|
|
echo "# Endpoint: $FLOCI_ENDPOINT" >&3
|
|
echo "# Config: $CA_TF_DIR" >&3
|
|
|
|
find .terraform -mindepth 1 -delete 2>/dev/null || true
|
|
rm -f .terraform.lock.hcl terraform.tfstate terraform.tfstate.backup 2>/dev/null || true
|
|
|
|
echo "# --- terraform init ---" >&3
|
|
run terraform init -input=false -no-color
|
|
if [ "$status" -ne 0 ]; then
|
|
echo "# terraform init failed: $output" >&3
|
|
return 1
|
|
fi
|
|
|
|
echo "# --- terraform apply ---" >&3
|
|
run terraform apply -var="endpoint=${FLOCI_ENDPOINT}" -input=false -auto-approve -no-color
|
|
if [ "$status" -ne 0 ]; then
|
|
echo "# terraform apply failed: $output" >&3
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
teardown_file() {
|
|
load 'test_helper/common-setup'
|
|
|
|
CA_TF_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/codeartifact-domain-repo-tf" && pwd)"
|
|
cd "$CA_TF_DIR"
|
|
|
|
terraform destroy -var="endpoint=${FLOCI_ENDPOINT}" -input=false -auto-approve -no-color || true
|
|
find .terraform -mindepth 1 -delete 2>/dev/null || true
|
|
rm -f .terraform.lock.hcl terraform.tfstate terraform.tfstate.backup 2>/dev/null || true
|
|
}
|
|
|
|
setup() {
|
|
load 'test_helper/common-setup'
|
|
CA_TF_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/codeartifact-domain-repo-tf" && pwd)"
|
|
}
|
|
|
|
@test "CodeArtifact domain/repository: apply reports the domain and repository ARNs" {
|
|
DOMAIN_ARN=$(terraform -chdir="$CA_TF_DIR" output -raw domain_arn)
|
|
REPO_ARN=$(terraform -chdir="$CA_TF_DIR" output -raw repository_arn)
|
|
assert_equal "$DOMAIN_ARN" "arn:aws:codeartifact:us-east-1:000000000000:domain/floci-codeartifact-domain"
|
|
assert_equal "$REPO_ARN" "arn:aws:codeartifact:us-east-1:000000000000:repository/floci-codeartifact-domain/floci-codeartifact-consumer"
|
|
}
|
|
|
|
@test "CodeArtifact domain/repository: tags and upstream round-trip" {
|
|
OWNER_TAG=$(terraform -chdir="$CA_TF_DIR" output -raw domain_owner_tag)
|
|
TEAM_TAG=$(terraform -chdir="$CA_TF_DIR" output -raw repository_team_tag)
|
|
UPSTREAM=$(terraform -chdir="$CA_TF_DIR" output -raw repository_upstream)
|
|
assert_equal "$OWNER_TAG" "platform"
|
|
assert_equal "$TEAM_TAG" "data"
|
|
assert_equal "$UPSTREAM" "floci-codeartifact-store"
|
|
}
|
|
|
|
@test "CodeArtifact domain/repository: DescribeDomain reports the live repository count" {
|
|
run aws_cmd codeartifact describe-domain --domain floci-codeartifact-domain \
|
|
--query "domain.repositoryCount" --output text
|
|
assert_success
|
|
assert_output "2"
|
|
}
|
|
|
|
@test "CodeArtifact domain/repository: second plan reports no changes" {
|
|
cd "$CA_TF_DIR"
|
|
run terraform plan -var="endpoint=${FLOCI_ENDPOINT}" -input=false -no-color -detailed-exitcode
|
|
assert_success
|
|
assert_output --partial "No changes"
|
|
}
|
|
|
|
@test "CodeArtifact domain/repository: GetRepositoryEndpoint resolves for a real package format" {
|
|
run aws_cmd codeartifact get-repository-endpoint --domain floci-codeartifact-domain \
|
|
--repository floci-codeartifact-consumer --format npm --query repositoryEndpoint --output text
|
|
assert_success
|
|
[[ "$output" == *"/codeartifact/npm/floci-codeartifact-domain/floci-codeartifact-consumer/"* ]]
|
|
}
|