forked from cert-manager/webhook-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
67 lines (55 loc) · 1.48 KB
/
main_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
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"os"
"testing"
"time"
"github.com/cert-manager/cert-manager/test/acme/dns"
"github.com/stretchr/testify/assert"
)
var (
zone = os.Getenv("TEST_ZONE_NAME")
)
func TestRunsSuite(t *testing.T) {
// The manifest path should contain a file named config.json that is a
// snippet of valid configuration that should be included on the
// ChallengeRequest passed as part of the test cases.
pollTime, _ := time.ParseDuration("10s")
timeOut, _ := time.ParseDuration("5m")
fixture := dns.NewFixture(&edgecenterDNSProviderSolver{},
dns.SetResolvedZone(zone),
dns.SetAllowAmbientCredentials(false),
dns.SetManifestPath("testdata/ec"),
// Disable the extended test to create several records for the same Record DNS Name
dns.SetStrict(false),
// Increase the poll interval to 10s
dns.SetPollInterval(pollTime),
// Increase the limit from 2 min to 5 min
dns.SetPropagationLimit(timeOut),
)
fixture.RunConformance(t)
}
func Test_extractAllZones(t *testing.T) {
testCases := []struct {
desc string
fqdn string
expected []string
}{
{
desc: "success",
fqdn: "_acme-challenge.my.test.domain.com.",
expected: []string{"my.test.domain.com", "test.domain.com", "domain.com"},
},
{
desc: "empty",
fqdn: "_acme-challenge.com.",
},
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
got := extractAllZones(test.fqdn)
assert.Equal(t, test.expected, got)
})
}
}