test: add storage URL format validation test
- Add test to validate storageKey format: {org}/{proj}/img/{uuid}
- Add test to validate storageUrl format matches CDN pattern
- Verify UUID in storage path matches image.id
- Update 06-edge-cases.rest to use new path format
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
3404743a84
commit
e1c2395d5d
|
|
@ -42,6 +42,37 @@ async function main() {
|
|||
log.detail('Source', response.source);
|
||||
});
|
||||
|
||||
// Test 1.5: Validate storage path format
|
||||
await runTest('Storage path format validation', async () => {
|
||||
// Get uploaded image
|
||||
const result = await api(`${endpoints.images}/${testContext.uploadedImageId}`);
|
||||
const image = result.data.data;
|
||||
|
||||
// Validate storageKey format: {orgSlug}/{projectSlug}/img/{uuid}
|
||||
const keyRegex = /^[\w-]+\/[\w-]+\/img\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
||||
if (!keyRegex.test(image.storageKey)) {
|
||||
throw new Error(`Invalid storageKey format: ${image.storageKey}. Expected: {org}/{proj}/img/{uuid}`);
|
||||
}
|
||||
|
||||
// Validate storageUrl format: https://.../img/{uuid}
|
||||
const urlRegex = /^https?:\/\/[^\/]+\/[\w-]+\/[\w-]+\/img\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
||||
if (!urlRegex.test(image.storageUrl)) {
|
||||
throw new Error(`Invalid storageUrl format: ${image.storageUrl}. Expected: https://.../img/{uuid}`);
|
||||
}
|
||||
|
||||
// Verify imageId matches the UUID in path
|
||||
const pathParts = image.storageKey.split('/');
|
||||
const uuidFromPath = pathParts[3];
|
||||
if (uuidFromPath !== image.id) {
|
||||
throw new Error(`storageKey UUID (${uuidFromPath}) doesn't match image.id (${image.id})`);
|
||||
}
|
||||
|
||||
log.detail('storageKey', image.storageKey);
|
||||
log.detail('storageUrl', image.storageUrl);
|
||||
log.detail('UUID in path = image.id', '✓');
|
||||
log.detail('Format', '{org}/{proj}/img/{uuid}');
|
||||
});
|
||||
|
||||
// Test 2: Upload image without alias
|
||||
await runTest('Upload image without alias', async () => {
|
||||
const fixturePath = join(__dirname, config.fixturesDir, 'test-image.png');
|
||||
|
|
|
|||
|
|
@ -236,11 +236,12 @@ X-API-Key: {{apiKey}}
|
|||
|
||||
### Step 6.1: CDN image by path (if implemented)
|
||||
# @name cdnImage
|
||||
GET {{base}}/api/v1/cdn/default/test-project/generated/2024-01/test.jpg
|
||||
# New format: {org}/{project}/img/{uuid}
|
||||
GET {{base}}/api/v1/cdn/default/test-project/img/00000000-0000-0000-0000-000000000000
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
###
|
||||
# Note: Endpoint structure check only - actual paths depend on storage
|
||||
# Note: Endpoint structure check only - uses placeholder UUID
|
||||
|
||||
### Step 6.2: Health check
|
||||
# @name healthCheck
|
||||
|
|
|
|||
Loading…
Reference in New Issue