-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathclient_test.go
More file actions
41 lines (33 loc) · 786 Bytes
/
Copy pathclient_test.go
File metadata and controls
41 lines (33 loc) · 786 Bytes
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
package main
import (
"os"
"testing"
)
func TestGetIssuerCert(t *testing.T) {
cert, err := readCertificate("./testdata/certificate.pem")
if err != nil {
t.Fatal(err)
}
httpClient := &MockHTTPClient{}
client := NewClient(httpClient, os.Stdout)
issCert, err := client.GetIssuerCertificate(cert)
if err != nil {
t.Fatal(err)
}
if issCert.Issuer.CommonName != "DigiCert Global Root CA" {
t.Fatal(issCert.Issuer.CommonName)
}
}
func TestReadCertificate(t *testing.T) {
_, err := readCertificate("./testdata/certificate.pem")
if err != nil {
t.Fatal(err)
}
}
func TestCertificateFromBytesNoCertificate(t *testing.T) {
in, _ := os.ReadFile("./testdata/private_key.pem")
_, err := certificateFromBytes(in)
if err == nil {
t.Fatal("should return error")
}
}