Skip to content

Commit 70b5560

Browse files
committed
fixed some unit tests
1 parent 07ca407 commit 70b5560

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

tests/unit/Swift/Signers/SMimeSignerTest.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,14 @@ public function testSingedMessage()
6262
6363
Here is the message itself
6464
--$boundary
65-
Content-Type: application/pkcs7-signature; name="smime\.p7s"
65+
Content-Type: application/(x\-)?pkcs7-signature; name="smime\.p7s"
6666
Content-Transfer-Encoding: base64
6767
Content-Disposition: attachment; filename="smime\.p7s"
6868
6969
(?:^[a-zA-Z0-9\/\\r\\n+]*={0,2})
7070
7171
--$boundary--
7272
OEL;
73-
7473
$this->assertValidVerify($expectedBody, $messageStream);
7574
unset($messageStream);
7675
}
@@ -93,7 +92,7 @@ public function testSingedMessageBinary()
9392
$entityString = $messageStream->getContent();
9493
$headers = self::getHeadersOfMessage($entityString);
9594

96-
if ('application/pkcs7-mime; smime-type=signed-data;' !== substr($headers['content-type'], 0, 47)) {
95+
if (!preg_match('#^application/(x\-)?pkcs7-mime; smime-type=signed\-data;#', $headers['content-type'])) {
9796
$this->fail('Content-type does not match.');
9897

9998
return false;
@@ -161,7 +160,7 @@ public function testSingedMessageWithAttachments()
161160
--\\1--
162161
163162
--$boundary
164-
Content-Type: application/pkcs7-signature; name="smime\\.p7s"
163+
Content-Type: application/(x\-)?pkcs7-signature; name="smime\\.p7s"
165164
Content-Transfer-Encoding: base64
166165
Content-Disposition: attachment; filename="smime\\.p7s"
167166
@@ -194,7 +193,7 @@ public function testEncryptedMessage()
194193
$entityString = $messageStream->getContent();
195194
$headers = self::getHeadersOfMessage($entityString);
196195

197-
if ('application/pkcs7-mime; smime-type=enveloped-data;' !== substr($headers['content-type'], 0, 50)) {
196+
if (!preg_match('#^application/(x\-)?pkcs7-mime; smime-type=enveloped\-data;#', $headers['content-type'])) {
198197
$this->fail('Content-type does not match.');
199198

200199
return false;
@@ -232,7 +231,7 @@ public function testEncryptedMessageWithMultipleCerts()
232231
$entityString = $messageStream->getContent();
233232
$headers = self::getHeadersOfMessage($entityString);
234233

235-
if ('application/pkcs7-mime; smime-type=enveloped-data;' !== substr($headers['content-type'], 0, 50)) {
234+
if (!preg_match('#^application/(x\-)?pkcs7-mime; smime-type=enveloped\-data;#', $headers['content-type'])) {
236235
$this->fail('Content-type does not match.');
237236

238237
return false;
@@ -278,7 +277,7 @@ public function testSignThenEncryptedMessage()
278277
$entityString = $messageStream->getContent();
279278
$headers = self::getHeadersOfMessage($entityString);
280279

281-
if ('application/pkcs7-mime; smime-type=enveloped-data;' !== substr($headers['content-type'], 0, 50)) {
280+
if (!preg_match('#^application/(x\-)?pkcs7-mime; smime-type=enveloped\-data;#', $headers['content-type'])) {
282281
$this->fail('Content-type does not match.');
283282

284283
return false;
@@ -308,7 +307,7 @@ public function testSignThenEncryptedMessage()
308307
309308
Here is the message itself
310309
--$boundary
311-
Content-Type: application/pkcs7-signature; name="smime\.p7s"
310+
Content-Type: application/(x\-)?pkcs7-signature; name="smime\.p7s"
312311
Content-Transfer-Encoding: base64
313312
Content-Disposition: attachment; filename="smime\.p7s"
314313
@@ -356,14 +355,14 @@ public function testEncryptThenSignMessage()
356355
--$boundary
357356
(?P<encrypted_message>MIME-Version: 1\.0
358357
Content-Disposition: attachment; filename="smime\.p7m"
359-
Content-Type: application/pkcs7-mime; smime-type=enveloped-data; name="smime\.p7m"
358+
Content-Type: application/(x\-)?pkcs7-mime; smime-type=enveloped-data; name="smime\.p7m"
360359
Content-Transfer-Encoding: base64
361360
362361
(?:^[a-zA-Z0-9\/\\r\\n+]*={0,2})
363362
364363
365364
)--$boundary
366-
Content-Type: application/pkcs7-signature; name="smime\.p7s"
365+
Content-Type: application/(x\-)?pkcs7-signature; name="smime\.p7s"
367366
Content-Transfer-Encoding: base64
368367
Content-Disposition: attachment; filename="smime\.p7s"
369368

0 commit comments

Comments
 (0)