|
4 | 4 | from slack_sdk.oauth.state_store import FileOAuthStateStore |
5 | 5 |
|
6 | 6 | from slack_bolt.async_app import AsyncApp |
| 7 | +from slack_bolt.authorization import AuthorizeResult |
7 | 8 | from slack_bolt.error import BoltError |
8 | 9 | from slack_bolt.oauth.async_oauth_flow import AsyncOAuthFlow |
9 | 10 | from slack_bolt.oauth.async_oauth_settings import AsyncOAuthSettings |
@@ -98,3 +99,31 @@ def test_valid_multi_auth_secret_absence(self): |
98 | 99 | signing_secret="valid", |
99 | 100 | oauth_settings=OAuthSettings(client_id="111.222", client_secret=None), |
100 | 101 | ) |
| 102 | + |
| 103 | + def test_authorize_conflicts(self): |
| 104 | + oauth_settings = OAuthSettings( |
| 105 | + client_id="111.222", |
| 106 | + client_secret="valid", |
| 107 | + installation_store=FileInstallationStore(), |
| 108 | + state_store=FileOAuthStateStore(expiration_seconds=120), |
| 109 | + ) |
| 110 | + |
| 111 | + # no error with this |
| 112 | + AsyncApp(signing_secret="valid", oauth_settings=oauth_settings) |
| 113 | + |
| 114 | + def authorize() -> AuthorizeResult: |
| 115 | + return AuthorizeResult(enterprise_id="E111", team_id="T111") |
| 116 | + |
| 117 | + with pytest.raises(BoltError): |
| 118 | + AsyncApp( |
| 119 | + signing_secret="valid", |
| 120 | + authorize=authorize, |
| 121 | + oauth_settings=oauth_settings, |
| 122 | + ) |
| 123 | + |
| 124 | + oauth_flow = AsyncOAuthFlow(settings=oauth_settings) |
| 125 | + # no error with this |
| 126 | + AsyncApp(signing_secret="valid", oauth_flow=oauth_flow) |
| 127 | + |
| 128 | + with pytest.raises(BoltError): |
| 129 | + AsyncApp(signing_secret="valid", authorize=authorize, oauth_flow=oauth_flow) |
0 commit comments