def test_success_pattern(self): authorization = SingleTeamAuthorization(auth_test_result={}) req = BoltRequest(body="payload={}", headers={}) req.context["client"] = WebClient( base_url=self.mock_api_server_base_url, token="xoxb-valid" ) resp = BoltResponse(status=404) resp = authorization.process(req=req, resp=resp, next=next) assert resp.status == 200 assert resp.body == ""
def test_failure_pattern(self): authorization = SingleTeamAuthorization(auth_test_result={}) req = BoltRequest(body="payload={}", headers={}) req.context["client"] = WebClient( base_url=self.mock_api_server_base_url, token="dummy" ) resp = BoltResponse(status=404) resp = authorization.process(req=req, resp=resp, next=next) assert resp.status == 200 assert resp.body == ":x: Please install this app into the workspace :bow:"
def _init_middleware_list(self): if self._init_middleware_list_done: return self._middleware_list.append( SslCheck(verification_token=self._verification_token) ) self._middleware_list.append(RequestVerification(self._signing_secret)) if self._oauth_flow is None: if self._token is not None: try: auth_test_result = self._client.auth_test(token=self._token) self._middleware_list.append( SingleTeamAuthorization(auth_test_result=auth_test_result) ) except SlackApiError as err: raise BoltError(error_auth_test_failure(err.response)) elif self._authorize is not None: self._middleware_list.append( MultiTeamsAuthorization(authorize=self._authorize) ) else: raise BoltError(error_token_required()) else: self._middleware_list.append( MultiTeamsAuthorization(authorize=self._authorize) ) self._middleware_list.append(IgnoringSelfEvents()) self._middleware_list.append(UrlVerification()) self._init_middleware_list_done = True
def _init_middleware_list(self): if self._init_middleware_list_done: return self._middleware_list.append( SslCheck(verification_token=self._verification_token)) self._middleware_list.append(RequestVerification(self._signing_secret)) if self._oauth_flow is None: if self._token: self._middleware_list.append(SingleTeamAuthorization()) else: raise BoltError( "OAuthFlow not found, so could not initialize the Bolt app." ) else: self._middleware_list.append( MultiTeamsAuthorization( installation_store=self._installation_store, verification_enabled=self._authorization_test_enabled, )) self._middleware_list.append(IgnoringSelfEvents()) self._middleware_list.append(UrlVerification()) self._init_middleware_list_done = True