Skip to content

Commit a6f5b97

Browse files
committed
test(signing): update PasswordTest for fail-closed CRL behavior
Migrates 'valid'/'revoked' string literals to CrlValidationStatus enum and adds test cases for the new DISABLED and urls_inaccessible/ validation_failed statuses introduced by the fail-closed policy. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 91d6191 commit a6f5b97

1 file changed

Lines changed: 38 additions & 6 deletions

File tree

tests/php/Unit/Service/IdentifyMethod/PasswordTest.php

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace OCA\Libresign\Tests\Unit\Service\IdentifyMethod;
1010

1111
use OCA\Libresign\AppInfo\Application;
12+
use OCA\Libresign\Enum\CrlValidationStatus;
1213
use OCA\Libresign\Exception\LibresignException;
1314
use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory;
1415
use OCA\Libresign\Handler\DocMdpHandler;
@@ -228,15 +229,22 @@ public static function providerValidateToSignWithCertificateData(): array {
228229
'revoked certificate' => [
229230
'certificateData' => [
230231
'validTo_time_t' => $futureTimestamp,
231-
'crl_validation' => 'revoked',
232+
'crl_validation' => CrlValidationStatus::REVOKED,
232233
],
233234
'shouldThrow' => true,
234235
'expectedMessage' => 'Certificate has been revoked',
235236
],
236237
'valid certificate with crl validation' => [
237238
'certificateData' => [
238239
'validTo_time_t' => $futureTimestamp,
239-
'crl_validation' => 'valid',
240+
'crl_validation' => CrlValidationStatus::VALID,
241+
],
242+
'shouldThrow' => false,
243+
],
244+
'disabled crl validation - admin disabled external check' => [
245+
'certificateData' => [
246+
'validTo_time_t' => $futureTimestamp,
247+
'crl_validation' => CrlValidationStatus::DISABLED,
240248
],
241249
'shouldThrow' => false,
242250
],
@@ -246,28 +254,52 @@ public static function providerValidateToSignWithCertificateData(): array {
246254
'crl_validation' => 'failed',
247255
],
248256
'shouldThrow' => true,
249-
'expectedMessage' => 'Certificate has been revoked',
257+
'expectedMessage' => 'Certificate revocation status could not be verified',
250258
],
251259
'invalid certificate - crl validation empty string' => [
252260
'certificateData' => [
253261
'validTo_time_t' => $futureTimestamp,
254262
'crl_validation' => '',
255263
],
256264
'shouldThrow' => true,
257-
'expectedMessage' => 'Certificate has been revoked',
265+
'expectedMessage' => 'Certificate revocation status could not be verified',
258266
],
259267
'invalid certificate - crl validation null' => [
260268
'certificateData' => [
261269
'validTo_time_t' => $futureTimestamp,
262270
'crl_validation' => null,
263271
],
264272
'shouldThrow' => true,
265-
'expectedMessage' => 'Certificate has been revoked',
273+
'expectedMessage' => 'Certificate revocation status could not be verified',
274+
],
275+
'invalid certificate - crl urls_inaccessible' => [
276+
'certificateData' => [
277+
'validTo_time_t' => $futureTimestamp,
278+
'crl_validation' => CrlValidationStatus::URLS_INACCESSIBLE,
279+
],
280+
'shouldThrow' => true,
281+
'expectedMessage' => 'Certificate revocation status could not be verified',
282+
],
283+
'invalid certificate - crl validation_failed' => [
284+
'certificateData' => [
285+
'validTo_time_t' => $futureTimestamp,
286+
'crl_validation' => CrlValidationStatus::VALIDATION_FAILED,
287+
],
288+
'shouldThrow' => true,
289+
'expectedMessage' => 'Certificate revocation status could not be verified',
290+
],
291+
'invalid certificate - crl validation_error' => [
292+
'certificateData' => [
293+
'validTo_time_t' => $futureTimestamp,
294+
'crl_validation' => CrlValidationStatus::VALIDATION_ERROR,
295+
],
296+
'shouldThrow' => true,
297+
'expectedMessage' => 'Certificate revocation status could not be verified',
266298
],
267299
'revoked and expired certificate' => [
268300
'certificateData' => [
269301
'validTo_time_t' => $pastTimestamp,
270-
'crl_validation' => 'revoked',
302+
'crl_validation' => CrlValidationStatus::REVOKED,
271303
],
272304
'shouldThrow' => true,
273305
'expectedMessage' => 'Certificate has been revoked', // revocation is checked first

0 commit comments

Comments
 (0)