Skip to content

Commit 9bd0211

Browse files
test: add test for non-integer cert revoked reason #864
1 parent fb0e325 commit 9bd0211

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsCertificateRevocationListRevokedCertificateTestCase.inc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,27 @@ class APIModelsCertificateRevocationListRevokedCertificateTestCase extends TestC
130130
},
131131
);
132132
}
133+
134+
/**
135+
* Ensures revoked certificates with non-numeric reasons are converted to -1 (unspecified) when reading #864
136+
*/
137+
public function test_non_numeric_reason_conversion(): void
138+
{
139+
# Mock a revoked certificate with a non-numeric reason
140+
Model::set_config(
141+
"crl/{$this->crl->id}/cert/0",
142+
[
143+
'certref' => $this->cert->refid->value,
144+
'reason' => 'some-non-numeric-reason',
145+
'revoke_time' => time(),
146+
],
147+
);
148+
149+
# Read the CRL and ensure the reason was converted to -1
150+
$crl_revoked_cert = CertificateRevocationListRevokedCertificate::query(
151+
parent_id: $this->crl->id,
152+
id: 0
153+
)->first();
154+
$this->assert_equals(-1, $crl_revoked_cert->reason->value);
155+
}
133156
}

0 commit comments

Comments
 (0)