def decorated_function(*args, **kwargs):
        signature = request.headers.get('X-Sqreen-Integrity',
                                        str(uuid.uuid4()))
        if not signature_verification.check_signature(signature,
                                                      request.get_data()):
            response = {
                'error': 'You need to authenticated to access this API.'
            }
            return jsonify(response), 401

        # Valid Input is an array of events.
        if not request.get_json() or not type(request.get_json()) is list:
            response = {'error': 'Unprocessable Entity'}
            return jsonify(response), 422
        return f(*args, **kwargs)
 def test_valid_signature_for_playbook_event_payload(
         self, playbook_event_payload):
     header = sign_request(playbook_event_payload)
     request_body = json.dumps(playbook_event_payload).encode('utf-8')
     assert signature_verification.check_signature(header,
                                                   request_body) == True
 def test_valid_signature(self, request_body):
     header = sign_request(request_body)
     request_body = json.dumps(request_body).encode('utf-8')
     assert signature_verification.check_signature(header,
                                                   request_body) == True