def test_signing_secret_bad(self): self.request.data = { "token": options.get("slack.verification-token"), "challenge": "abc123", "type": "url_verification", } self.request.body = urlencode(self.request.data).encode("utf-8") self.request.META = set_signing_secret("bad_key", self.request.body) with self.assertRaises(SlackRequestError) as e: self.slack_request.validate() assert e.status == 401
def get_slack_response( self, payload: Mapping[str, str], status_code: Optional[str] = None ) -> Response: """Shadow get_success_response but with a non-JSON payload.""" data = urlencode(payload).encode("utf-8") response = self.client.post( reverse(self.endpoint), content_type="application/x-www-form-urlencoded", data=data, **set_signing_secret(options.get("slack.signing-secret"), data), ) assert response.status_code == (status_code or status.HTTP_200_OK) return response
def setUp(self): super().setUp() self.request = mock.Mock() self.request.data = { "type": "foo", "team_id": "T001", "channel": {"id": "1"}, "user": {"id": "2"}, "api_app_id": "S1", } self.request.body = urlencode(self.request.data).encode("utf-8") self.request.META = set_signing_secret( options.get("slack.signing-secret"), self.request.body )
def setUp(self): super().setUp() self.request = mock.Mock() self.request.data = { "payload": json.dumps( { "type": "foo", "team": {"id": "T001"}, "channel": {"id": "1"}, "user": {"id": "2"}, "token": options.get("slack.verification-token"), "callback_id": '{"issue":"I1"}', } ) } self.request.body = urlencode(self.request.data).encode("utf-8") self.request.META = set_signing_secret( options.get("slack.signing-secret"), self.request.body )