Repository: slackapi/python-slack-events-api

Issue:
Lack of X-Slack-Request-Timestamp and/or X-Slack-Signature in requests results in 500
### Description

I noticed that a test I wrote to simulate a user probing the events URL returned a 500 when I would have expected a 400.

### What type of issue is this? (place an `x` in one of the `[ ]`)
- [x] bug
- [ ] enhancement (feature request)
- [ ] question
- [ ] documentation related
- [ ] testing related
- [ ] discussion

### Requirements
* [x] I've read and understood the [Contributing guidelines](https://github.com/slackapi/python-slack-events-api/blob/master/.github/contributing.md) and have done my best effort to follow them. -- _However, Spotify, my employer, has not yet signed the CLA to my knowledge, so I will not be able to submit a patch until they do._
* [x] I've read and agree to the [Code of Conduct](https://slackhq.github.io/code-of-conduct).
* [x] I've searched for any related issues and avoided creating a duplicate issue.

### Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

#### Reproducible in:
slackeventsapi version: 2.2.0
python version: 3.6
OS version(s): irrelevant, but Linux and MacOS

#### Steps to reproduce:

1. Make a POST request to a slack events URL without `X-Slack-Events-Timestamp` in the headers.
2. Observe response of 500 and subsequent TypeError raised

#### Expected result:

A 400 error.

#### Actual result:

500 and unhandled exception.

#### Attachments:


Discussion:

Patch:
diff --git a/slackeventsapi/server.py b/slackeventsapi/server.py
index c1436e5..74afca5 100644
--- a/slackeventsapi/server.py
+++ b/slackeventsapi/server.py
@@ -89,7 +89,7 @@ class SlackServer(Flask):
             # Each request comes with request timestamp and request signature
             # emit an error if the timestamp is out of range
             req_timestamp = request.headers.get('X-Slack-Request-Timestamp')
-            if abs(time() - int(req_timestamp)) > 60 * 5:
+            if req_timestamp is None or abs(time() - int(req_timestamp)) > 60 * 5:
                 slack_exception = SlackEventAdapterException('Invalid request timestamp')
                 self.emitter.emit('error', slack_exception)
                 return make_response("", 403)
@@ -97,7 +97,7 @@ class SlackServer(Flask):
             # Verify the request signature using the app's signing secret
             # emit an error if the signature can't be verified
             req_signature = request.headers.get('X-Slack-Signature')
-            if not self.verify_signature(req_timestamp, req_signature):
+            if req_signature is None or not self.verify_signature(req_timestamp, req_signature):
                 slack_exception = SlackEventAdapterException('Invalid request signature')
                 self.emitter.emit('error', slack_exception)
                 return make_response("", 403)


Test patch:
diff --git a/tests/test_server.py b/tests/test_server.py
index 172d475..a66a560 100644
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -56,6 +56,32 @@ def test_url_challenge(client):
     assert bytes.decode(res.data) == "valid_challenge_token"
 
 
+def test_no_request_timestamp_header(client):
+    data = pytest.reaction_event_fixture
+    with pytest.raises(SlackEventAdapterException) as excinfo:
+        res = client.post(
+            '/slack/events',
+            data=data,
+            content_type='application/json',
+            headers={}
+        )
+    assert str(excinfo.value) == 'Invalid request timestamp'
+
+def test_no_request_signature_header(client):
+    data = pytest.reaction_event_fixture
+    timestamp = int(time.time())
+    with pytest.raises(SlackEventAdapterException) as excinfo:
+        res = client.post(
+            '/slack/events',
+            data=data,
+            content_type='application/json',
+            headers={
+                'X-Slack-Request-Timestamp': timestamp, # valid
+            }
+        )
+    assert str(excinfo.value) == 'Invalid request signature'
+
+
 def test_invalid_request_signature(client):
     # Verify [package metadata header is set
     slack_adapter = SlackEventAdapter("SIGNING_SECRET")