feat(core,storage,oci,registry-config): add streaming response support and configurable registry URLs across protocols

This commit is contained in:
2026-03-24 22:59:37 +00:00
parent 1f0acf2825
commit 7da1a35efe
42 changed files with 4179 additions and 5396 deletions

View File

@@ -1,5 +1,6 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import { SmartRegistry } from '../ts/index.js';
import { streamToBuffer, streamToJson } from '../ts/core/helpers.stream.js';
import { createTestRegistry, createTestTokens, calculateDigest, createTestManifest } from './helpers/registry.js';
let registry: SmartRegistry;
@@ -113,8 +114,9 @@ tap.test('OCI: should retrieve blob (GET /v2/{name}/blobs/{digest})', async () =
});
expect(response.status).toEqual(200);
expect(response.body).toBeInstanceOf(Buffer);
expect((response.body as Buffer).toString('utf-8')).toEqual('Hello from OCI test blob!');
const body = await streamToBuffer(response.body);
expect(body).toBeInstanceOf(Buffer);
expect(body.toString('utf-8')).toEqual('Hello from OCI test blob!');
expect(response.headers['Docker-Content-Digest']).toEqual(testBlobDigest);
});
@@ -152,9 +154,10 @@ tap.test('OCI: should retrieve manifest by tag (GET /v2/{name}/manifests/{refere
});
expect(response.status).toEqual(200);
expect(response.body).toBeInstanceOf(Buffer);
const body = await streamToBuffer(response.body);
expect(body).toBeInstanceOf(Buffer);
const manifest = JSON.parse((response.body as Buffer).toString('utf-8'));
const manifest = JSON.parse(body.toString('utf-8'));
expect(manifest.schemaVersion).toEqual(2);
expect(manifest.config.digest).toEqual(testConfigDigest);
expect(manifest.layers[0].digest).toEqual(testBlobDigest);
@@ -201,9 +204,9 @@ tap.test('OCI: should list tags (GET /v2/{name}/tags/list)', async () => {
});
expect(response.status).toEqual(200);
expect(response.body).toHaveProperty('tags');
const tagList = await streamToJson(response.body);
expect(tagList).toHaveProperty('tags');
const tagList = response.body as any;
expect(tagList.name).toEqual('test-repo');
expect(tagList.tags).toBeInstanceOf(Array);
expect(tagList.tags).toContain('v1.0.0');
@@ -222,7 +225,8 @@ tap.test('OCI: should handle pagination for tag list', async () => {
});
expect(response.status).toEqual(200);
expect(response.body).toHaveProperty('tags');
const body = await streamToJson(response.body);
expect(body).toHaveProperty('tags');
});
tap.test('OCI: should return 404 for non-existent blob', async () => {
@@ -236,7 +240,8 @@ tap.test('OCI: should return 404 for non-existent blob', async () => {
});
expect(response.status).toEqual(404);
expect(response.body).toHaveProperty('errors');
const body = await streamToJson(response.body);
expect(body).toHaveProperty('errors');
});
tap.test('OCI: should return 404 for non-existent manifest', async () => {
@@ -251,7 +256,8 @@ tap.test('OCI: should return 404 for non-existent manifest', async () => {
});
expect(response.status).toEqual(404);
expect(response.body).toHaveProperty('errors');
const body = await streamToJson(response.body);
expect(body).toHaveProperty('errors');
});
tap.test('OCI: should delete manifest (DELETE /v2/{name}/manifests/{digest})', async () => {