-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ciscert_test.go
59 lines (47 loc) · 2.11 KB
/
ciscert_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
48
49
50
51
52
53
54
55
56
57
58
59
package fiskalhrgo
// SPDX-License-Identifier: MIT
// Copyright (c) 2024 L. D. T. d.o.o.
// Copyright (c) contributors for their respective contributions. See https://github.com/l-d-t/fiskalhrgo/graphs/contributors
import "testing"
// Expected serial number of the embedded CIS demo certificate currently in use
const expectedDemoSerial = "325450325973957308031939306065516468253"
// Expected serial number of the embedded CIS production certificate currently in use
const expectedProdSerial = "313300731601639444557048129613010882577"
// Test embedded CIS demo certificate
func TestParseAndVerifyEmbeddedCertsDemo(t *testing.T) {
t.Logf("Testing embedded CIS demo certificate...")
// Parse and verify the embedded CIS demo certificate
cert, err := getDemoPublicKey()
if err != nil {
t.Fatalf("Failed to parse and verify embedded CIS demo certificate: %v", err)
}
t.Logf("Embedded CIS demo certificate parsed and verified successfully")
t.Logf("Subject: %s", cert.Subject)
t.Logf("Serial: %s", cert.Serial)
t.Logf("Issuer: %s", cert.Issuer)
t.Logf("Valid from: %v", cert.ValidFrom)
t.Logf("Valid until: %v", cert.ValidUntil)
// Check if the serial number matches the expected value
if cert.Serial != expectedDemoSerial {
t.Fatalf("Expected serial number %s, but got %s", expectedDemoSerial, cert.Serial)
}
}
// Test embedded CIS production certificate
func TestParseAndVerifyEmbeddedCertsProd(t *testing.T) {
t.Logf("Testing embedded CIS production certificate...")
// Parse and verify the embedded CIS production certificate
cert, err := getProductionPublicKey()
if err != nil {
t.Fatalf("Failed to parse and verify embedded CIS production certificate: %v", err)
}
t.Logf("Embedded CIS production certificate parsed and verified successfully")
t.Logf("Subject: %s", cert.Subject)
t.Logf("Serial: %s", cert.Serial)
t.Logf("Issuer: %s", cert.Issuer)
t.Logf("Valid from: %v", cert.ValidFrom)
t.Logf("Valid until: %v", cert.ValidUntil)
// Check if the serial number matches the expected value
if cert.Serial != expectedProdSerial {
t.Fatalf("Expected serial number %s, but got %s", expectedProdSerial, cert.Serial)
}
}