Skip to content

Commit

Permalink
Almost all unit tests work now, except ...
Browse files Browse the repository at this point in the history
--- FAIL: TestBluecatRecords (0.00s)
    bluecat_test.go:89: could not fetch zones: error retrieving zone(s) from gateway: foo, Get "foo/api/v1/configurations/foo/views/foo/zones/foo/zones/": unsupported protocol scheme ""
FAIL
FAIL	sigs.k8s.io/external-dns/provider/bluecat	0.250s
  • Loading branch information
seanmalloy committed May 16, 2020
1 parent cd65b1f commit 5d91f0a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
4 changes: 4 additions & 0 deletions pkg/apis/externaldns/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var (
AzureConfigFile: "/etc/kubernetes/azure.json",
AzureResourceGroup: "",
AzureSubscriptionID: "",
BluecatConfigFile: "/etc/kubernetes/bluecat.json",
CloudflareProxied: false,
CloudflareZonesPerPage: 50,
CoreDNSPrefix: "/skydns/",
Expand Down Expand Up @@ -130,6 +131,7 @@ var (
AzureConfigFile: "azure.json",
AzureResourceGroup: "arg",
AzureSubscriptionID: "arg",
BluecatConfigFile: "bluecat.json",
CloudflareProxied: true,
CloudflareZonesPerPage: 20,
CoreDNSPrefix: "/coredns/",
Expand Down Expand Up @@ -218,6 +220,7 @@ func TestParseFlags(t *testing.T) {
"--azure-config-file=azure.json",
"--azure-resource-group=arg",
"--azure-subscription-id=arg",
"--bluecat-config-file=bluecat.json",
"--cloudflare-proxied",
"--cloudflare-zones-per-page=20",
"--coredns-prefix=/coredns/",
Expand Down Expand Up @@ -305,6 +308,7 @@ func TestParseFlags(t *testing.T) {
"EXTERNAL_DNS_AZURE_CONFIG_FILE": "azure.json",
"EXTERNAL_DNS_AZURE_RESOURCE_GROUP": "arg",
"EXTERNAL_DNS_AZURE_SUBSCRIPTION_ID": "arg",
"EXTERNAL_DNS_BLUECAT_CONFIG_FILE": "bluecat.json",
"EXTERNAL_DNS_CLOUDFLARE_PROXIED": "1",
"EXTERNAL_DNS_CLOUDFLARE_ZONES_PER_PAGE": "20",
"EXTERNAL_DNS_COREDNS_PREFIX": "/coredns/",
Expand Down
51 changes: 31 additions & 20 deletions provider/bluecat/bluecat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@ package bluecat

import (
"context"
"net/http"
"strings"
"testing"
"time"

"github.com/stretchr/testify/assert"
"sigs.k8s.io/external-dns/endpoint"
"sigs.k8s.io/external-dns/internal/testutils"
"sigs.k8s.io/external-dns/provider"
)

type mockGatewayClient struct {
mockBluecatZones *[]BluecatZone
mockBluecatHosts *[]BluecatHostRecord
mockBluecatCNAMEs *[]BluecatCNAMERecord
}
//type mockGatewayClient struct {
// mockBluecatZones *[]BluecatZone
// mockBluecatHosts *[]BluecatHostRecord
// mockBluecatCNAMEs *[]BluecatCNAMERecord
//}

func (g *mockGatewayClient) getBluecatZones() ([]BluecatZone, error) {
return *g.mockBluecatZones, nil
}
//func (g *mockGatewayClient) getBluecatZones() ([]BluecatZone, error) {
// return *g.mockBluecatZones, nil
//}

func createMockBluecatZone(fqdn string) BluecatZone {
return BluecatZone{
Expand Down Expand Up @@ -55,18 +57,27 @@ func newBluecatProvider(domainFilter endpoint.DomainFilter, zoneIDFilter provide
}

func TestBluecatRecords(t *testing.T) {
client := mockGatewayClient{
mockBluecatZones: &[]BluecatZone{
createMockBluecatZone("example.com"),
},
mockBluecatHosts: &[]BluecatHostRecord{
createMockBluecatHostRecord("example.com", "123.123.123.122"),
createMockBluecatHostRecord("nginx.example.com", "123.123.123.123"),
createMockBluecatHostRecord("whitespace.example.com", "123.123.123.124"),
},
mockBluecatCNAMEs: &[]BluecatCNAMERecord{
createMockBluecatCNAME("hack.example.com", "bluecatnetworks.com"),
},
//client := mockGatewayClient{
// mockBluecatZones: &[]BluecatZone{
// createMockBluecatZone("example.com"),
// },
// mockBluecatHosts: &[]BluecatHostRecord{
// createMockBluecatHostRecord("example.com", "123.123.123.122"),
// createMockBluecatHostRecord("nginx.example.com", "123.123.123.123"),
// createMockBluecatHostRecord("whitespace.example.com", "123.123.123.124"),
// },
// mockBluecatCNAMEs: &[]BluecatCNAMERecord{
// createMockBluecatCNAME("hack.example.com", "bluecatnetworks.com"),
// },
//}
client := GatewayClient{
Token: "foo",
Host: "foo",
DNSConfiguration: "foo",
View: "foo",
RootZone: "foo",
Cookie: http.Cookie{Name: "mycookie", Value: "SomeValue", Path: "/mysite", Domain: "", Expires: time.Now(), RawExpires: "", MaxAge: 0, Secure: true, HttpOnly: true, Raw: "", Unparsed: []string(nil)},
//Cookie: "foo", // http.Cookie
}

provider := newBluecatProvider(
Expand Down

0 comments on commit 5d91f0a

Please sign in to comment.