Skip to content

Commit

Permalink
Add unit tests for generating secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
ojmhetar committed Jan 28, 2019
1 parent 525217d commit 5c80aea
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/secret_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package test

import (
"testing"

"github.com/platform9/cctl/common"
)

func TestBTSecret(t *testing.T) {

btSecret, _ := common.CreateBootstrapTokenSecret("bootstrap")

if btSecret.ObjectMeta.Name != "bootstrap" {
t.Error("Expected bootstrap, got ", btSecret.ObjectMeta.Name)
}
}

func TestCASecret(t *testing.T) {
caSecret, err := common.CreateCASecretDefault("apiserver-ca")
if err != nil {
t.Error("Error creating ca secret: ", err)
}

if caSecret.ObjectMeta.Name != "apiserver-ca" {
t.Error("Expected apiserver-ca, got ", caSecret.ObjectMeta.Name)
}

if _, ok := caSecret.Data["tls.crt"]; !ok {
t.Error("tls.crt not found.")
}
if _, ok := caSecret.Data["tls.key"]; !ok {
t.Error("tls.key not found")
}
}

func TestSASecret(t *testing.T) {
saSecret, err := common.CreateSAKeySecretDefault("serviceaccount")
if err != nil {
t.Error("Error creating ca secret: ", err)
}

if saSecret.ObjectMeta.Name != "serviceaccount" {
t.Error("Expected serviceaccount, got ", saSecret.ObjectMeta.Name)
}

if _, ok := saSecret.Data["privatekey"]; !ok {
t.Error("privatekey not found.")
}
if _, ok := saSecret.Data["publickey"]; !ok {
t.Error("publickey not found")
}
}

0 comments on commit 5c80aea

Please sign in to comment.