Files
keyhunter/pkg/recon/sources/register_test.go
salvacybersec 7ef6c2ac34 feat(14-04): wire all 12 Phase 14 sources in RegisterAll (45 -> 52 total)
- Add CircleCIToken to SourcesConfig with env/viper lookup in cmd/recon.go
- Register 7 new sources: travisci, ghactions, circleci, jenkins, wayback, commoncrawl, jsbundle
- Update register_test.go expectations from 45 to 52 sources
- Add integration test handlers + registrations for all 12 Phase 14 sources
- Integration test now validates 52 sources end-to-end
2026-04-06 13:34:18 +03:00

108 lines
2.4 KiB
Go

package sources
import (
"reflect"
"testing"
"github.com/salvacybersec/keyhunter/pkg/providers"
"github.com/salvacybersec/keyhunter/pkg/recon"
)
// registerTestRegistry builds a minimal registry with one synthetic provider so
// BuildQueries inside individual sources does not panic.
func registerTestRegistry() *providers.Registry {
return providers.NewRegistryFromProviders([]providers.Provider{
{Name: "openai", Keywords: []string{"sk-proj-"}},
})
}
// TestRegisterAll_WiresAllFiftyTwoSources asserts that RegisterAll registers
// every Phase 10-14 source by its stable name on a fresh engine.
func TestRegisterAll_WiresAllFiftyTwoSources(t *testing.T) {
eng := recon.NewEngine()
cfg := SourcesConfig{
Registry: registerTestRegistry(),
Limiters: recon.NewLimiterRegistry(),
}
RegisterAll(eng, cfg)
got := eng.List()
want := []string{
"azureblob",
"binaryedge",
"bing",
"bitbucket",
"brave",
"censys",
"circleci",
"codeberg",
"codesandbox",
"commoncrawl",
"crates",
"deploypreview",
"dockerhub",
"dotenv",
"duckduckgo",
"fofa",
"gcs",
"ghactions",
"gist",
"gistpaste",
"github",
"gitlab",
"google",
"goproxy",
"helm",
"huggingface",
"jenkins",
"jsbundle",
"k8s",
"kaggle",
"maven",
"netlas",
"npm",
"nuget",
"packagist",
"pastebin",
"pastesites",
"pypi",
"replit",
"rubygems",
"s3",
"sandboxes",
"shodan",
"sourcemaps",
"spaces",
"swagger",
"terraform",
"travisci",
"wayback",
"webpack",
"yandex",
"zoomeye",
}
if !reflect.DeepEqual(got, want) {
t.Fatalf("RegisterAll names mismatch\n got: %v\nwant: %v", got, want)
}
}
// TestRegisterAll_MissingCredsStillRegistered asserts that sources whose
// credentials are absent are still registered (so eng.List() reports them),
// but their Enabled() returns false. This keeps the CLI surface uniform
// regardless of which tokens are configured.
func TestRegisterAll_MissingCredsStillRegistered(t *testing.T) {
eng := recon.NewEngine()
RegisterAll(eng, SourcesConfig{
Registry: registerTestRegistry(),
Limiters: recon.NewLimiterRegistry(),
})
if n := len(eng.List()); n != 52 {
t.Fatalf("expected 52 sources registered, got %d: %v", n, eng.List())
}
// SweepAll with an empty config should filter out cred-gated sources
// (github, gitlab, bitbucket, gist, kaggle) and still run the credless
// ones. We only check List() here; the integration test covers Sweep.
}