Skip to content
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
25 changes: 15 additions & 10 deletions .github/workflows/subsystem.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,39 @@ on:
pull_request:
branches: [main, 'release/v*']

# All jobs build control-plane via Containerfile (UBI builder + runtime).
# Pre-pull with retries avoids flaky CDN EOFs during podman-compose build.
env:
CONTROL_PLANE_BUILD_IMAGES: >-
registry.access.redhat.com/ubi9/go-toolset:1.25.5
registry.access.redhat.com/ubi9/ubi-minimal:latest

jobs:
policy-subsystem:
uses: dcm-project/shared-workflows/.github/workflows/black-box.yaml@main
with:
up-target: policy-subsystem-test-up
test-target: policy-subsystem-test
down-target: policy-subsystem-test-down
images: "${{ env.CONTROL_PLANE_BUILD_IMAGES }} quay.io/sclorg/postgresql-16-c9s:latest"
images: >-
registry.access.redhat.com/ubi9/go-toolset:1.25.5
registry.access.redhat.com/ubi9/ubi-minimal:latest
quay.io/sclorg/postgresql-16-c9s:latest

catalog-subsystem:
uses: dcm-project/shared-workflows/.github/workflows/black-box.yaml@main
with:
up-target: catalog-subsystem-test-up
test-target: catalog-subsystem-test
down-target: catalog-subsystem-test-down
images: "${{ env.CONTROL_PLANE_BUILD_IMAGES }} quay.io/sclorg/postgresql-16-c9s:latest wiremock/wiremock:3x"
images: >-
registry.access.redhat.com/ubi9/go-toolset:1.25.5
registry.access.redhat.com/ubi9/ubi-minimal:latest
quay.io/sclorg/postgresql-16-c9s:latest
wiremock/wiremock:3x

sp-subsystem:
uses: dcm-project/shared-workflows/.github/workflows/black-box.yaml@main
with:
up-target: sp-subsystem-test-up
test-target: sp-subsystem-test
down-target: sp-subsystem-test-down
images: "${{ env.CONTROL_PLANE_BUILD_IMAGES }} quay.io/sclorg/postgresql-16-c9s:latest wiremock/wiremock:3x docker.io/library/nats:2-alpine"
images: >-
registry.access.redhat.com/ubi9/go-toolset:1.25.5
registry.access.redhat.com/ubi9/ubi-minimal:latest
quay.io/sclorg/postgresql-16-c9s:latest
wiremock/wiremock:3x
docker.io/library/nats:2-alpine
4 changes: 4 additions & 0 deletions internal/app/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ func oapiRequestValidator(spec *openapi3.T) func(http.Handler) http.Handler {
return nethttpmiddleware.OapiRequestValidatorWithOptions(spec, &nethttpmiddleware.Options{
Options: openapi3filter.Options{
AuthenticationFunc: openapi3filter.NoopAuthenticationFunc,
// kin-openapi rewrites validated bodies when schema defaults are applied,
// but only registers encoders for application/json. PATCH merge bodies
// use application/merge-patch+json and must stay partial (RFC 7396).
SkipSettingDefaults: true,
},
SilenceServersWarning: true,
})
Expand Down
16 changes: 16 additions & 0 deletions internal/app/openapi_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ var _ = Describe("OpenAPI request validation", func() {
It("rejects malformed JSON on POST /policies", func() {
expectInvalidJSONRejected(validators, "/api/v1alpha1/policies")
})

It("allows valid partial PATCH on /policies/{policyId}", func() {
router := chi.NewRouter()
router.Use(validators.middleware())
router.Patch("/api/v1alpha1/policies/{policyId}", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
})

body := `{"display_name":"Updated Name","priority":600}`
req := httptest.NewRequest(http.MethodPatch, "/api/v1alpha1/policies/test-policy-id", strings.NewReader(body))
req.Header.Set("Content-Type", "application/merge-patch+json")
rec := httptest.NewRecorder()
router.ServeHTTP(rec, req)

Expect(rec.Code).To(Equal(http.StatusOK), rec.Body.String())
})
})

Describe("catalog routes", func() {
Expand Down