Files
HackBrowserData/keys/retriever_darwin_test.go
T
moonD4rk c951d7ac16 refactor(keys): extract master-key package to top-level keys/
Master-key acquisition and the cross-host dump format are a concern distinct from the raw crypto primitives, so crypto/keyretriever moves to an importable top-level keys/. KeyRetriever→Retriever drops the keys.KeyRetriever stutter.
2026-06-01 01:02:45 +08:00

42 lines
1.1 KiB
Go

//go:build darwin
package keys
import (
"testing"
"github.com/moond4rk/keychainbreaker"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestFindStorageKey_Found(t *testing.T) {
records := []keychainbreaker.GenericPassword{
{Account: "Chrome", Password: []byte("mock-secret")},
{Account: "Brave", Password: []byte("brave-secret")},
}
key, err := findStorageKey(records, "Chrome")
require.NoError(t, err)
assert.Equal(t, darwinParams.deriveKey([]byte("mock-secret")), key)
}
func TestFindStorageKey_NotFound(t *testing.T) {
records := []keychainbreaker.GenericPassword{
{Account: "Chrome", Password: []byte("mock-secret")},
}
key, err := findStorageKey(records, "Firefox")
require.Error(t, err)
assert.Nil(t, key)
assert.ErrorIs(t, err, errStorageNotFound)
}
func TestKeychainPasswordRetriever_EmptyPassword(t *testing.T) {
r := &KeychainPasswordRetriever{Password: ""}
key, err := r.RetrieveKey(Hints{KeychainLabel: "Chrome"})
require.Error(t, err)
assert.Nil(t, key)
assert.Contains(t, err.Error(), "keychain password not provided")
}