forked from intel/trustauthority-client-for-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathak_certificate_test.go
47 lines (40 loc) · 925 Bytes
/
ak_certificate_test.go
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
/*
* Copyright (c) 2022-2024 Intel Corporation
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*/
package connector
import (
"crypto/tls"
"crypto/x509"
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
)
func TestGetAKCertificate(t *testing.T) {
testServer := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == akProvisioningApiPath {
w.WriteHeader(http.StatusOK)
response := akCertificateRequestResponse{}
j, err := json.Marshal(&response)
if err != nil {
t.Fatal(err)
}
w.Write([]byte(j))
} else {
w.WriteHeader(http.StatusNotFound)
}
}))
ctr, err := New(&Config{
ApiUrl: testServer.URL,
TlsCfg: &tls.Config{InsecureSkipVerify: true},
})
if err != nil {
t.Fatal(err)
}
_, _, _, err = ctr.GetAKCertificate(&x509.Certificate{}, make([]byte, 100))
if err != nil {
t.Fatal(err)
}
}