Skip to content

Commit fc89d71

Browse files
committed
test: extend CRL provider edge coverage
Signed-off-by: Vitor Mattos <[email protected]>
1 parent 94decce commit fc89d71

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

lib/Service/Crl/CrlDistributionPointsExtractor.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ public function extractFromExtensions(array $extensions): array {
4848
foreach ($values as $value) {
4949
preg_match_all('/URI\s*:\s*([^\s\n]+)/i', $value, $matches);
5050
if (!empty($matches[1])) {
51-
$urls = [...$urls, ...$matches[1]];
51+
$normalizedUrls = array_map(
52+
static fn (string $url): string => rtrim($url, ")]"),
53+
$matches[1],
54+
);
55+
$urls = [...$urls, ...$normalizedUrls];
5256
}
5357
}
5458

tests/php/Unit/Service/Crl/CrlDistributionPointsExtractorTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ public static function crlDistributionPointExtractionProvider(): array {
8989
true,
9090
['ldap://ldap.example.net/cn=CA,dc=example,dc=net?certificateRevocationList;binary'],
9191
],
92+
'uri-with-tabs-and-extra-whitespace' => [
93+
[
94+
'2.5.29.31' => "Full Name:\n\tURI\t:\t https://example.org/crl/with-tabs.crl",
95+
],
96+
true,
97+
['https://example.org/crl/with-tabs.crl'],
98+
],
99+
'uri-line-with-closing-parenthesis-from-formatted-output' => [
100+
[
101+
'2.5.29.31' => "Distribution Point (1):\nURI:https://example.org/crl/formatted.crl)",
102+
],
103+
true,
104+
['https://example.org/crl/formatted.crl'],
105+
],
92106
'multiple-supported-extension-keys-are-merged-and-deduplicated' => [
93107
[
94108
'2.5.29.31' => "Full Name:\nURI:https://example.org/crl/shared.crl",
@@ -118,6 +132,24 @@ public static function crlDistributionPointExtractionProvider(): array {
118132
true,
119133
[],
120134
],
135+
'known-extension-with-general-names-but-no-uri' => [
136+
[
137+
'X509v3 CRL Distribution Points' => "Full Name:\nDNS:crl.example.org\nDirName:/C=BR/O=Example/CN=CRL Directory",
138+
],
139+
true,
140+
[],
141+
],
142+
'multiple-supported-keys-preserve-first-seen-order' => [
143+
[
144+
'crlDistributionPoints' => "Full Name:\nURI:https://example.org/crl/first.crl",
145+
'2.5.29.31' => "Full Name:\nURI:https://example.org/crl/second.crl",
146+
],
147+
true,
148+
[
149+
'https://example.org/crl/first.crl',
150+
'https://example.org/crl/second.crl',
151+
],
152+
],
121153
'unknown-extension-name-should-not-match' => [
122154
[
123155
'Issuer CRL Distribution Points' => "Full Name:\nURI:https://example.org/crl/issuer.crl",

0 commit comments

Comments
 (0)