diff --git a/backend/internal/common/env_config.go b/backend/internal/common/env_config.go index ffd8c154..687b1c24 100644 --- a/backend/internal/common/env_config.go +++ b/backend/internal/common/env_config.go @@ -168,7 +168,7 @@ func ValidateEnvConfig(config *EnvConfigSchema) error { switch config.FileBackend { case "s3", "database": // All good, these are valid values - case "", "fs": + case "", "filesystem": if config.UploadPath == "" { config.UploadPath = defaultFsUploadPath } diff --git a/backend/internal/common/env_config_test.go b/backend/internal/common/env_config_test.go index 266e5437..22044a60 100644 --- a/backend/internal/common/env_config_test.go +++ b/backend/internal/common/env_config_test.go @@ -159,7 +159,7 @@ func TestParseEnvConfig(t *testing.T) { t.Setenv("APP_URL", "http://localhost:3000") t.Setenv("AUDIT_LOG_RETENTION_DAYS", "0") - err := parseEnvConfig() + err := parseAndValidateEnvConfig(t) require.Error(t, err) assert.ErrorContains(t, err, "AUDIT_LOG_RETENTION_DAYS must be greater than 0") }) diff --git a/backend/internal/service/export_service.go b/backend/internal/service/export_service.go index 31e2ceae..67d18111 100644 --- a/backend/internal/service/export_service.go +++ b/backend/internal/service/export_service.go @@ -56,7 +56,7 @@ func (s *ExportService) extractDatabase() (DatabaseExport, error) { Tables: map[string][]map[string]any{}, // These tables need to be inserted in a specific order because of foreign key constraints // Not all tables are listed here, because not all tables are order-dependent - TableOrder: []string{"users", "user_groups", "oidc_clients"}, + TableOrder: []string{"users", "user_groups", "oidc_clients", "signup_tokens"}, } for table := range schema { diff --git a/backend/internal/service/import_service.go b/backend/internal/service/import_service.go index 1c0ec7cf..278c0b15 100644 --- a/backend/internal/service/import_service.go +++ b/backend/internal/service/import_service.go @@ -61,7 +61,7 @@ func (s *ImportService) ImportFromZip(ctx context.Context, r *zip.Reader) error // ImportDatabase only imports the database data from the given DatabaseExport struct. func (s *ImportService) ImportDatabase(dbData DatabaseExport) error { - err := s.resetSchema(dbData.Version, dbData.Provider) + err := s.resetSchema(dbData.Version) if err != nil { return err } @@ -144,7 +144,7 @@ func (s *ImportService) importUploads(ctx context.Context, files []*zip.File) er } // resetSchema drops the existing schema and migrates to the target version -func (s *ImportService) resetSchema(targetVersion uint, exportDbProvider string) error { +func (s *ImportService) resetSchema(targetVersion uint) error { sqlDb, err := s.db.DB() if err != nil { return fmt.Errorf("failed to get sql.DB: %w", err) @@ -155,11 +155,19 @@ func (s *ImportService) resetSchema(targetVersion uint, exportDbProvider string) return fmt.Errorf("failed to get migrate instance: %w", err) } + if s.db.Name() == "sqlite" { + s.db.Exec("PRAGMA foreign_keys = OFF;") + } + err = m.Drop() if err != nil { return fmt.Errorf("failed to drop existing schema: %w", err) } + if s.db.Name() == "sqlite" { + defer s.db.Exec("PRAGMA foreign_keys = ON;") + } + // Needs to be called again to re-create the schema_migrations table m, err = utils.GetEmbeddedMigrateInstance(sqlDb) if err != nil { diff --git a/backend/resources/migrations/postgres/20251117141000_export_normalization.down.sql b/backend/resources/migrations/postgres/20251117141000_export_normalization.down.sql deleted file mode 100644 index d34341f0..00000000 --- a/backend/resources/migrations/postgres/20251117141000_export_normalization.down.sql +++ /dev/null @@ -1 +0,0 @@ --- No-op in Postgres \ No newline at end of file diff --git a/backend/resources/migrations/postgres/20251117141000_export_normalization.up.sql b/backend/resources/migrations/postgres/20251117141000_export_normalization.up.sql deleted file mode 100644 index d34341f0..00000000 --- a/backend/resources/migrations/postgres/20251117141000_export_normalization.up.sql +++ /dev/null @@ -1 +0,0 @@ --- No-op in Postgres \ No newline at end of file diff --git a/backend/resources/migrations/postgres/20251217141000_v2_export_normalization.down.sql b/backend/resources/migrations/postgres/20251217141000_v2_export_normalization.down.sql new file mode 100644 index 00000000..b19a5a75 --- /dev/null +++ b/backend/resources/migrations/postgres/20251217141000_v2_export_normalization.down.sql @@ -0,0 +1,3 @@ +-- This migration is part of v2 + +-- No-op in Postgres diff --git a/backend/resources/migrations/postgres/20251217141000_v2_export_normalization.up.sql b/backend/resources/migrations/postgres/20251217141000_v2_export_normalization.up.sql new file mode 100644 index 00000000..b19a5a75 --- /dev/null +++ b/backend/resources/migrations/postgres/20251217141000_v2_export_normalization.up.sql @@ -0,0 +1,3 @@ +-- This migration is part of v2 + +-- No-op in Postgres diff --git a/backend/resources/migrations/sqlite/20251117141000_export_normalization.down.sql b/backend/resources/migrations/sqlite/20251217141000_v2_export_normalization.down.sql similarity index 98% rename from backend/resources/migrations/sqlite/20251117141000_export_normalization.down.sql rename to backend/resources/migrations/sqlite/20251217141000_v2_export_normalization.down.sql index 939b3456..c68d3ee6 100644 --- a/backend/resources/migrations/sqlite/20251117141000_export_normalization.down.sql +++ b/backend/resources/migrations/sqlite/20251217141000_v2_export_normalization.down.sql @@ -1,3 +1,5 @@ +-- This migration is part of v2 + PRAGMA foreign_keys = OFF; BEGIN; diff --git a/backend/resources/migrations/sqlite/20251117141000_export_normalization.up.sql b/backend/resources/migrations/sqlite/20251217141000_v2_export_normalization.up.sql similarity index 99% rename from backend/resources/migrations/sqlite/20251117141000_export_normalization.up.sql rename to backend/resources/migrations/sqlite/20251217141000_v2_export_normalization.up.sql index b280d370..1eae6c6f 100644 --- a/backend/resources/migrations/sqlite/20251117141000_export_normalization.up.sql +++ b/backend/resources/migrations/sqlite/20251217141000_v2_export_normalization.up.sql @@ -1,3 +1,5 @@ +-- This migration is part of v2 + PRAGMA foreign_keys = OFF; BEGIN; diff --git a/frontend/src/routes/settings/audit-log/global/+page.svelte b/frontend/src/routes/settings/audit-log/global/+page.svelte index ba1c918e..4ba7e1a8 100644 --- a/frontend/src/routes/settings/audit-log/global/+page.svelte +++ b/frontend/src/routes/settings/audit-log/global/+page.svelte @@ -36,9 +36,7 @@ {m.global_audit_log()} - {m.see_all_recent_account_activities()} + {m.see_all_recent_account_activities()}
diff --git a/tests/resources/export/database.json b/tests/resources/export/database.json index 1461420a..ce989cef 100644 --- a/tests/resources/export/database.json +++ b/tests/resources/export/database.json @@ -1,7 +1,7 @@ { "provider": "sqlite", - "version": 20251117141000, - "tableOrder": ["users", "user_groups", "oidc_clients"], + "version": 20251219000000, + "tableOrder": ["users", "user_groups", "oidc_clients", "signup_tokens"], "tables": { "api_keys": [ { @@ -63,6 +63,7 @@ "dark_image_type": null, "id": "3654a746-35d4-4321-ac61-0bdcff2b4055", "image_type": "png", + "is_group_restricted": false, "is_public": false, "launch_url": "https://nextcloud.local", "logout_callback_urls": "WyJodHRwOi8vbmV4dGNsb3VkL2F1dGgvbG9nb3V0L2NhbGxiYWNrIl0=", @@ -79,6 +80,7 @@ "dark_image_type": null, "id": "606c7782-f2b1-49e5-8ea9-26eb1b06d018", "image_type": null, + "is_group_restricted": true, "is_public": false, "launch_url": null, "logout_callback_urls": "bnVsbA==", @@ -95,6 +97,7 @@ "dark_image_type": null, "id": "7c21a609-96b5-4011-9900-272b8d31a9d1", "image_type": null, + "is_group_restricted": true, "is_public": false, "launch_url": null, "logout_callback_urls": "WyJodHRwOi8vdGFpbHNjYWxlL2F1dGgvbG9nb3V0L2NhbGxiYWNrIl0=", @@ -111,6 +114,7 @@ "dark_image_type": null, "id": "c48232ff-ff65-45ed-ae96-7afa8a9b443b", "image_type": null, + "is_group_restricted": false, "is_public": false, "launch_url": null, "logout_callback_urls": "bnVsbA==", @@ -143,6 +147,7 @@ "expires_at": "2025-11-25T13:39:02Z", "id": "bf877753-4ea4-4c9c-bbbd-e198bb201cb8", "token": "HPe6k6uiDRRVuAQV", + "device_token": null, "user_id": "f4b89dc2-62fb-46bf-9f5f-c34f4eafe93e" }, { @@ -150,6 +155,7 @@ "expires_at": "2025-11-25T12:39:01Z", "id": "d3afae24-fe2d-4a98-abec-cf0b8525096a", "token": "YCGDtftvsvYWiXd0", + "device_token": null, "user_id": "f4b89dc2-62fb-46bf-9f5f-c34f4eafe93e" }, { @@ -157,6 +163,7 @@ "expires_at": "2025-11-25T13:39:02Z", "id": "defd5164-9d9b-4228-bbce-708e33f49360", "token": "one-time-token", + "device_token": null, "user_id": "f4b89dc2-62fb-46bf-9f5f-c34f4eafe93e" } ], @@ -194,6 +201,12 @@ "usage_limit": 1 } ], + "signup_tokens_user_groups": [ + { + "signup_token_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + "user_group_id": "c7ae7c01-28a3-4f3c-9572-1ee734ea8368" + } + ], "user_authorized_oidc_clients": [ { "client_id": "3654a746-35d4-4321-ac61-0bdcff2b4055", diff --git a/tests/specs/application-configuration.spec.ts b/tests/specs/application-configuration.spec.ts index 998006d0..6706f5d2 100644 --- a/tests/specs/application-configuration.spec.ts +++ b/tests/specs/application-configuration.spec.ts @@ -126,7 +126,9 @@ test.describe('Update application images', () => { await page.getByLabel('Light Mode Logo').setInputFiles('resources/images/pingvin-share-logo.png'); await page.getByLabel('Dark Mode Logo').setInputFiles('resources/images/cloud-logo.png'); await page.getByLabel('Email Logo').setInputFiles('resources/images/pingvin-share-logo.png'); - await page.getByLabel('Default Profile Picture').setInputFiles('resources/images/pingvin-share-logo.png'); + await page + .getByLabel('Default Profile Picture') + .setInputFiles('resources/images/pingvin-share-logo.png'); await page.getByLabel('Background Image').setInputFiles('resources/images/clouds.jpg'); await page.getByRole('button', { name: 'Save' }).last().click(); diff --git a/tests/specs/cli.spec.ts b/tests/specs/cli.spec.ts index b7c8e1b9..e6116575 100644 --- a/tests/specs/cli.spec.ts +++ b/tests/specs/cli.spec.ts @@ -287,7 +287,6 @@ function runExportToStdout(): Buffer { '--path', '-' ]); - fs.writeFileSync('export-stdout.txt', res); return res; }