|
1 | 1 | from slack_sdk import WebClient |
| 2 | +from slack_sdk.web import SlackResponse |
2 | 3 |
|
3 | 4 | from slack_bolt.middleware import SingleTeamAuthorization |
4 | 5 | from slack_bolt.middleware.authorization.internals import _build_user_facing_authorize_error_message |
@@ -34,6 +35,29 @@ def test_success_pattern(self): |
34 | 35 | assert resp.status == 200 |
35 | 36 | assert resp.body == "" |
36 | 37 |
|
| 38 | + def test_success_pattern_with_bot_scopes(self): |
| 39 | + client = WebClient(base_url=self.mock_api_server_base_url, token="xoxb-valid") |
| 40 | + auth_test_result: SlackResponse = SlackResponse( |
| 41 | + client=client, |
| 42 | + http_verb="POST", |
| 43 | + api_url="https://slack.com/api/auth.test", |
| 44 | + req_args={}, |
| 45 | + data={}, |
| 46 | + headers={"x-oauth-scopes": "chat:write,commands"}, |
| 47 | + status_code=200, |
| 48 | + ) |
| 49 | + authorization = SingleTeamAuthorization(auth_test_result=auth_test_result) |
| 50 | + req = BoltRequest(body="payload={}", headers={}) |
| 51 | + req.context["client"] = client |
| 52 | + resp = BoltResponse(status=404) |
| 53 | + |
| 54 | + resp = authorization.process(req=req, resp=resp, next=next) |
| 55 | + |
| 56 | + assert resp.status == 200 |
| 57 | + assert resp.body == "" |
| 58 | + assert req.context.authorize_result.bot_scopes == ["chat:write", "commands"] |
| 59 | + assert req.context.authorize_result.user_scopes is None |
| 60 | + |
37 | 61 | def test_failure_pattern(self): |
38 | 62 | authorization = SingleTeamAuthorization(auth_test_result={}) |
39 | 63 | req = BoltRequest(body="payload={}", headers={}) |
|
0 commit comments