def test_bad_client_fingerprint(self): transport1, transport2 = dummy_ice_transport_pair() certificate1 = RTCCertificate.generateCertificate() session1 = RTCDtlsTransport(transport1, [certificate1]) certificate2 = RTCCertificate.generateCertificate() session2 = RTCDtlsTransport(transport2, [certificate2]) bogus_parameters = RTCDtlsParameters( fingerprints=[ RTCDtlsFingerprint(algorithm="sha-256", value="bogus_fingerprint") ] ) run( asyncio.gather( session1.start(bogus_parameters), session2.start(session1.getLocalParameters()), ) ) self.assertEqual(session1.state, "failed") self.assertEqual(session2.state, "connected") run(session1.stop()) run(session2.stop())
def test_bad_client_fingerprint(self): transport1, transport2 = dummy_ice_transport_pair() certificate1 = RTCCertificate.generateCertificate() session1 = RTCDtlsTransport(transport1, [certificate1]) certificate2 = RTCCertificate.generateCertificate() session2 = RTCDtlsTransport(transport2, [certificate2]) bogus_parameters = RTCDtlsParameters( fingerprints=[RTCDtlsFingerprint(algorithm='sha-256', value='bogus_fingerprint')]) with self.assertRaises(DtlsError) as cm: run(asyncio.gather( session1.start(bogus_parameters), session2.start(session1.getLocalParameters()))) self.assertEqual(str(cm.exception), 'DTLS fingerprint does not match') self.assertEqual(session1.state, 'failed') self.assertEqual(session2.state, 'connecting') run(session1.stop()) run(session2.stop())