-
Notifications
You must be signed in to change notification settings - Fork 6
/
main_test.go
59 lines (45 loc) · 1.23 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
package main
import (
"os"
"testing"
"os/exec"
"fmt"
"github.com/jetstack/cert-manager/test/acme/dns"
"k8s.io/client-go/rest"
)
var (
zone = os.Getenv("TEST_ZONE_NAME")
kubeBuilderBinPath = "./_out/kubebuilder/bin"
testPath = "./testdata/my-custom-solver"
)
type testCustomDNSProviderSolver struct {
customDNSProviderSolver
}
func (c *testCustomDNSProviderSolver) Initialize(kubeClientConfig *rest.Config, stopCh <-chan struct{}) error {
err := c.customDNSProviderSolver.Initialize(kubeClientConfig, stopCh);
if err != nil {
return err
}
cmd := exec.Command(
fmt.Sprintf("%s/kubectl", kubeBuilderBinPath),
"apply",
"-f",
fmt.Sprintf("%s/api-key.yaml", testPath),
"-s",
kubeClientConfig.Host,
)
_, err = cmd.Output()
return err
}
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.
fixture := dns.NewFixture(&testCustomDNSProviderSolver{},
dns.SetBinariesPath(kubeBuilderBinPath),
dns.SetResolvedZone(zone),
dns.SetAllowAmbientCredentials(false),
dns.SetManifestPath(testPath),
)
fixture.RunConformance(t)
}