Пример #1
0
 def test_defaultFactory(self):
     proxy = FakeEndpoint()
     endpoint = client.SOCKS5ClientEndpoint('', 0, proxy)
     endpoint.connect(None)
     # PY3KPORT: Py2-3 compatible port using six
     self.assertEqual(proxy.transport.value(),
                      six.ensure_binary('\x05\x01\x00'))
Пример #2
0
 def test_justLoginAuth(self):
     proxy = FakeEndpoint()
     endpoint = client.SOCKS5ClientEndpoint('',
                                            0,
                                            proxy,
                                            methods={'login': ()})
     endpoint.connect(None)
     self.assertEqual(proxy.transport.value(), '\x05\x01\x02')
Пример #3
0
 def test_differentUser(self):
     proxy = FakeEndpoint()
     endpoint = client.SOCKS4ClientEndpoint('127.0.0.1', 0, proxy, 'spam')
     endpoint.connect(None)
     # Py3k fixes
     # PY3KPORT: Py2-3 compatible port using six
     self.assertEqual(
         proxy.transport.value(),
         six.ensure_binary('\x04\x01\x00\x00\x7f\x00\x00\x01spam\x00'))
Пример #4
0
 def test_hostname(self):
     proxy = FakeEndpoint()
     endpoint = client.SOCKS4ClientEndpoint('spam.com', 0, proxy)
     endpoint.connect(None)
     # PY3KPORT: Py2-3 compatible port using six
     self.assertEqual(
         proxy.transport.value(),
         six.ensure_binary(
             '\x04\x01\x00\x00\x00\x00\x00\x01\x00spam.com\x00'))
Пример #5
0
 def test_dataSentByPeer(self):
     wrappedFac = FakeFactory()
     proxy = FakeEndpoint()
     endpoint = client.SOCKS4ClientEndpoint('', 0, proxy)
     endpoint.connect(wrappedFac)
     proxy.proto.dataReceived('\x00\x5a\x00\x00\x00\x00\x00\x00')
     proxy.proto.transport.clear()
     wrappedFac.proto.transport.write('xxxxx')
     self.assertEqual(proxy.proto.transport.value(), 'xxxxx')
Пример #6
0
 def test_buildingWrappedFactory(self):
     wrappedFac = FakeFactory()
     proxy = FakeEndpoint()
     endpoint = client.SOCKS4ClientEndpoint('', 0, proxy)
     d = endpoint.connect(wrappedFac)
     proxy.proto.dataReceived('\x00\x5a\x00\x00\x00\x00\x00\x00xxxxx')
     d.addCallback(self.assertEqual, wrappedFac.proto)
     self.assertEqual(wrappedFac.proto.data, 'xxxxx')
     return d
Пример #7
0
 def test_dataSentByPeer(self):
     wrappedFac = FakeFactory()
     proxy = FakeEndpoint()
     endpoint = client.SOCKS4ClientEndpoint('', 0, proxy)
     endpoint.connect(wrappedFac)
     proxy.proto.dataReceived('\x00\x5a\x00\x00\x00\x00\x00\x00')
     proxy.proto.transport.clear()
     # PY3KPORT: Py2-3 compatible port using six
     wrappedFac.proto.transport.write(six.b('xxxxx'))
     self.assertEqual(proxy.proto.transport.value(), six.b('xxxxx'))
Пример #8
0
 def test_buildingWrappedFactory(self):
     wrappedFac = FakeFactory()
     proxy = FakeEndpoint()
     endpoint = client.SOCKS4ClientEndpoint('', 0, proxy)
     d = endpoint.connect(wrappedFac)
     proxy.proto.dataReceived('\x00\x5a\x00\x00\x00\x00\x00\x00xxxxx')
     d.addCallback(self.assertEqual, wrappedFac.proto)
     # PY3KPORT: Py2-3 compatible port using six
     self.assertEqual(wrappedFac.proto.data, six.b('xxxxx'))
     return d
Пример #9
0
 def test_justLoginAuth(self):
     proxy = FakeEndpoint()
     endpoint = client.SOCKS5ClientEndpoint('',
                                            0,
                                            proxy,
                                            methods={'login': ()})
     endpoint.connect(None)
     # PY3KPORT: Py2-3 compatible port using six
     self.assertEqual(proxy.transport.value(),
                      six.ensure_binary('\x05\x01\x02'))
Пример #10
0
 def test_anonymousAndLoginAuth(self):
     proxy = FakeEndpoint()
     endpoint = client.SOCKS5ClientEndpoint('',
                                            0,
                                            proxy,
                                            methods={
                                                'anonymous': (),
                                                'login': ()
                                            })
     endpoint.connect(None)
     # PY3KPORT: Py2-3 compatible port using six
     # This is sometimes coming a b'\x05\x02\x00\x02' and sometimes
     # as b'\x05\x02\x02\x00' in Python3!
     value = sorted(six.ensure_text(proxy.transport.value()))
     # So test just checks for the sorted value
     self.assertEqual(value, ['\x00', '\x02', '\x02', '\x05'])
Пример #11
0
 def test_clientConnectionFailed(self):
     proxy = FakeEndpoint(failure=connectionRefusedFailure)
     endpoint = client.SOCKS4ClientEndpoint('', 0, proxy)
     d = endpoint.connect(None)
     return self.assertFailure(d, ConnectionRefusedError)
Пример #12
0
 def setUp(self):
     self.endpoint = FakeEndpoint()
     self.agent = self.agentType(None, proxyEndpoint=self.endpoint)
     self.agent._tlsWrapper = self._tlsWrapper
Пример #13
0
 def setUp(self):
     self.endpoint = FakeEndpoint()
     self.context = object()
     self.wrapper = TLSWrapClientEndpoint(self.context, self.endpoint)
     self.wrapper._wrapper = UppercaseWrapperFactory
     self.factory = NetstringFactory()
Пример #14
0
 def test_differentUser(self):
     proxy = FakeEndpoint()
     endpoint = client.SOCKS4ClientEndpoint('127.0.0.1', 0, proxy, 'spam')
     endpoint.connect(None)
     self.assertEqual(proxy.transport.value(),
                      '\x04\x01\x00\x00\x7f\x00\x00\x01spam\x00')
Пример #15
0
 def test_hostname(self):
     proxy = FakeEndpoint()
     endpoint = client.SOCKS4ClientEndpoint('spam.com', 0, proxy)
     endpoint.connect(None)
     self.assertEqual(proxy.transport.value(),
                      '\x04\x01\x00\x00\x00\x00\x00\x01\x00spam.com\x00')
Пример #16
0
 def test_defaultFactory(self):
     proxy = FakeEndpoint()
     endpoint = client.SOCKS4ClientEndpoint('127.0.0.1', 0, proxy)
     endpoint.connect(None)
     self.assertEqual(proxy.transport.value(),
                      '\x04\x01\x00\x00\x7f\x00\x00\x01\x00')