Skip to content

Commit

Permalink
test: add ipv6 tests as well
Browse files Browse the repository at this point in the history
  • Loading branch information
clementnuss committed Apr 1, 2022
1 parent d8d9d5a commit a80342e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 4 additions & 4 deletions internal/controller/csr_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ func TestWrongSignerCsr(t *testing.T) {

func TestNonMatchingCommonNameUsername(t *testing.T) {
csrParams := CsrParams{
csrName: "csr-non-matching",
commonName: "funny-common-name",

ipAddresses: testNodeIpAddresses, nodeName: testNodeName}
csrName: "csr-non-matching",
commonName: "funny-common-name",
ipAddresses: testNodeIpAddresses,
nodeName: testNodeName}
csr := createCsr(t, csrParams)
_, nodeClientSet, _ := createControlPlaneUser(t, csr.Spec.Username, []string{"system:masters"})

Expand Down
12 changes: 8 additions & 4 deletions internal/controller/testenv_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ type CsrParams struct {

var (
testNodeName string
testNodeIps []string
testNodeIpAddresses []net.IP
)

Expand Down Expand Up @@ -168,15 +167,20 @@ func packageSetup() {
}
adminClientset = clientset.NewForConfigOrDie(cfg)

testNodeIps := []string{"192.168.14.34"}
for _, ip := range testNodeIps {
testNodeIpv4 := []string{"192.168.14.34"}
testNodeIpv6 := []string{"fc00:1291:feed::cafe"}
for _, ip := range testNodeIpv4 {
testNodeIpAddresses = append(testNodeIpAddresses, net.ParseIP(ip))
}
for _, ip := range testNodeIpv6 {
testNodeIpAddresses = append(testNodeIpAddresses, net.ParseIP(ip))
}
testNodeName = randstr.String(4, "0123456789abcdefghijklmnopqrstuvwxyz")
dnsResolver = mockdns.Resolver{
Zones: map[string]mockdns.Zone{
testNodeName + ".test.ch.": {
A: testNodeIps,
A: testNodeIpv4,
AAAA: testNodeIpv6,
},
},
}
Expand Down

0 comments on commit a80342e

Please sign in to comment.