Update .slinkignore to include additional SailPoint API URLs and enhance test coverage for ignored URLs. Modify tests to ensure proper handling of ignored paths and URLs, including node_modules and package-lock.json.

This commit is contained in:
Luke Hagar
2025-09-13 03:17:44 +00:00
parent 4af80ed208
commit d2dbfe9dd1
5 changed files with 41 additions and 6 deletions

View File

@@ -44,11 +44,24 @@ func TestCollectURLs_FromTestFiles(t *testing.T) {
if _, ok := urls["https://example.com/this/path/does/not/exist"]; ok {
t.Fatalf("expected URL ignored by .slinkignore to be absent")
}
// Ignore sailpoint api variants
ignoredAPIs := []string{
"https://sailpoint.api.identitynow.com/beta",
"https://sailpoint.api.identitynow.com/v3",
"https://sailpoint.api.identitynow.com/v2024",
"https://sailpoint.api.identitynow.com/v2025",
"https://sailpoint.api.identitynow.com/v2026",
}
for _, u := range ignoredAPIs {
if _, ok := urls[u]; ok {
t.Fatalf("expected API URL %s to be ignored via .slinkignore", u)
}
}
// Verify .slinkignore path ignores: file under ignore-me should not contribute
for u, files := range urls {
for _, f := range files {
if strings.Contains(f, "ignore-me/") {
if strings.Contains(f, "ignore-me/") || strings.Contains(f, "node_modules/") || strings.HasSuffix(f, "package-lock.json") {
t.Fatalf("file %s should have been ignored via .slinkignore, but contributed to URL %s", f, u)
}
}

View File

@@ -27,9 +27,9 @@ func TestCollectURLs_FromCodeFiles(t *testing.T) {
}
}
// Ensure sanitizer trims emphasis and punctuation
if _, ok := urls["https://sailpoint.api.identitynow.com/v2024"]; !ok {
t.Fatalf("expected sanitized emphasized URL to be collected without trailing *")
// Ensure sanitizer trims emphasis and punctuation (note: v2024 is ignored by .slinkignore)
if _, ok := urls["https://sailpoint.api.identitynow.com/v2024"]; ok {
t.Fatalf("expected v2024 URL to be ignored via .slinkignore")
}
if _, ok := urls["https://example.com/path"]; !ok {
t.Fatalf("expected URL with trailing ) to be trimmed")

12
testdata/.slinkignore vendored
View File

@@ -1,10 +1,18 @@
{
"ignorePaths": [
"**/ignore-me/**",
"**/*.bak"
"**/*.bak",
"node_modules",
"package-lock.json"
],
"ignoreURLs": [
"*notarealwebsite.com*",
"https://example.com/this/path/does/not/exist",
"*notarealwebsite.com*"
"*acme*",
"https://sailpoint.api.identitynow.com/beta",
"https://sailpoint.api.identitynow.com/v3",
"https://sailpoint.api.identitynow.com/v2024",
"https://sailpoint.api.identitynow.com/v2025",
"https://sailpoint.api.identitynow.com/v2026"
]
}

2
testdata/node_modules/pkg/readme.md generated vendored Normal file
View File

@@ -0,0 +1,2 @@
This is a vendored dependency and should be ignored.
https://sailpoint.api.identitynow.com/v2024

12
testdata/package-lock.json generated vendored Normal file
View File

@@ -0,0 +1,12 @@
{
"name": "fixture",
"version": "1.0.0",
"dependencies": {
"@acme/pkg": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/@acme/pkg/-/pkg-1.2.3.tgz",
"integrity": "sha512-...",
"homepage": "https://acme.example.com"
}
}
}