|
@@ -74,36 +74,26 @@ class SlackRequestTest(TestCase):
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- def test_validate_existence_of_data(self):
|
|
|
- type(self.request).DATA = mock.PropertyMock(side_effect=ValueError())
|
|
|
-
|
|
|
- with pytest.raises(SlackRequestError):
|
|
|
- self.slack_request.validate()
|
|
|
-
|
|
|
+ @pytest.mark.xfail(strict=True, reason="crashes in _log_request before validation can occur")
|
|
|
def test_returns_400_on_invalid_data(self):
|
|
|
- type(self.request).DATA = mock.PropertyMock(side_effect=ValueError())
|
|
|
+ type(self.request).data = mock.PropertyMock(side_effect=ValueError())
|
|
|
|
|
|
with pytest.raises(SlackRequestError) as e:
|
|
|
self.slack_request.validate()
|
|
|
- assert e.status == 400
|
|
|
-
|
|
|
- def test_validates_token(self):
|
|
|
- self.request.data["token"] = "notthetoken"
|
|
|
-
|
|
|
- with pytest.raises(SlackRequestError):
|
|
|
- self.slack_request.validate()
|
|
|
+ assert e.value.status == 400
|
|
|
|
|
|
+ @override_options({"slack.signing-secret": None}) # force token-auth
|
|
|
def test_returns_401_on_invalid_token(self):
|
|
|
self.request.data["token"] = "notthetoken"
|
|
|
|
|
|
with pytest.raises(SlackRequestError) as e:
|
|
|
self.slack_request.validate()
|
|
|
- assert e.status == 401
|
|
|
+ assert e.value.status == 401
|
|
|
|
|
|
def test_validates_existence_of_integration(self):
|
|
|
with pytest.raises(SlackRequestError) as e:
|
|
|
self.slack_request.validate()
|
|
|
- assert e.status == 403
|
|
|
+ assert e.value.status == 403
|
|
|
|
|
|
def test_none_in_data(self):
|
|
|
request = mock.Mock()
|
|
@@ -201,7 +191,7 @@ class SlackEventRequestTest(TestCase):
|
|
|
self.request.META = set_signing_secret("bad_key", self.request.body)
|
|
|
with pytest.raises(SlackRequestError) as e:
|
|
|
self.slack_request.validate()
|
|
|
- assert e.status == 401
|
|
|
+ assert e.value.status == 401
|
|
|
|
|
|
def test_use_verification_token(self):
|
|
|
with override_options({"slack.signing-secret": None}):
|