fix(oci): remove /v2/ from internal route patterns and make upstream apiPrefix configurable
The OCI handler had /v2/ baked into all regex patterns and Location headers. When basePath was set to /v2 (as in stack.gallery), stripping it removed the prefix that patterns expected, causing all OCI endpoints to 404. Now patterns match on bare paths after basePath stripping, working correctly regardless of the basePath value. Also adds configurable apiPrefix to OCI upstream class (default /v2) for registries behind reverse proxies with custom path prefixes.
This commit is contained in:
@@ -24,7 +24,7 @@ tap.test('OCI: should create registry instance', async () => {
|
||||
tap.test('OCI: should handle version check (GET /v2/)', async () => {
|
||||
const response = await registry.handleRequest({
|
||||
method: 'GET',
|
||||
path: '/oci/v2/',
|
||||
path: '/oci/',
|
||||
headers: {},
|
||||
query: {},
|
||||
});
|
||||
@@ -36,7 +36,7 @@ tap.test('OCI: should handle version check (GET /v2/)', async () => {
|
||||
tap.test('OCI: should initiate blob upload (POST /v2/{name}/blobs/uploads/)', async () => {
|
||||
const response = await registry.handleRequest({
|
||||
method: 'POST',
|
||||
path: '/oci/v2/test-repo/blobs/uploads/',
|
||||
path: '/oci/test-repo/blobs/uploads/',
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
},
|
||||
@@ -53,7 +53,7 @@ tap.test('OCI: should upload blob in single PUT', async () => {
|
||||
|
||||
const response = await registry.handleRequest({
|
||||
method: 'POST',
|
||||
path: '/oci/v2/test-repo/blobs/uploads/',
|
||||
path: '/oci/test-repo/blobs/uploads/',
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
},
|
||||
@@ -73,7 +73,7 @@ tap.test('OCI: should upload config blob', async () => {
|
||||
|
||||
const response = await registry.handleRequest({
|
||||
method: 'POST',
|
||||
path: '/oci/v2/test-repo/blobs/uploads/',
|
||||
path: '/oci/test-repo/blobs/uploads/',
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
},
|
||||
@@ -90,7 +90,7 @@ tap.test('OCI: should upload config blob', async () => {
|
||||
tap.test('OCI: should check if blob exists (HEAD /v2/{name}/blobs/{digest})', async () => {
|
||||
const response = await registry.handleRequest({
|
||||
method: 'HEAD',
|
||||
path: `/oci/v2/test-repo/blobs/${testBlobDigest}`,
|
||||
path: `/oci/test-repo/blobs/${testBlobDigest}`,
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
},
|
||||
@@ -105,7 +105,7 @@ tap.test('OCI: should check if blob exists (HEAD /v2/{name}/blobs/{digest})', as
|
||||
tap.test('OCI: should retrieve blob (GET /v2/{name}/blobs/{digest})', async () => {
|
||||
const response = await registry.handleRequest({
|
||||
method: 'GET',
|
||||
path: `/oci/v2/test-repo/blobs/${testBlobDigest}`,
|
||||
path: `/oci/test-repo/blobs/${testBlobDigest}`,
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
},
|
||||
@@ -126,7 +126,7 @@ tap.test('OCI: should upload manifest (PUT /v2/{name}/manifests/{reference})', a
|
||||
|
||||
const response = await registry.handleRequest({
|
||||
method: 'PUT',
|
||||
path: '/oci/v2/test-repo/manifests/v1.0.0',
|
||||
path: '/oci/test-repo/manifests/v1.0.0',
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
'Content-Type': 'application/vnd.oci.image.manifest.v1+json',
|
||||
@@ -143,7 +143,7 @@ tap.test('OCI: should upload manifest (PUT /v2/{name}/manifests/{reference})', a
|
||||
tap.test('OCI: should retrieve manifest by tag (GET /v2/{name}/manifests/{reference})', async () => {
|
||||
const response = await registry.handleRequest({
|
||||
method: 'GET',
|
||||
path: '/oci/v2/test-repo/manifests/v1.0.0',
|
||||
path: '/oci/test-repo/manifests/v1.0.0',
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
Accept: 'application/vnd.oci.image.manifest.v1+json',
|
||||
@@ -163,7 +163,7 @@ tap.test('OCI: should retrieve manifest by tag (GET /v2/{name}/manifests/{refere
|
||||
tap.test('OCI: should retrieve manifest by digest (GET /v2/{name}/manifests/{digest})', async () => {
|
||||
const response = await registry.handleRequest({
|
||||
method: 'GET',
|
||||
path: `/oci/v2/test-repo/manifests/${testManifestDigest}`,
|
||||
path: `/oci/test-repo/manifests/${testManifestDigest}`,
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
Accept: 'application/vnd.oci.image.manifest.v1+json',
|
||||
@@ -178,7 +178,7 @@ tap.test('OCI: should retrieve manifest by digest (GET /v2/{name}/manifests/{dig
|
||||
tap.test('OCI: should check if manifest exists (HEAD /v2/{name}/manifests/{reference})', async () => {
|
||||
const response = await registry.handleRequest({
|
||||
method: 'HEAD',
|
||||
path: '/oci/v2/test-repo/manifests/v1.0.0',
|
||||
path: '/oci/test-repo/manifests/v1.0.0',
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
Accept: 'application/vnd.oci.image.manifest.v1+json',
|
||||
@@ -193,7 +193,7 @@ tap.test('OCI: should check if manifest exists (HEAD /v2/{name}/manifests/{refer
|
||||
tap.test('OCI: should list tags (GET /v2/{name}/tags/list)', async () => {
|
||||
const response = await registry.handleRequest({
|
||||
method: 'GET',
|
||||
path: '/oci/v2/test-repo/tags/list',
|
||||
path: '/oci/test-repo/tags/list',
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
},
|
||||
@@ -212,7 +212,7 @@ tap.test('OCI: should list tags (GET /v2/{name}/tags/list)', async () => {
|
||||
tap.test('OCI: should handle pagination for tag list', async () => {
|
||||
const response = await registry.handleRequest({
|
||||
method: 'GET',
|
||||
path: '/oci/v2/test-repo/tags/list',
|
||||
path: '/oci/test-repo/tags/list',
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
},
|
||||
@@ -228,7 +228,7 @@ tap.test('OCI: should handle pagination for tag list', async () => {
|
||||
tap.test('OCI: should return 404 for non-existent blob', async () => {
|
||||
const response = await registry.handleRequest({
|
||||
method: 'GET',
|
||||
path: '/oci/v2/test-repo/blobs/sha256:0000000000000000000000000000000000000000000000000000000000000000',
|
||||
path: '/oci/test-repo/blobs/sha256:0000000000000000000000000000000000000000000000000000000000000000',
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
},
|
||||
@@ -242,7 +242,7 @@ tap.test('OCI: should return 404 for non-existent blob', async () => {
|
||||
tap.test('OCI: should return 404 for non-existent manifest', async () => {
|
||||
const response = await registry.handleRequest({
|
||||
method: 'GET',
|
||||
path: '/oci/v2/test-repo/manifests/non-existent-tag',
|
||||
path: '/oci/test-repo/manifests/non-existent-tag',
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
Accept: 'application/vnd.oci.image.manifest.v1+json',
|
||||
@@ -257,7 +257,7 @@ tap.test('OCI: should return 404 for non-existent manifest', async () => {
|
||||
tap.test('OCI: should delete manifest (DELETE /v2/{name}/manifests/{digest})', async () => {
|
||||
const response = await registry.handleRequest({
|
||||
method: 'DELETE',
|
||||
path: `/oci/v2/test-repo/manifests/${testManifestDigest}`,
|
||||
path: `/oci/test-repo/manifests/${testManifestDigest}`,
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
},
|
||||
@@ -270,7 +270,7 @@ tap.test('OCI: should delete manifest (DELETE /v2/{name}/manifests/{digest})', a
|
||||
tap.test('OCI: should delete blob (DELETE /v2/{name}/blobs/{digest})', async () => {
|
||||
const response = await registry.handleRequest({
|
||||
method: 'DELETE',
|
||||
path: `/oci/v2/test-repo/blobs/${testBlobDigest}`,
|
||||
path: `/oci/test-repo/blobs/${testBlobDigest}`,
|
||||
headers: {
|
||||
Authorization: `Bearer ${ociToken}`,
|
||||
},
|
||||
@@ -283,7 +283,7 @@ tap.test('OCI: should delete blob (DELETE /v2/{name}/blobs/{digest})', async ()
|
||||
tap.test('OCI: should handle unauthorized requests', async () => {
|
||||
const response = await registry.handleRequest({
|
||||
method: 'GET',
|
||||
path: '/oci/v2/test-repo/manifests/v1.0.0',
|
||||
path: '/oci/test-repo/manifests/v1.0.0',
|
||||
headers: {
|
||||
// No authorization header
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user