mirror of
https://github.com/cert-manager/webhook-example.git
synced 2025-07-01 22:35:49 +02:00
WIP - missed changes
This commit is contained in:
parent
99d2af76be
commit
8623314867
3 changed files with 13 additions and 33 deletions
|
@ -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"
|
||||
|
|
4
main.go
4
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
|
||||
}
|
||||
|
|
26
main_test.go
26
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))
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue