test(01-02): add failing tests for provider schema validation and registry
This commit is contained in:
23
pkg/engine/scanner_test.go
Normal file
23
pkg/engine/scanner_test.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package engine_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestShannonEntropy verifies the entropy function returns expected values.
|
||||
// Stub: will be implemented when entropy.go exists (Plan 04).
|
||||
func TestShannonEntropy(t *testing.T) {
|
||||
t.Skip("stub — implement after entropy.go exists")
|
||||
}
|
||||
|
||||
// TestKeywordPreFilter verifies Aho-Corasick pre-filter rejects files without keywords.
|
||||
// Stub: will be implemented when filter.go exists (Plan 04).
|
||||
func TestKeywordPreFilter(t *testing.T) {
|
||||
t.Skip("stub — implement after filter.go exists")
|
||||
}
|
||||
|
||||
// TestScannerPipeline verifies end-to-end scan of testdata returns expected findings.
|
||||
// Stub: will be implemented when engine.go exists (Plan 04).
|
||||
func TestScannerPipeline(t *testing.T) {
|
||||
t.Skip("stub — implement after engine.go exists")
|
||||
}
|
||||
58
pkg/providers/registry_test.go
Normal file
58
pkg/providers/registry_test.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package providers_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/salvacybersec/keyhunter/pkg/providers"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func TestRegistryLoad(t *testing.T) {
|
||||
reg, err := providers.NewRegistry()
|
||||
require.NoError(t, err)
|
||||
assert.GreaterOrEqual(t, len(reg.List()), 3, "expected at least 3 providers")
|
||||
}
|
||||
|
||||
func TestRegistryGet(t *testing.T) {
|
||||
reg, err := providers.NewRegistry()
|
||||
require.NoError(t, err)
|
||||
|
||||
p, ok := reg.Get("openai")
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, "openai", p.Name)
|
||||
assert.Equal(t, 1, p.Tier)
|
||||
|
||||
_, notOk := reg.Get("nonexistent-provider")
|
||||
assert.False(t, notOk)
|
||||
}
|
||||
|
||||
func TestRegistryStats(t *testing.T) {
|
||||
reg, err := providers.NewRegistry()
|
||||
require.NoError(t, err)
|
||||
|
||||
stats := reg.Stats()
|
||||
assert.GreaterOrEqual(t, stats.Total, 3)
|
||||
assert.GreaterOrEqual(t, stats.ByTier[1], 2)
|
||||
}
|
||||
|
||||
func TestAhoCorasickBuild(t *testing.T) {
|
||||
reg, err := providers.NewRegistry()
|
||||
require.NoError(t, err)
|
||||
|
||||
ac := reg.AC()
|
||||
matches := ac.FindAll("export OPENAI_API_KEY=sk-proj-abc")
|
||||
assert.NotEmpty(t, matches)
|
||||
|
||||
noMatches := ac.FindAll("hello world nothing here")
|
||||
assert.Empty(t, noMatches)
|
||||
}
|
||||
|
||||
func TestProviderSchemaValidation(t *testing.T) {
|
||||
invalid := []byte("format_version: 0\nname: invalid\nlast_verified: \"\"\n")
|
||||
var p providers.Provider
|
||||
err := yaml.Unmarshal(invalid, &p)
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "format_version")
|
||||
}
|
||||
23
pkg/storage/db_test.go
Normal file
23
pkg/storage/db_test.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package storage_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestDBOpen verifies SQLite database opens and creates schema.
|
||||
// Stub: will be implemented when db.go exists (Plan 03).
|
||||
func TestDBOpen(t *testing.T) {
|
||||
t.Skip("stub — implement after db.go exists")
|
||||
}
|
||||
|
||||
// TestEncryptDecryptRoundtrip verifies AES-256-GCM encrypt/decrypt roundtrip.
|
||||
// Stub: will be implemented when encrypt.go exists (Plan 03).
|
||||
func TestEncryptDecryptRoundtrip(t *testing.T) {
|
||||
t.Skip("stub — implement after encrypt.go exists")
|
||||
}
|
||||
|
||||
// TestArgon2KeyDerivation verifies Argon2id produces 32-byte key deterministically.
|
||||
// Stub: will be implemented when crypto.go exists (Plan 03).
|
||||
func TestArgon2KeyDerivation(t *testing.T) {
|
||||
t.Skip("stub — implement after crypto.go exists")
|
||||
}
|
||||
Reference in New Issue
Block a user