From 19da7a6185afc43c1336cc6be5bb11a4f86593e0 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Fri, 27 Oct 2023 15:23:37 +0200 Subject: [PATCH] cloudapi: add upload targets to route handler tests --- internal/cloudapi/v2/v2_test.go | 84 +++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/internal/cloudapi/v2/v2_test.go b/internal/cloudapi/v2/v2_test.go index fc5d4249603..39cea9e7331 100644 --- a/internal/cloudapi/v2/v2_test.go +++ b/internal/cloudapi/v2/v2_test.go @@ -291,6 +291,7 @@ func TestCompose(t *testing.T) { // "reason": "Requested method isn't supported for resource" // }`, "operation_id") + // With upload options for default target test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(` { "distribution": "%s", @@ -310,6 +311,59 @@ func TestCompose(t *testing.T) { "href": "/api/image-builder-composer/v2/compose", "kind": "ComposeId" }`, "id") + + // With upload options for specific upload target + test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(` + { + "distribution": "%s", + "image_request":{ + "architecture": "%s", + "image_type": "aws", + "repositories": [{ + "baseurl": "somerepo.org", + "rhsm": false + }], + "upload_targets": [{ + "type": "org.osbuild.aws", + "upload_options": { + "region": "eu-central-1" + } + }] + } + }`, test_distro.TestDistroName, test_distro.TestArch3Name), http.StatusCreated, ` + { + "href": "/api/image-builder-composer/v2/compose", + "kind": "ComposeId" + }`, "id") + + // With both upload options for default target and a specific target + test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(` + { + "distribution": "%s", + "image_request":{ + "architecture": "%s", + "image_type": "aws", + "repositories": [{ + "baseurl": "somerepo.org", + "rhsm": false + }], + "upload_targets": [{ + "type": "org.osbuild.aws", + "upload_options": { + "region": "eu-central-1" + } + }], + "upload_options": { + "region": "eu-central-1" + } + } + }`, test_distro.TestDistroName, test_distro.TestArch3Name), http.StatusCreated, ` + { + "href": "/api/image-builder-composer/v2/compose", + "kind": "ComposeId" + }`, "id") + + // Koji test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(` { "distribution": "%s", @@ -360,6 +414,36 @@ func TestCompose(t *testing.T) { "kind": "ComposeId" }`, "id") + // ref only with secondary pulp upload target + test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(` + { + "distribution": "%s", + "image_request":{ + "architecture": "%s", + "image_type": "edge-commit", + "repositories": [{ + "baseurl": "somerepo.org", + "rhsm": false + }], + "upload_targets": [{ + "type": "org.osbuild.pulp.ostree", + "upload_options": { + "basepath": "edge/rhel10" + } + }], + "upload_options": { + "region": "eu-central-1" + }, + "ostree": { + "ref": "rhel/10/x86_64/edge" + } + } + }`, test_distro.TestDistroName, test_distro.TestArch3Name), http.StatusCreated, ` + { + "href": "/api/image-builder-composer/v2/compose", + "kind": "ComposeId" + }`, "id") + // url only (must use ostreeRepoDefault for default ref) test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(` {