mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-07-08 21:37:49 +02:00
feat: add CountEntries to skip decryption for list --detail (#562)
* feat: add CountEntries to skip decryption for list --detail (#549) * test: add CountEntries and countCategory tests at browser level * fix: address review feedback on CountRows and countLocalStorage * test: add CountRows unit tests
This commit is contained in:
@@ -7,8 +7,9 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestExtractExtensions(t *testing.T) {
|
||||
path := createTestJSON(t, "Secure Preferences", `{
|
||||
func setupExtensionJSON(t *testing.T) string {
|
||||
t.Helper()
|
||||
return createTestJSON(t, "Secure Preferences", `{
|
||||
"extensions": {
|
||||
"settings": {
|
||||
"abc123": {
|
||||
@@ -38,6 +39,10 @@ func TestExtractExtensions(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}`)
|
||||
}
|
||||
|
||||
func TestExtractExtensions(t *testing.T) {
|
||||
path := setupExtensionJSON(t)
|
||||
|
||||
got, err := extractExtensions(path)
|
||||
require.NoError(t, err)
|
||||
@@ -56,6 +61,45 @@ func TestExtractExtensions(t *testing.T) {
|
||||
assert.False(t, ids["system-ext"])
|
||||
}
|
||||
|
||||
func TestCountExtensions(t *testing.T) {
|
||||
path := setupExtensionJSON(t)
|
||||
|
||||
count, err := countExtensions(path)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 2, count) // system (5) and component (10) skipped
|
||||
}
|
||||
|
||||
func TestCountOperaExtensions(t *testing.T) {
|
||||
path := createTestJSON(t, "Secure Preferences", `{
|
||||
"extensions": {
|
||||
"opsettings": {
|
||||
"opera-ext-1": {
|
||||
"location": 1,
|
||||
"manifest": {"name": "Opera Ad Blocker", "version": "2.0.0"}
|
||||
},
|
||||
"system-ext": {
|
||||
"location": 5,
|
||||
"manifest": {"name": "System", "version": "1.0"}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`)
|
||||
|
||||
count, err := countOperaExtensions(path)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 1, count)
|
||||
}
|
||||
|
||||
func TestCountExtensions_Empty(t *testing.T) {
|
||||
path := createTestJSON(t, "Secure Preferences", `{
|
||||
"extensions": {"settings": {}}
|
||||
}`)
|
||||
|
||||
count, err := countExtensions(path)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 0, count)
|
||||
}
|
||||
|
||||
func TestExtractExtensions_NoManifestSkipped(t *testing.T) {
|
||||
path := createTestJSON(t, "Secure Preferences", `{
|
||||
"extensions": {
|
||||
|
||||
Reference in New Issue
Block a user