-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtls_test.go
More file actions
53 lines (40 loc) · 1.24 KB
/
tls_test.go
File metadata and controls
53 lines (40 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package api
import (
"strings"
"testing"
)
func TestTLSString(t *testing.T) {
tls := &TLS{}
expected := "--- HTTPS Enforced: not set\n--- Certs Auto: not set\n--- Issuer: not set"
if strings.TrimSpace(tls.String()) != expected {
t.Errorf("Expected:\n\n%s\n\nGot:\n\n%s", expected, tls.String())
}
tls = NewTLS()
expected = "--- HTTPS Enforced: false\n--- Certs Auto: false\n--- Issuer: not set"
if strings.TrimSpace(tls.String()) != expected {
t.Errorf("Expected:\n\n%s\n\nGot:\n\n%s", expected, tls.String())
}
b := true
tls.HTTPSEnforced = &b
expected = "--- HTTPS Enforced: true\n--- Certs Auto: false\n--- Issuer: not set"
if strings.TrimSpace(tls.String()) != expected {
t.Errorf("Expected:\n\n%s\n\nGot:\n\n%s", expected, tls.String())
}
issuer := Issuer{
Email: "anonymous@cert-manager.io",
Server: "https://acme-v02.api.letsencrypt.org/directory",
KeyID: "",
KeySecret: "",
}
tls.Issuer = &issuer
expected = `--- HTTPS Enforced: true
--- Certs Auto: false
--- Issuer:
email: anonymous@cert-manager.io
server: https://acme-v02.api.letsencrypt.org/directory
key-id:
key-secret:`
if strings.TrimSpace(tls.String()) != expected {
t.Errorf("Expected:\n\n%s\n\nGot:\n\n%s", expected, tls.String())
}
}