Skip to content

Commit 5209d43

Browse files
committed
test: add end-to-end upload integration test for presigned URL flow
Adds a new integration test that exercises the full upload pipeline for both public and private files using real MinIO: - requestUploadUrl → PUT to presigned URL → confirmUpload - Tests public bucket (is_public=true) and private bucket (is_public=false) - Tests content-hash deduplication - Uses lazy S3 bucket provisioning (from PR #969) - Uses per-database bucket naming (from PR #968) Includes seed fixtures (simple-seed-storage) that create: - jwt_private schema with current_database_id() function - metaschema tables (database, schema, table, field) - services tables (apis, domains, api_schemas) - storage_module config row - storage tables (buckets, files, upload_requests) - Two buckets: public and private
1 parent 49ef663 commit 5209d43

4 files changed

Lines changed: 828 additions & 0 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
-- Schema creation for simple-seed-storage test scenario
2+
-- Creates the app schema with storage tables (buckets, files, upload_requests)
3+
4+
-- Create app schemas
5+
CREATE SCHEMA IF NOT EXISTS "simple-storage-public";
6+
7+
-- Grant schema usage
8+
GRANT USAGE ON SCHEMA "simple-storage-public" TO administrator, authenticated, anonymous;
9+
10+
-- Set default privileges
11+
ALTER DEFAULT PRIVILEGES IN SCHEMA "simple-storage-public"
12+
GRANT ALL ON TABLES TO administrator;
13+
ALTER DEFAULT PRIVILEGES IN SCHEMA "simple-storage-public"
14+
GRANT USAGE ON SEQUENCES TO administrator, authenticated;
15+
ALTER DEFAULT PRIVILEGES IN SCHEMA "simple-storage-public"
16+
GRANT ALL ON FUNCTIONS TO administrator, authenticated, anonymous;
17+
18+
-- =====================================================
19+
-- STORAGE TABLES (mirroring what the storage module generator creates)
20+
-- =====================================================
21+
22+
-- Buckets table
23+
CREATE TABLE IF NOT EXISTS "simple-storage-public".buckets (
24+
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
25+
key text NOT NULL,
26+
type text NOT NULL DEFAULT 'private',
27+
is_public boolean NOT NULL DEFAULT false,
28+
owner_id uuid,
29+
allowed_mime_types text[] NULL,
30+
max_file_size bigint NULL,
31+
created_at timestamptz DEFAULT now(),
32+
updated_at timestamptz DEFAULT now(),
33+
UNIQUE (key)
34+
);
35+
36+
COMMENT ON TABLE "simple-storage-public".buckets IS E'@storageBuckets\nStorage buckets table';
37+
38+
-- Files table
39+
CREATE TABLE IF NOT EXISTS "simple-storage-public".files (
40+
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
41+
bucket_id uuid NOT NULL REFERENCES "simple-storage-public".buckets(id),
42+
key text NOT NULL,
43+
content_type text NOT NULL,
44+
content_hash text,
45+
size bigint,
46+
filename text,
47+
owner_id uuid,
48+
is_public boolean NOT NULL DEFAULT false,
49+
status text NOT NULL DEFAULT 'pending',
50+
created_at timestamptz DEFAULT now(),
51+
updated_at timestamptz DEFAULT now()
52+
);
53+
54+
COMMENT ON TABLE "simple-storage-public".files IS E'@storageFiles\nStorage files table';
55+
56+
-- Upload requests table
57+
CREATE TABLE IF NOT EXISTS "simple-storage-public".upload_requests (
58+
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
59+
file_id uuid NOT NULL REFERENCES "simple-storage-public".files(id),
60+
bucket_id uuid NOT NULL REFERENCES "simple-storage-public".buckets(id),
61+
key text NOT NULL,
62+
content_type text NOT NULL,
63+
content_hash text,
64+
size bigint,
65+
status text NOT NULL DEFAULT 'issued',
66+
expires_at timestamptz,
67+
confirmed_at timestamptz,
68+
created_at timestamptz DEFAULT now(),
69+
updated_at timestamptz DEFAULT now()
70+
);
71+
72+
-- Grant table permissions (allow anonymous to do CRUD for tests — no RLS)
73+
GRANT SELECT, INSERT, UPDATE, DELETE ON "simple-storage-public".buckets TO administrator, authenticated, anonymous;
74+
GRANT SELECT, INSERT, UPDATE, DELETE ON "simple-storage-public".files TO administrator, authenticated, anonymous;
75+
GRANT SELECT, INSERT, UPDATE, DELETE ON "simple-storage-public".upload_requests TO administrator, authenticated, anonymous;

0 commit comments

Comments
 (0)