Skip to content

Commit

Permalink
Merge pull request #1074 from praekelt/feature/MOMUG-352-adding-missi…
Browse files Browse the repository at this point in the history
…ng-publish-status-method

Add missing publish status method & remove SSLv3 Support
  • Loading branch information
erikh360 authored Aug 28, 2017
2 parents 1fb1c4c + 6372126 commit 0251858
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 36 deletions.
3 changes: 1 addition & 2 deletions vumi/application/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from OpenSSL.SSL import (
VERIFY_PEER, VERIFY_FAIL_IF_NO_PEER_CERT, VERIFY_CLIENT_ONCE, VERIFY_NONE,
SSLv3_METHOD, SSLv23_METHOD, TLSv1_METHOD)
SSLv23_METHOD, TLSv1_METHOD)

from vumi.config import ConfigText, ConfigInt, ConfigList, ConfigDict
from vumi.application.base import ApplicationWorker
Expand Down Expand Up @@ -883,7 +883,6 @@ def _make_request_from_command(self, method, command):
'VERIFY_FAIL_IF_NO_PEER_CERT': VERIFY_FAIL_IF_NO_PEER_CERT,
}
method_map = {
'SSLv3': SSLv3_METHOD,
'SSLv23': SSLv23_METHOD,
'TLSv1': TLSv1_METHOD,
}
Expand Down
36 changes: 2 additions & 34 deletions vumi/application/tests/test_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import warnings

from OpenSSL.SSL import (
VERIFY_PEER, VERIFY_FAIL_IF_NO_PEER_CERT, VERIFY_NONE,
SSLv3_METHOD, SSLv23_METHOD, TLSv1_METHOD)
VERIFY_PEER, VERIFY_FAIL_IF_NO_PEER_CERT, VERIFY_NONE, SSLv23_METHOD,
TLSv1_METHOD)

from twisted.internet.defer import (
inlineCallbacks, fail, succeed, DeferredQueue)
Expand Down Expand Up @@ -1097,15 +1097,6 @@ def test_make_context_factory_no_method_verify_none(self):
self.assertEqual(
self.get_context(context_factory).get_verify_mode(), VERIFY_NONE)

def test_make_context_factory_sslv3_verify_none(self):
context_factory = make_context_factory(
verify_options=VERIFY_NONE, ssl_method=SSLv3_METHOD)
self.assertIsInstance(context_factory, HttpClientContextFactory)
self.assertEqual(context_factory.verify_options, VERIFY_NONE)
self.assertEqual(context_factory.ssl_method, SSLv3_METHOD)
self.assertEqual(
self.get_context(context_factory).get_verify_mode(), VERIFY_NONE)

def test_make_context_factory_no_method_verify_peer(self):
# This test's behaviour depends on the version of Twisted being used.
context_factory = make_context_factory(verify_options=VERIFY_PEER)
Expand Down Expand Up @@ -1150,17 +1141,6 @@ def test_make_context_factory_no_method_no_verify(self):
else:
self.assertIsInstance(context_factory, HttpClientPolicyForHTTPS)

def test_make_context_factory_sslv3_no_verify(self):
# This test's behaviour depends on the version of Twisted being used.
context_factory = make_context_factory(ssl_method=SSLv3_METHOD)
self.assertEqual(context_factory.ssl_method, SSLv3_METHOD)
if HttpClientPolicyForHTTPS is None:
# We have Twisted<14.0.0
self.assertIsInstance(context_factory, HttpClientContextFactory)
self.assertEqual(context_factory.verify_options, None)
else:
self.assertIsInstance(context_factory, HttpClientPolicyForHTTPS)

@inlineCallbacks
def test_handle_get(self):
self.http_request_succeed("foo")
Expand Down Expand Up @@ -1337,18 +1317,6 @@ def test_https_request_method_default(self):
context_factory = self.get_context_factory()
self.assertEqual(context_factory.ssl_method, None)

@inlineCallbacks
def test_https_request_method_SSLv3(self):
self.http_request_succeed("foo")
reply = yield self.dispatch_command(
'get', url='https://www.example.com', ssl_method='SSLv3')
self.assertTrue(reply['success'])
self.assertEqual(reply['body'], "foo")
self.assert_http_request('https://www.example.com', method='GET')

context_factory = self.get_context_factory()
self.assertEqual(context_factory.ssl_method, SSLv3_METHOD)

@inlineCallbacks
def test_https_request_method_SSLv23(self):
self.http_request_succeed("foo")
Expand Down
5 changes: 5 additions & 0 deletions vumi/middleware/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ def handle_failure(self, failure, connector_name):
"""
return failure

def handle_publish_status(self, status, connector_name):
"""Called when a status is published.
"""
return status


class TransportMiddleware(BaseMiddleware):
"""Message processor middleware for Transports.
Expand Down

0 comments on commit 0251858

Please sign in to comment.