mirror of
https://github.com/cert-manager/webhook-example.git
synced 2025-07-03 07:05:50 +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
|
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) {
|
func TestRemoveDNSRecord(t *testing.T) {
|
||||||
expectedMethod := "DELETE"
|
expectedMethod := "DELETE"
|
||||||
dnsID := "1"
|
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)
|
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"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
|
@ -23,7 +24,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
zone = "example.com." // os.Getenv("TEST_ZONE_NAME")
|
zone = os.Getenv("TEST_ZONE_NAME")
|
||||||
kubeBuilderBinPath = "./_out/kubebuilder/bin"
|
kubeBuilderBinPath = "./_out/kubebuilder/bin"
|
||||||
fqdn string
|
fqdn string
|
||||||
)
|
)
|
||||||
|
@ -69,7 +70,7 @@ func TestRunsSuite(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
httpCall := 0
|
httpCall := 0
|
||||||
|
fqdn = "cert-manager-dns01-tests-with-secret." + zone
|
||||||
testHandlerFunc := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
testHandlerFunc := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||||
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++
|
httpCall++
|
||||||
|
@ -85,7 +86,7 @@ func TestRunsSuite(t *testing.T) {
|
||||||
|
|
||||||
srv := &server.BasicServer{
|
srv := &server.BasicServer{
|
||||||
Handler: &test.Handler{
|
Handler: &test.Handler{
|
||||||
Log: logf.FromContext(ctx, "dnsBasicServer"),
|
Log: logf.FromContext(ctx, "dnsBasicServerSecret"),
|
||||||
TxtRecords: map[string][][]string{
|
TxtRecords: map[string][][]string{
|
||||||
fqdn: {
|
fqdn: {
|
||||||
{},
|
{},
|
||||||
|
@ -121,12 +122,9 @@ func TestRunsSuite(t *testing.T) {
|
||||||
)
|
)
|
||||||
|
|
||||||
fixture.RunConformance(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) {
|
func TestRunSuiteWithSecret(t *testing.T) {
|
||||||
|
t.Skip()
|
||||||
dnsResp := dynuclient.DNSResponse{
|
dnsResp := dynuclient.DNSResponse{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ID: 98765,
|
ID: 98765,
|
||||||
|
@ -135,7 +133,7 @@ func TestRunSuiteWithSecret(t *testing.T) {
|
||||||
NodeName: "nodeName",
|
NodeName: "nodeName",
|
||||||
Hostname: "hostName",
|
Hostname: "hostName",
|
||||||
RecordType: "TXT",
|
RecordType: "TXT",
|
||||||
TTL: 90,
|
TTL: 200,
|
||||||
State: true,
|
State: true,
|
||||||
Content: "content",
|
Content: "content",
|
||||||
UpdatedOn: "2020-10-29T23:00",
|
UpdatedOn: "2020-10-29T23:00",
|
||||||
|
@ -163,14 +161,12 @@ func TestRunSuiteWithSecret(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
httpCall := 0
|
httpCall := 0
|
||||||
// if os.Getenv("TEST_ZONE_NAME") != "" {
|
if os.Getenv("TEST_ZONE_NAME") != "" {
|
||||||
// zone = os.Getenv("TEST_ZONE_NAME")
|
zone = os.Getenv("TEST_ZONE_NAME")
|
||||||
// }
|
}
|
||||||
// fqdn = "cert-manager-dns01-tests-with-secret." + zone
|
fqdn = "cert-manager-dns01-tests-with-secret." + zone
|
||||||
testHandlerFunc := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
testHandlerFunc := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||||
fmt.Println("called: ", httpCall)
|
assert.Equal(t, scenarios[httpCall].expected, req.URL.String(), scenarios[httpCall].scenario+" failed")
|
||||||
fmt.Println("scenario:", scenarios[httpCall].scenario)
|
|
||||||
// assert.Equal(t, scenarios[httpCall].expected, req.URL.String(), scenarios[httpCall].scenario+" failed")
|
|
||||||
httpCall++
|
httpCall++
|
||||||
w.Write([]byte(dnsResponse))
|
w.Write([]byte(dnsResponse))
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue