-
-
Notifications
You must be signed in to change notification settings - Fork 781
Open
Labels
Description
I'm trying to write some tests for the msexchange pack and hitting some issues with the BaseActionTestCase because the pack uses the st2 client to read and write cache entries...
from collections import namedtuple
import os
from st2common.runners.base_action import Action
from st2client.client import Client
from st2client.models import KeyValuePair
from exchangelib import Account, Credentials, Configuration, DELEGATE, EWSTimeZone
CacheEntry = namedtuple('CacheEntry', 'ews_url ews_auth_type primary_smtp_address')
class BaseExchangeAction(Action):
def __init__(self, config):
super(BaseExchangeAction, self).__init__(config)
api_url = os.environ.get('ST2_ACTION_API_URL', None)
token = os.environ.get('ST2_ACTION_AUTH_TOKEN', None)
self.client = Client(api_url=api_url, token=token)On both CircleCI for the pack and when I test using the Vagrant image, because the ST2_ACTION_AUTH_TOKEN is not set on the runner. What is the correct way to get around this?
======================================================================
5) ERROR: test_run_get_test_folder (search_items_test_case.SearchItemsActionTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
tests/search_items_test_case.py line 9 in test_run_get_test_folder
result = self.get_action_instance(config=self._test_config).run(
/opt/stackstorm/st2/lib/python3.6/site-packages/st2tests/actions.py line 48 in get_action_instance
action_service=self.action_service)
/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/runners/utils.py line 143 in get_action_class_instance
action_instance = action_cls(**kwargs)
actions/base/action.py line 27 in __init__
cache = self._get_cache()
actions/base/action.py line 70 in _get_cache
name='exchange_ews_url')
/opt/stackstorm/st2/lib/python3.6/site-packages/st2client/models/core.py line 42 in decorate
return func(*args, **kwargs)
/opt/stackstorm/st2/lib/python3.6/site-packages/st2client/models/core.py line 294 in get_by_name
instances = self.query(name=name, **kwargs)
/opt/stackstorm/st2/lib/python3.6/site-packages/st2client/models/core.py line 42 in decorate
return func(*args, **kwargs)
/opt/stackstorm/st2/lib/python3.6/site-packages/st2client/models/core.py line 281 in query
instances, _ = self._query_details(**kwargs)
/opt/stackstorm/st2/lib/python3.6/site-packages/st2client/models/core.py line 274 in _query_details
self.handle_error(response)
/opt/stackstorm/st2/lib/python3.6/site-packages/st2client/models/core.py line 168 in handle_error
response.raise_for_status()
/opt/stackstorm/st2/lib/python3.6/site-packages/requests/models.py line 941 in raise_for_status
raise HTTPError(http_error_msg, response=self)
HTTPError: 401 Client Error: Unauthorized
MESSAGE: Unauthorized - One of Token or API key required. for url: http://127.0.0.1:9101/v1/keys/?name=exchange_ews_url
-------------------- >> begin captured logging << --------------------
st2.st2common.runners.utils: DEBUG: Action class (ABCMeta) constructor doesn't take "action_service" argument, falling back to late assignment...
urllib3.connectionpool: DEBUG: Starting new HTTP connection (1): 127.0.0.1:9101
urllib3.connectionpool: DEBUG: http://127.0.0.1:9101 "GET /v1/keys/?name=exchange_ews_url HTTP/1.1" 401 73
--------------------- >> end captured logging << ---------------------