-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib_test.go
56 lines (48 loc) · 1.22 KB
/
lib_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package crtsher
import (
"net/http"
"testing"
"time"
)
func TestNewRunner(t *testing.T) {
runner := NewRunner()
if runner.Options.Concurrency != 3 {
t.Errorf("Expected Concurrency to be 3, got %d", runner.Options.Concurrency)
}
if runner.Options.Timeout != 90 {
t.Errorf("Expected Timeout to be 90, got %d", runner.Options.Timeout)
}
}
func TestQuery(t *testing.T) {
runner := NewRunnerWithOptions(&Options{
HTTPClient: &http.Client{
Timeout: 10 * time.Second,
},
})
domains := []string{"example.com", "hackerone.com"}
success := false
for _, domain := range domains {
results := runner.Query(domain)
if len(results) > 0 {
success = true
break
}
}
if !success {
t.Error("Expected results for at least one domain, got none")
}
}
func TestGetCommonName(t *testing.T) {
result := Result{CommonName: "*.example.com"}
expected := "example.com"
if result.GetCommonName() != expected {
t.Errorf("Expected %s, got %s", expected, result.GetCommonName())
}
}
func TestGetMatchingIdentity(t *testing.T) {
result := Result{NameValue: "*.example.com"}
expected := "example.com"
if result.GetMatchingIdentity() != expected {
t.Errorf("Expected %s, got %s", expected, result.GetMatchingIdentity())
}
}