Ejemplo n.º 1
0
 def test_cellRecognized_too_short(self):
     payload = '\x00\x00\x00\x00\x00\x00'
     relay_crypto = mock.Mock()
     relay_crypto.backward_digest = mock.Mock()
     relay_crypto.backward_digest.copy = mock.Mock()
     self.assertFalse(util._cellRecognized(payload, relay_crypto))
     self.assertEqual(relay_crypto.backward_digest.copy.call_count, 0)
Ejemplo n.º 2
0
 def test_cellRecognized_too_short(self):
     payload = '\x00\x00\x00\x00\x00\x00'
     relay_crypto = mock.Mock()
     relay_crypto.backward_digest = mock.Mock()
     relay_crypto.backward_digest.copy = mock.Mock()
     self.assertFalse(util._cellRecognized(payload, relay_crypto))
     self.assertEqual(relay_crypto.backward_digest.copy.call_count, 0)
Ejemplo n.º 3
0
    def test_cellRecognized_no(self, mock_mpwd):
        payload = '\x01\x01\x00\x00\x00\x0a\x0a\x0a\x0a'
        relay_crypto = mock.Mock()
        relay_crypto.backward_digest = mock.Mock()
        relay_crypto.backward_digest.copy = mock.Mock()
        mock_td = mock.Mock()
        relay_crypto.backward_digest.copy.return_value = mock_td
        mock_td.update = mock.Mock()
        mock_td.digest = mock.Mock()
        mock_td.digest.return_value = '\x0a\x0a\x0a\x0b'

        ret = util._cellRecognized(payload, relay_crypto)

        mock_td.update.assert_called_once_with('test payload')
        self.assertFalse(ret)
Ejemplo n.º 4
0
    def test_cellRecognized_no(self, mock_mpwd):
        payload = '\x01\x01\x00\x00\x00\x0a\x0a\x0a\x0a'
        relay_crypto = mock.Mock()
        relay_crypto.backward_digest = mock.Mock()
        relay_crypto.backward_digest.copy = mock.Mock()
        mock_td = mock.Mock()
        relay_crypto.backward_digest.copy.return_value = mock_td
        mock_td.update = mock.Mock()
        mock_td.digest = mock.Mock()
        mock_td.digest.return_value = '\x0a\x0a\x0a\x0b'

        ret = util._cellRecognized(payload, relay_crypto)

        mock_td.update.assert_called_once_with('test payload')
        self.assertFalse(ret)