diff --git a/cmd/osbuild-auth-tests/main_test.go b/cmd/osbuild-auth-tests/main_test.go index 303cb71f1..79ca912b6 100644 --- a/cmd/osbuild-auth-tests/main_test.go +++ b/cmd/osbuild-auth-tests/main_test.go @@ -192,7 +192,7 @@ func TestKojiAPIAuth(t *testing.T) { require.NoError(t, err) defer ckp.remove() - testRoute(t, "https://localhost/status", ckp, c.success) + testRoute(t, "https://localhost/api/composer-koji/v1/status", ckp, c.success) }) } }) @@ -208,7 +208,7 @@ func TestKojiAPIAuth(t *testing.T) { require.NoError(t, err) defer ckp.remove() - testRoute(t, "https://localhost/status", ckp, false) + testRoute(t, "https://localhost/api/composer-koji/v1/status", ckp, false) }) t.Run("self-signed certificate", func(t *testing.T) { @@ -217,7 +217,7 @@ func TestKojiAPIAuth(t *testing.T) { require.NoError(t, err) defer ckp.remove() - testRoute(t, "https://localhost/status", ckp, false) + testRoute(t, "https://localhost/api/composer-koji/v1/status", ckp, false) }) } diff --git a/internal/kojiapi/api/api.go b/internal/kojiapi/api/api.go index b5f2978c4..4f4e8dccf 100644 --- a/internal/kojiapi/api/api.go +++ b/internal/kojiapi/api/api.go @@ -1,3 +1,5 @@ //go:generate go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen -package=api -generate types,server -o api.gen.go openapi.yml package api + +const BasePath = "/api/composer-koji/v1" diff --git a/internal/kojiapi/api/openapi.yml b/internal/kojiapi/api/openapi.yml index 3ebc6710d..ab2e1f190 100644 --- a/internal/kojiapi/api/openapi.yml +++ b/internal/kojiapi/api/openapi.yml @@ -1,11 +1,13 @@ openapi: 3.0.1 info: - version: '1' title: OSBuild Composer - Koji + version: '1' description: Service to build and push images to Koji. license: name: Apache 2.0 url: 'https://www.apache.org/licenses/LICENSE-2.0.html' +servers: + - url: /api/composer-koji/v1 paths: /status: get: diff --git a/internal/kojiapi/server.go b/internal/kojiapi/server.go index 1b2337ac2..f816ca52b 100644 --- a/internal/kojiapi/server.go +++ b/internal/kojiapi/server.go @@ -44,7 +44,7 @@ func NewServer(logger *log.Logger, workers *worker.Server, rpmMetadata rpmmd.RPM e.Binder = binder{} e.StdLogger = logger - api.RegisterHandlers(e, &apiHandlers{s}) + api.RegisterHandlers(e.Group(api.BasePath), &apiHandlers{s}) s.server = &http.Server{ ErrorLog: logger, diff --git a/test/image-tests/koji-compose.py b/test/image-tests/koji-compose.py index 943c24061..f60efe7ac 100755 --- a/test/image-tests/koji-compose.py +++ b/test/image-tests/koji-compose.py @@ -42,7 +42,7 @@ def main(distro): cr = compose_request(distro, "https://localhost:4343/kojihub") print(json.dumps(cr)) - r = requests.post("https://localhost/compose", json=cr, + r = requests.post("https://localhost/api/composer-koji/v1/compose", json=cr, cert=("/etc/osbuild-composer/worker-crt.pem", "/etc/osbuild-composer/worker-key.pem"), verify="/etc/osbuild-composer/ca-crt.pem") if r.status_code != 201: @@ -54,7 +54,7 @@ def main(distro): compose_id = r.json()["id"] while True: - r = requests.get(f"https://localhost/compose/{compose_id}", + r = requests.get(f"https://localhost/api/composer-koji/v1/compose/{compose_id}", cert=("/etc/osbuild-composer/worker-crt.pem", "/etc/osbuild-composer/worker-key.pem"), verify="/etc/osbuild-composer/ca-crt.pem") if r.status_code != 200: