How to use the messagebird.signed_request.SignedRequest function in messagebird

To help you get started, we’ve selected a few messagebird examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github messagebird / python-rest-api / tests / test_signed_request.py View on Github external
def test_not_recent_signed_request(self):
        query = {}
        signature = 'KVBdcVdz2lYMwcBLZCRITgxUfA/WkwSi+T3Wxl2HL6w='
        timestamp = int(time.time()) - 100
        body = ''

        signed_request = SignedRequest(signature, timestamp, body, query)
        self.assertFalse(signed_request.is_recent())
github messagebird / python-rest-api / tests / test_signed_request.py View on Github external
def test_incorrectly_signed_request(self):
        query = {
            'recipient': '31612345678',
            'reference': 'BAR',
            'statusDatetime': '2019-01-11T09:17:11+00:00',
            'id': 'eef0ab57a9e049be946f3821568c2b2e',
            'status': 'delivered',
            'mccmnc': '20408',
            'ported': '1',
        }

        signature = 'KVBdcVdz2lYMwcBLZCRITgxUfA/WkwSi+T3Wxl2HL6w='
        timestamp = 1547198231
        body = ''

        signed_request = SignedRequest(signature, timestamp, body, query)
        self.assertFalse(signed_request.verify(SIGNING_KEY))
github messagebird / python-rest-api / tests / test_signed_request.py View on Github external
def test_recent_signed_request(self):
        query = {}
        signature = 'KVBdcVdz2lYMwcBLZCRITgxUfA/WkwSi+T3Wxl2HL6w='
        timestamp = int(time.time()) - 1
        body = ''

        signed_request = SignedRequest(signature, timestamp, body, query)
        self.assertTrue(signed_request.is_recent())
github messagebird / python-rest-api / tests / test_signed_request.py View on Github external
def test_signed_request_with_body(self):
        query = {
            'recipient': '31612345678',
            'reference': 'FOO',
            'statusDatetime': '2019-01-11T09:17:11+00:00',
            'id': 'eef0ab57a9e049be946f3821568c2b2e',
            'status': 'delivered',
            'mccmnc': '20408',
            'ported': '1',
        }

        signature = '2bl+38H4oHVg03pC3bk2LvCB0IHFgfC4cL5HPQ0LdmI='
        timestamp = 1547198231
        body = '{"foo":"bar"}'

        signed_request = SignedRequest(signature, timestamp, body, query)
        self.assertTrue(signed_request.verify(SIGNING_KEY))
github messagebird / python-rest-api / tests / test_signed_request.py View on Github external
def test_signed_request_withou_body(self):
        query = {
            'recipient': '31612345678',
            'reference': 'FOO',
            'statusDatetime': '2019-01-11T09:17:11+00:00',
            'id': 'eef0ab57a9e049be946f3821568c2b2e',
            'status': 'delivered',
            'mccmnc': '20408',
            'ported': '1',
        }

        signature = 'KVBdcVdz2lYMwcBLZCRITgxUfA/WkwSi+T3Wxl2HL6w='
        timestamp = 1547198231
        body = ''

        signed_request = SignedRequest(signature, timestamp, body, query)
        self.assertTrue(signed_request.verify(SIGNING_KEY))