-
Notifications
You must be signed in to change notification settings - Fork 1
fix(storage): disable acl list objects for new buckets #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 173 additions & 0 deletions
173
packages/storage/src/test/bucket-create.integration.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| import { describe, it, expect, afterEach } from 'vitest'; | ||
| import { createBucket } from '../lib/bucket/create'; | ||
| import { listBuckets } from '../lib/bucket/list'; | ||
| import { removeBucket } from '../lib/bucket/remove'; | ||
| import { shouldSkipIntegrationTests } from './setup'; | ||
| import { config } from '../lib/config'; | ||
|
|
||
| const skipTests = shouldSkipIntegrationTests(); | ||
|
|
||
| const testBucket = (suffix: string) => | ||
| `test-create-${suffix}-${Date.now()}`.toLowerCase(); | ||
|
|
||
| describe.skipIf(skipTests)('createBucket Integration Tests', () => { | ||
| const bucketsToCleanup: string[] = []; | ||
|
|
||
| afterEach(async () => { | ||
| for (const bucket of bucketsToCleanup) { | ||
| await removeBucket(bucket, { force: true, config }); | ||
| } | ||
| bucketsToCleanup.length = 0; | ||
| }); | ||
|
|
||
| it('should create a bucket and be listable', async () => { | ||
| const name = testBucket('basic'); | ||
| bucketsToCleanup.push(name); | ||
|
|
||
| const result = await createBucket(name, { config }); | ||
|
|
||
| expect(result.error).toBeUndefined(); | ||
| expect(result.data).toBeDefined(); | ||
| expect(result.data?.hasForks).toBe(false); | ||
| expect(result.data?.isSnapshotEnabled).toBe(false); | ||
|
|
||
| const { data } = await listBuckets({ config }); | ||
| expect(data?.buckets.some((b) => b.name === name)).toBe(true); | ||
| }); | ||
designcode marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| it('should create a public bucket with directory listing disabled', async () => { | ||
| const name = testBucket('public'); | ||
| bucketsToCleanup.push(name); | ||
|
|
||
| const result = await createBucket(name, { | ||
| access: 'public', | ||
| config, | ||
| }); | ||
|
|
||
| expect(result.error).toBeUndefined(); | ||
| expect(result.data).toBeDefined(); | ||
|
|
||
| // Verify directory listing is disabled: unauthenticated ListObjects | ||
| // should return 403 even though the bucket is public | ||
| const endpoint = config.endpoint || 'https://t3.storage.dev'; | ||
| const resp = await fetch(`${endpoint}/${name}?list-type=2`); | ||
| expect(resp.status).toBe(403); | ||
| }); | ||
|
|
||
| it('should create a bucket with snapshot enabled', async () => { | ||
| const name = testBucket('snap'); | ||
| bucketsToCleanup.push(name); | ||
|
|
||
| const result = await createBucket(name, { | ||
| enableSnapshot: true, | ||
| config, | ||
| }); | ||
|
|
||
| expect(result.error).toBeUndefined(); | ||
| expect(result.data?.isSnapshotEnabled).toBe(true); | ||
| }); | ||
|
|
||
| it('should create a fork from a source bucket', async () => { | ||
| const sourceName = testBucket('fork-src'); | ||
| const forkName = testBucket('fork-dst'); | ||
| bucketsToCleanup.push(sourceName, forkName); | ||
|
|
||
| await createBucket(sourceName, { | ||
| enableSnapshot: true, | ||
| config, | ||
| }); | ||
|
|
||
| const result = await createBucket(forkName, { | ||
| sourceBucketName: sourceName, | ||
| config, | ||
| }); | ||
|
|
||
| expect(result.error).toBeUndefined(); | ||
| expect(result.data?.sourceBucketName).toBe(sourceName); | ||
| }); | ||
|
|
||
| it('should accept all location types', async () => { | ||
| const locations = [ | ||
| { | ||
| suffix: 'single', | ||
| opts: { type: 'single' as const, values: 'iad' as const }, | ||
| }, | ||
| { | ||
| suffix: 'multi', | ||
| opts: { type: 'multi' as const, values: 'usa' as const }, | ||
| }, | ||
| { | ||
| suffix: 'dual', | ||
| opts: { | ||
| type: 'dual' as const, | ||
| values: ['iad', 'fra'] as ['iad', 'fra'], | ||
| }, | ||
| }, | ||
| { suffix: 'global', opts: { type: 'global' as const } }, | ||
| ]; | ||
|
|
||
| for (const { suffix, opts } of locations) { | ||
| const name = testBucket(`loc-${suffix}`); | ||
| bucketsToCleanup.push(name); | ||
|
|
||
| const result = await createBucket(name, { | ||
| locations: opts, | ||
| config, | ||
| }); | ||
|
|
||
| expect(result.error, `${suffix} location failed`).toBeUndefined(); | ||
| expect(result.data).toBeDefined(); | ||
| } | ||
| }); | ||
|
|
||
| it('should create a bucket with all options combined', async () => { | ||
| const name = testBucket('combined'); | ||
| bucketsToCleanup.push(name); | ||
|
|
||
| const result = await createBucket(name, { | ||
| access: 'public', | ||
| defaultTier: 'STANDARD_IA', | ||
| enableSnapshot: true, | ||
| locations: { type: 'single', values: 'iad' }, | ||
| config, | ||
| }); | ||
|
|
||
| expect(result.error).toBeUndefined(); | ||
| expect(result.data).toBeDefined(); | ||
| expect(result.data?.isSnapshotEnabled).toBe(true); | ||
| }); | ||
|
|
||
| // ── Validation errors ── | ||
|
|
||
| it('should return error for invalid region', async () => { | ||
| const result = await createBucket(testBucket('bad-region'), { | ||
| region: 'invalid-region', | ||
| config, | ||
| }); | ||
|
|
||
| expect(result.error).toBeDefined(); | ||
| expect(result.error?.message).toContain('Invalid regions specified'); | ||
| }); | ||
|
|
||
| it('should return error for invalid location', async () => { | ||
| const result = await createBucket(testBucket('bad-loc'), { | ||
| locations: { type: 'single', values: 'invalid' as 'iad' }, | ||
| config, | ||
| }); | ||
|
|
||
| expect(result.error).toBeDefined(); | ||
| expect(result.error?.message).toContain('Invalid single-region location'); | ||
| }); | ||
|
|
||
| it('should return error when sourceBucketSnapshot is provided without sourceBucketName', async () => { | ||
| const result = await createBucket(testBucket('snap-no-src'), { | ||
| sourceBucketSnapshot: 'snap-123', | ||
| config, | ||
| }); | ||
|
|
||
| expect(result.error).toBeDefined(); | ||
| expect(result.error?.message).toBe( | ||
| 'sourceBucketName is required when sourceBucketSnapshot is provided' | ||
| ); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.