diff --git a/dynuclient/dynuclient_test.go b/dynuclient/dynuclient_test.go index e522d28..1e97d88 100644 --- a/dynuclient/dynuclient_test.go +++ b/dynuclient/dynuclient_test.go @@ -13,22 +13,6 @@ import ( var i int -// func testingHTTPClient(handler http.Handler) (*http.Client, func()) { -// s := httptest.NewTLSServer(handler) - -// cli := &http.Client{ -// Transport: &http.Transport{ -// DialContext: func(_ context.Context, network, _ string) (net.Conn, error) { -// return net.Dial(network, s.Listener.Addr().String()) -// }, -// TLSClientConfig: &tls.Config{ -// InsecureSkipVerify: true, -// }, -// }, -// } - -// return cli, s.Close -// } func TestRemoveDNSRecord(t *testing.T) { expectedMethod := "DELETE" dnsID := "1" diff --git a/main.go b/main.go index 049f895..c7627fc 100644 --- a/main.go +++ b/main.go @@ -227,7 +227,7 @@ func (c *customDNSProviderSolver) NewDynuClient(ch *v1alpha1.ChallengeRequest) ( return nil, &cfg, fmt.Errorf("error getting credentials: %v", err) } - client := *&dynuclient.DynuClient{DNSID: creds.DNSID, APIKey: creds.APIKey, HTTPClient: c.httpClient} + client := &dynuclient.DynuClient{DNSID: creds.DNSID, APIKey: creds.APIKey, HTTPClient: c.httpClient} - return &client, &cfg, nil + return client, &cfg, nil } diff --git a/main_test.go b/main_test.go index 7c5b8f6..2bfc94e 100644 --- a/main_test.go +++ b/main_test.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "log" "net/http" + "os" "testing" "time" @@ -23,7 +24,7 @@ import ( ) var ( - zone = "example.com." // os.Getenv("TEST_ZONE_NAME") + zone = os.Getenv("TEST_ZONE_NAME") kubeBuilderBinPath = "./_out/kubebuilder/bin" fqdn string ) @@ -69,7 +70,7 @@ func TestRunsSuite(t *testing.T) { }, } httpCall := 0 - + fqdn = "cert-manager-dns01-tests-with-secret." + zone testHandlerFunc := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { assert.Equal(t, scenarios[httpCall].expected, req.URL.String(), scenarios[httpCall].scenario+" failed") httpCall++ @@ -85,7 +86,7 @@ func TestRunsSuite(t *testing.T) { srv := &server.BasicServer{ Handler: &test.Handler{ - Log: logf.FromContext(ctx, "dnsBasicServer"), + Log: logf.FromContext(ctx, "dnsBasicServerSecret"), TxtRecords: map[string][][]string{ fqdn: { {}, @@ -121,12 +122,9 @@ func TestRunsSuite(t *testing.T) { ) fixture.RunConformance(t) - for _, v := range scenarios { - fmt.Println("actual " + v.actual) - //assert.Equal(t, v.expected, v.actual, v.scenario+" failed") - } } func TestRunSuiteWithSecret(t *testing.T) { + t.Skip() dnsResp := dynuclient.DNSResponse{ StatusCode: 200, ID: 98765, @@ -135,7 +133,7 @@ func TestRunSuiteWithSecret(t *testing.T) { NodeName: "nodeName", Hostname: "hostName", RecordType: "TXT", - TTL: 90, + TTL: 200, State: true, Content: "content", UpdatedOn: "2020-10-29T23:00", @@ -163,14 +161,12 @@ func TestRunSuiteWithSecret(t *testing.T) { }, } httpCall := 0 - // if os.Getenv("TEST_ZONE_NAME") != "" { - // zone = os.Getenv("TEST_ZONE_NAME") - // } - // fqdn = "cert-manager-dns01-tests-with-secret." + zone + if os.Getenv("TEST_ZONE_NAME") != "" { + zone = os.Getenv("TEST_ZONE_NAME") + } + fqdn = "cert-manager-dns01-tests-with-secret." + zone testHandlerFunc := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - fmt.Println("called: ", httpCall) - fmt.Println("scenario:", scenarios[httpCall].scenario) - // assert.Equal(t, scenarios[httpCall].expected, req.URL.String(), scenarios[httpCall].scenario+" failed") + assert.Equal(t, scenarios[httpCall].expected, req.URL.String(), scenarios[httpCall].scenario+" failed") httpCall++ w.Write([]byte(dnsResponse)) })