|
1 | 1 | from time import time |
2 | 2 |
|
| 3 | +import pytest |
3 | 4 | from slack_sdk.signature import SignatureVerifier |
4 | 5 |
|
5 | 6 | from slack_bolt.middleware import RequestVerification |
@@ -60,3 +61,21 @@ def test_ssl_check_param_requires_valid_signature(self): |
60 | 61 | resp = middleware.process(req=req, resp=resp, next=next) |
61 | 62 | assert resp.status == 401 |
62 | 63 | assert resp.body == """{"error": "invalid request"}""" |
| 64 | + |
| 65 | + def test_empty_signing_secret_does_not_raise_on_init(self): |
| 66 | + RequestVerification(signing_secret="") |
| 67 | + |
| 68 | + def test_socket_mode_request_skips_verification_without_signing_secret(self): |
| 69 | + middleware = RequestVerification(signing_secret="") |
| 70 | + req = BoltRequest(mode="socket_mode", body="payload={}", headers={}) |
| 71 | + resp = BoltResponse(status=404, body="default") |
| 72 | + resp = middleware.process(req=req, resp=resp, next=next) |
| 73 | + assert resp.status == 200 |
| 74 | + assert resp.body == "next" |
| 75 | + |
| 76 | + def test_http_request_with_empty_signing_secret_raises(self): |
| 77 | + middleware = RequestVerification(signing_secret="") |
| 78 | + req = BoltRequest(body="payload={}", headers={}) |
| 79 | + resp = BoltResponse(status=404) |
| 80 | + with pytest.raises(ValueError): |
| 81 | + middleware.process(req=req, resp=resp, next=next) |
0 commit comments