Files
trufflehog/pkg/detectors/sqlserver/sqlserver_test.go
Nabeel Alam e6be459eb4 Added pattern unit tests for detectors starting with the letters r through s (#3752)
* updated and added pattern tests for detectors r-s

* updated skybiometry pattern test

* reformatted integration files; fixed import sequence
2024-12-12 16:21:38 +05:00

21 lines
1.2 KiB
Go

package sqlserver
import (
"testing"
)
func TestSQLServer_Pattern(t *testing.T) {
if !pattern.Match([]byte(`builder.Services.AddDbContext<Database>(optionsBuilder => optionsBuilder.UseSqlServer("Server=localhost;Initial Catalog=master;User ID=sa;Password=P@ssw0rd!;Persist Security Info=true;MultipleActiveResultSets=true;"));`)) {
t.Errorf("SQLServer.pattern: did not find connection string from Program.cs")
}
if !pattern.Match([]byte(`{"ConnectionStrings": {"Demo": "Server=localhost;Initial Catalog=master;User ID=sa;Password=P@ssw0rd!;Persist Security Info=true;MultipleActiveResultSets=true;"}}`)) {
t.Errorf("SQLServer.pattern: did not find connection string from appsettings.json")
}
if !pattern.Match([]byte(`CONNECTION_STRING: Server=localhost;Initial Catalog=master;User ID=sa;Password=P@ssw0rd!;Persist Security Info=true;MultipleActiveResultSets=true`)) {
t.Errorf("SQLServer.pattern: did not find connection string from .env")
}
if !pattern.Match([]byte(`<add name="Sample2" value="SERVER=server_name;DATABASE=database_name;user=user_name;pwd=plaintextpassword;encrypt=true;Timeout=120;MultipleActiveResultSets=True;" />`)) {
t.Errorf("SQLServer.pattern: did not find connection string in xml format")
}
}