mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-07-08 21:37:49 +02:00
feat(safari): multi-profile support (#581)
* feat(safari): multi-profile support
This commit is contained in:
@@ -3,6 +3,7 @@ package safari
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -83,3 +84,38 @@ func createTestDB(t *testing.T, name string, schemas []string, inserts ...string
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SafariTabs.db fixtures
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// tabRow describes one profile entry to stamp into the fake SafariTabs.db.
|
||||
type tabRow struct {
|
||||
uuid string
|
||||
title string
|
||||
}
|
||||
|
||||
// writeSafariTabsDB creates a minimal SafariTabs.db at path containing only
|
||||
// the bookmarks columns discoverSafariProfiles reads. Every row gets
|
||||
// subtype=2 (profile record) so the production query picks it up.
|
||||
func writeSafariTabsDB(t *testing.T, path string, rows []tabRow) {
|
||||
t.Helper()
|
||||
require.NoError(t, os.MkdirAll(filepath.Dir(path), 0o755))
|
||||
|
||||
db, err := sql.Open("sqlite", path)
|
||||
require.NoError(t, err)
|
||||
defer db.Close()
|
||||
|
||||
_, err = db.Exec(`CREATE TABLE bookmarks (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
external_uuid TEXT,
|
||||
title TEXT,
|
||||
subtype INTEGER DEFAULT 0
|
||||
)`)
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, r := range rows {
|
||||
_, err = db.Exec(`INSERT INTO bookmarks (external_uuid, title, subtype) VALUES (?, ?, 2)`, r.uuid, r.title)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user