@@ -109,12 +109,12 @@ def build_headers(self, timestamp: str, body: str):
109109 "x-slack-request-timestamp" : [timestamp ],
110110 }
111111
112- def build_request (self ):
112+ def build_request (self , team_id : str = "T014GJXU940" ):
113113 timestamp , body = str (int (time ())), json .dumps (
114114 {
115- "team_id" : "T014GJXU940" ,
115+ "team_id" : team_id ,
116116 "enterprise_id" : "E013Y3SHLAY" ,
117- "context_team_id" : "T014GJXU940" ,
117+ "context_team_id" : team_id ,
118118 "context_enterprise_id" : "E013Y3SHLAY" ,
119119 "api_app_id" : "A04TEM7H4S0" ,
120120 "event" : {
@@ -123,7 +123,7 @@ def build_request(self):
123123 "upload" : False ,
124124 "user" : "W013QGS7BPF" ,
125125 "display_as_bot" : False ,
126- "team" : "T014GJXU940" ,
126+ "team" : team_id ,
127127 "channel" : "C04T3ACM40K" ,
128128 "subtype" : "file_share" ,
129129 },
@@ -176,3 +176,38 @@ def handle_events(context: BoltContext, say: Say):
176176 assert_auth_test_count (self , 1 )
177177 sleep (1 ) # wait a bit after auto ack()
178178 assert self .mock_received_requests ["/chat.postMessage" ] == 1
179+
180+ def test_authorize_result_no_user_token (self ):
181+ app = App (
182+ client = self .web_client ,
183+ signing_secret = self .signing_secret ,
184+ oauth_settings = OAuthSettings (
185+ client_id = "111.222" ,
186+ client_secret = "secret" ,
187+ scopes = ["commands" , "chat:write" ],
188+ user_scopes = ["search:read" , "chat:write" ],
189+ installation_store = MemoryInstallationStore (),
190+ user_token_resolution = "actor" ,
191+ ),
192+ )
193+
194+ @app .event ("message" )
195+ def handle_events (context : BoltContext , say : Say ):
196+ assert context .actor_enterprise_id == "E013Y3SHLAY"
197+ assert context .actor_team_id == "T111111"
198+ assert context .actor_user_id == "W013QGS7BPF"
199+
200+ assert context .authorize_result .bot_id == "BZYBOTHED"
201+ assert context .authorize_result .bot_user_id == "W23456789"
202+ assert context .authorize_result .bot_token == "xoxb-valid-2"
203+ assert context .authorize_result .bot_scopes == ["commands" , "chat:write" ]
204+ assert context .authorize_result .user_id is None
205+ assert context .authorize_result .user_token is None
206+ assert context .authorize_result .user_scopes is None
207+ say ("What's up?" )
208+
209+ response = app .dispatch (self .build_request (team_id = "T111111" ))
210+ assert response .status == 200
211+ assert_auth_test_count (self , 1 )
212+ sleep (1 ) # wait a bit after auto ack()
213+ assert self .mock_received_requests ["/chat.postMessage" ] == 1
0 commit comments