@@ -215,4 +215,42 @@ public function testPrepareAuthBasic($arg, $result)
215215 [, $ options ] = $ this ->prepareRequest ('POST ' , 'http://example.com ' , ['auth_basic ' => $ arg ], HttpClientInterface::OPTIONS_DEFAULTS );
216216 $ this ->assertSame ('Basic ' .$ result , $ options ['headers ' ]['authorization ' ][0 ]);
217217 }
218+
219+ public function provideFingerprints ()
220+ {
221+ foreach (['md5 ' , 'sha1 ' , 'sha256 ' ] as $ algo ) {
222+ $ hash = \hash ($ algo , $ algo );
223+ yield [$ hash , [$ algo => $ hash ]];
224+ }
225+
226+ yield ['AAAA:BBBB:CCCC:DDDD:EEEE:FFFF:GGGG:HHHH:IIII:JJJJ:KKKK ' , ['pin-sha256 ' => ['AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKK ' ]]];
227+ }
228+
229+ /**
230+ * @dataProvider provideFingerprints
231+ */
232+ public function testNormalizePeerFingerprint ($ fingerprint , $ expected )
233+ {
234+ self ::assertSame ($ expected , $ this ->normalizePeerFingerprint ($ fingerprint ));
235+ }
236+
237+ /**
238+ * @expectedException \Symfony\Component\HttpClient\Exception\InvalidArgumentException
239+ * @expectedExceptionMessage Cannot auto-detect fingerprint algorithm for "foo".
240+ */
241+ public function testNormalizePeerFingerprintException ()
242+ {
243+ $ this ->normalizePeerFingerprint ('foo ' );
244+ }
245+
246+ /**
247+ * @expectedException \Symfony\Component\HttpClient\Exception\InvalidArgumentException
248+ * @expectedExceptionMessage Option "peer_fingerprint" must be string or array, object given.
249+ */
250+ public function testNormalizePeerFingerprintTypeException ()
251+ {
252+ $ fingerprint = new \stdClass ();
253+
254+ $ this ->normalizePeerFingerprint ($ fingerprint );
255+ }
218256}
0 commit comments