@@ -140,13 +140,15 @@ func TestGenerateZKI(t *testing.T) {
140
140
// GitHub repository and CI environment, where the correct test certificate is available.
141
141
142
142
func TestKnownZKI (t * testing.T ) {
143
+ if os .Getenv ("FISKALHRGO_TEST_KNOWN_ZKI" ) == "" {
144
+ t .Skip ("Skipping TestKnownZKI because FISKALHRGO_TEST_KNOWN_ZKI environment variable is not set" )
145
+ }
143
146
t .Logf ("Testing Known LDT ZKI generation..." )
144
147
145
- expectedZKI := "0b173c6127809d4f0fff53e13222c819" // This is the ZKI for the test certificate
148
+ expectedZKI := os . Getenv ( "FISKALHRGO_TEST_KNOWN_ZKI" ) // This is the ZKI for the test certificate
146
149
147
- // Check if the external contributor has set their own known ZKI via environment variable
148
- if envZKI := os .Getenv ("FISKALHRGO_TEST_KNOWN_ZKI" ); envZKI != "" {
149
- expectedZKI = envZKI
150
+ if ! ValidateZKI (expectedZKI ) {
151
+ t .Fatalf ("Invalid ZKI provided in FISKALHRGO_TEST_KNOWN_ZKI environment variable" )
150
152
}
151
153
152
154
timeString := "17.05.2024 16:00:38"
@@ -172,9 +174,8 @@ func TestKnownZKI(t *testing.T) {
172
174
if zki != expectedZKI {
173
175
t .Error ("Note:" )
174
176
t .Error ("- The ZKI (Protection Code) is dependent on the private key used." )
175
- t .Error ("- If you're an external contributor and don't have the correct test certificate, this test is expected to fail." )
176
- t .Error ("- You can use the FISKALHRGO_TEST_KNOWN_ZKI environment variable to specify your own expected ZKI for testing." )
177
- t .Error ("- This test should pass on the official GitHub and CI setup where the correct certificate is available." )
177
+ t .Error ("- Use the FISKALHRGO_TEST_KNOWN_ZKI environment variable to specify your expected ZKI for testing." )
178
+ t .Error ("- This test should pass on the official GitHub and CI setup where the correct certificate and ZKI pair is available." )
178
179
t .Fatalf ("ERROR - Expected ZKI: %s, got %s" , expectedZKI , zki )
179
180
} else {
180
181
t .Log ("ZKI matched the expected value." )
@@ -214,8 +215,8 @@ func TestPing(t *testing.T) {
214
215
// This test just the SSL connection and production cert verification pool and ping message to the CIS production server
215
216
// The rest should be identical to the demo environment and the rest can only be tested in the demo environment ofc.
216
217
func TestProductionPing (t * testing.T ) {
217
- if os .Getenv ("CIStestprodping " ) == "" {
218
- t .Skip ("Skipping TestProductionPing because CIStestprodping environment variable is not set" )
218
+ if os .Getenv ("CISTESTPRODPING " ) == "" {
219
+ t .Skip ("Skipping TestProductionPing because CISTESTPRODPING environment variable is not set" )
219
220
}
220
221
t .Log ("Testing Production Ping..." )
221
222
// The path is still to the demo cert, but is not important since we will test only the SSL connection and Echo message
0 commit comments