# Automation API result for prod (.iqe_venv) [iqe-workspace-dev]$ ENV_FOR_DYNACONF=prod iqe shell Welcome to IPython designed for running Insights QE code. > from iqe.base.application.implementations.web_ui import navigate_to > app = $magic Application /home/dgaikwad/redhat/iqe-workspace-dev/iqe-core/iqe/base/settings/_find_files.py:69: IQEDeprecationWarning: DEPRECATED: local LOCAL conf path not used warnings.warn("local LOCAL conf path not used", IQEDeprecationWarning) /home/dgaikwad/redhat/iqe-workspace-dev/iqe-core/iqe/base/settings/vault_loading.py:127: IQEDeprecationWarning: DEPRECATED: Github authentication will be End of Life on Friday, Oct. 21, 2022 iqe_core==22.12.24.0 will remove support for this functionality. A possible replacement is: Enable OIDC authentication for Vault. Export DYNACONF_IQE_VAULT_OIDC_AUTH='1'. You can find discussion regarding this at https://issues.redhat.com/browse/IQE-1662. _login_and_renew_token(client, settings) > conf = app.config You can create your own python file with imports you use frequently. Just create a conf/iqe_python_startup.py file in your repo. This file can contain arbitrary python code that is executed in this context. In [1]: In [1]: In [1]: In [1]: import fauxfactory In [2]: application = app In [3]: bundle_id = "637be1a3-3c05-4415-a6a9-844d392d4cf5" ...: user = "notifications_user" ...: user_obj = getattr(application.notifications.config.USERS, user) ...: with application.copy_using(user=user_obj) as new_application: ...: ...: payload = { ...: "bundle_id": bundle_id, ...: "display_name": fauxfactory.gen_alphanumeric(30, start="test_notifications_"), ...: } ...: client = ( ...: new_application.notifications.rest_client_notifications.notification_resource_api ...: ) ...: ...: client.notification_resource_create_behavior_group(payload) ...: --------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In [3], line 14 6 payload = { 7 "bundle_id": bundle_id, 8 "display_name": fauxfactory.gen_alphanumeric(30, start="test_notifications_"), 9 } 10 client = ( 11 new_application.notifications.rest_client_notifications.notification_resource_api 12 ) ---> 14 client.notification_resource_create_behavior_group(payload) File ~/redhat/iqe-workspace-dev/iqe-notifications-plugin/iqe_notifications_api/api/notification_resource_api.py:60, in NotificationResourceApi.notification_resource_create_behavior_group(self, create_behavior_group_request, **kwargs) 39 """Create a behavior group - assigning actions and linking to event types as requested # noqa: E501 40 41 This method makes a synchronous HTTP request by default. To make an (...) 57 returns the request thread. 58 """ 59 kwargs['_return_http_data_only'] = True ---> 60 return self.notification_resource_create_behavior_group_with_http_info(create_behavior_group_request, **kwargs) File ~/redhat/iqe-workspace-dev/iqe-notifications-plugin/iqe_notifications_api/api/notification_resource_api.py:144, in NotificationResourceApi.notification_resource_create_behavior_group_with_http_info(self, create_behavior_group_request, **kwargs) 141 # Authentication setting 142 auth_settings = ['SecurityScheme'] # noqa: E501 --> 144 return self.api_client.call_api( 145 '/notifications/behaviorGroups', 'POST', 146 path_params, 147 query_params, 148 header_params, 149 body=body_params, 150 post_params=form_params, 151 files=local_var_files, 152 response_type='CreateBehaviorGroupResponse', # noqa: E501 153 auth_settings=auth_settings, 154 async_req=local_var_params.get('async_req'), 155 _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 156 _preload_content=local_var_params.get('_preload_content', True), 157 _hide_api_exception=local_var_params.get('_hide_api_exception', False), 158 _request_timeout=local_var_params.get('_request_timeout'), 159 collection_formats=collection_formats) File ~/redhat/iqe-workspace-dev/iqe-notifications-plugin/iqe_notifications_api/api_client.py:358, in ApiClient.call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, async_req, _return_http_data_only, collection_formats, _preload_content, _hide_api_exception, _request_timeout, _host) 321 """Makes the HTTP request (synchronous) and returns deserialized data. 322 323 To make an async_req request, set the async_req parameter. (...) 355 then the method will return the response directly. 356 """ 357 if not async_req: --> 358 return self.__call_api(resource_path, method, 359 path_params, query_params, header_params, 360 body, post_params, files, 361 response_type, auth_settings, 362 _return_http_data_only, collection_formats, 363 _preload_content, _hide_api_exception, _request_timeout, _host) 364 return self.pool.apply_async(self.__call_api, (resource_path, 365 method, path_params, query_params, 366 header_params, body, (...) 373 _request_timeout, 374 _host)) File ~/redhat/iqe-workspace-dev/iqe-notifications-plugin/iqe_notifications_api/api_client.py:166, in ApiClient.__call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, _return_http_data_only, collection_formats, _preload_content, _hide_api_exception, _request_timeout, _host) 163 post_params.extend(self.files_parameters(files)) 165 # auth setting --> 166 self.update_params_for_auth(header_params, query_params, auth_settings) 168 # body 169 if body: File ~/redhat/iqe-workspace-dev/iqe-core/iqe/base/rest_client.py:23, in client_obj_maker..make_obj..IQEApiClient.update_params_for_auth(self, headers, *k, **kw) 17 """ 18 this is a very ugly hack that rips out the real auth 19 20 """ 22 if self.configuration.iqe_authz: ---> 23 self.configuration.iqe_authz(Namespace(headers=headers)) 24 else: 25 super().update_params_for_auth(headers, *k, **kw) File ~/redhat/iqe-workspace-dev/iqe-core/.iqe_venv/lib64/python3.8/site-packages/iqe_jwt/__init__.py:136, in JwtAuth.__call__(self, r) 135 def __call__(self, r): --> 136 token = self.get_token() 137 r.headers["Authorization"] = f"Bearer {token}" 138 return r File ~/redhat/iqe-workspace-dev/iqe-core/.iqe_venv/lib64/python3.8/site-packages/iqe_jwt/__init__.py:109, in JwtAuth.get_token(self) 107 if not self.token: 108 logger.info("No access token, requesting...") --> 109 self._get_jwt() 110 elif self._refresh_token_expired: 111 logger.info("Refresh token has expired, performing new auth...") File ~/redhat/iqe-workspace-dev/iqe-core/.iqe_venv/lib64/python3.8/site-packages/iqe_jwt/__init__.py:156, in JwtAuth._get_jwt(self) 154 return 155 else: --> 156 self._rhsm_style() File ~/redhat/iqe-workspace-dev/iqe-core/.iqe_venv/lib64/python3.8/site-packages/iqe_jwt/__init__.py:218, in JwtAuth._rhsm_style(self) 211 sess = requests.Session() 212 data_refresh = { 213 "client_id": self.client_id, 214 "grant_type": "password", 215 "username": self.username, 216 "password": self.password, 217 } --> 218 self._refresh_token(sess, data_refresh) File ~/redhat/iqe-workspace-dev/iqe-core/.iqe_venv/lib64/python3.8/site-packages/iqe_jwt/__init__.py:193, in JwtAuth._refresh_token(self, session, data_refresh) 188 response_text = response.json() 189 error_message = ( 190 f"Cannot get token, error: {response_text['error']}," 191 f" reason:{response_text['error_description']}" 192 ) --> 193 raise ValueError(error_message) 195 response.raise_for_status() 197 response_json = response.json() ValueError: Cannot get token, error: unauthorized_client, reason:Client not allowed for direct access grants In [4]: In [4]: In [4]: In [4]: In [4]: bundle_id = "637be1a3-3c05-4415-a6a9-844d392d4cf5" ...: user = "notifications_admin" ...: user_obj = getattr(application.notifications.config.USERS, user) ...: with application.copy_using(user=user_obj) as new_application: ...: ...: payload = { ...: "bundle_id": bundle_id, ...: "display_name": fauxfactory.gen_alphanumeric(30, start="test_notifications_"), ...: } ...: client = ( ...: new_application.notifications.rest_client_notifications.notification_resource_api ...: ) ...: ...: client.notification_resource_create_behavior_group(payload) ...: --------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In [4], line 14 6 payload = { 7 "bundle_id": bundle_id, 8 "display_name": fauxfactory.gen_alphanumeric(30, start="test_notifications_"), 9 } 10 client = ( 11 new_application.notifications.rest_client_notifications.notification_resource_api 12 ) ---> 14 client.notification_resource_create_behavior_group(payload) File ~/redhat/iqe-workspace-dev/iqe-notifications-plugin/iqe_notifications_api/api/notification_resource_api.py:60, in NotificationResourceApi.notification_resource_create_behavior_group(self, create_behavior_group_request, **kwargs) 39 """Create a behavior group - assigning actions and linking to event types as requested # noqa: E501 40 41 This method makes a synchronous HTTP request by default. To make an (...) 57 returns the request thread. 58 """ 59 kwargs['_return_http_data_only'] = True ---> 60 return self.notification_resource_create_behavior_group_with_http_info(create_behavior_group_request, **kwargs) File ~/redhat/iqe-workspace-dev/iqe-notifications-plugin/iqe_notifications_api/api/notification_resource_api.py:144, in NotificationResourceApi.notification_resource_create_behavior_group_with_http_info(self, create_behavior_group_request, **kwargs) 141 # Authentication setting 142 auth_settings = ['SecurityScheme'] # noqa: E501 --> 144 return self.api_client.call_api( 145 '/notifications/behaviorGroups', 'POST', 146 path_params, 147 query_params, 148 header_params, 149 body=body_params, 150 post_params=form_params, 151 files=local_var_files, 152 response_type='CreateBehaviorGroupResponse', # noqa: E501 153 auth_settings=auth_settings, 154 async_req=local_var_params.get('async_req'), 155 _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 156 _preload_content=local_var_params.get('_preload_content', True), 157 _hide_api_exception=local_var_params.get('_hide_api_exception', False), 158 _request_timeout=local_var_params.get('_request_timeout'), 159 collection_formats=collection_formats) File ~/redhat/iqe-workspace-dev/iqe-notifications-plugin/iqe_notifications_api/api_client.py:358, in ApiClient.call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, async_req, _return_http_data_only, collection_formats, _preload_content, _hide_api_exception, _request_timeout, _host) 321 """Makes the HTTP request (synchronous) and returns deserialized data. 322 323 To make an async_req request, set the async_req parameter. (...) 355 then the method will return the response directly. 356 """ 357 if not async_req: --> 358 return self.__call_api(resource_path, method, 359 path_params, query_params, header_params, 360 body, post_params, files, 361 response_type, auth_settings, 362 _return_http_data_only, collection_formats, 363 _preload_content, _hide_api_exception, _request_timeout, _host) 364 return self.pool.apply_async(self.__call_api, (resource_path, 365 method, path_params, query_params, 366 header_params, body, (...) 373 _request_timeout, 374 _host)) File ~/redhat/iqe-workspace-dev/iqe-notifications-plugin/iqe_notifications_api/api_client.py:166, in ApiClient.__call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, _return_http_data_only, collection_formats, _preload_content, _hide_api_exception, _request_timeout, _host) 163 post_params.extend(self.files_parameters(files)) 165 # auth setting --> 166 self.update_params_for_auth(header_params, query_params, auth_settings) 168 # body 169 if body: File ~/redhat/iqe-workspace-dev/iqe-core/iqe/base/rest_client.py:23, in client_obj_maker..make_obj..IQEApiClient.update_params_for_auth(self, headers, *k, **kw) 17 """ 18 this is a very ugly hack that rips out the real auth 19 20 """ 22 if self.configuration.iqe_authz: ---> 23 self.configuration.iqe_authz(Namespace(headers=headers)) 24 else: 25 super().update_params_for_auth(headers, *k, **kw) File ~/redhat/iqe-workspace-dev/iqe-core/.iqe_venv/lib64/python3.8/site-packages/iqe_jwt/__init__.py:136, in JwtAuth.__call__(self, r) 135 def __call__(self, r): --> 136 token = self.get_token() 137 r.headers["Authorization"] = f"Bearer {token}" 138 return r File ~/redhat/iqe-workspace-dev/iqe-core/.iqe_venv/lib64/python3.8/site-packages/iqe_jwt/__init__.py:109, in JwtAuth.get_token(self) 107 if not self.token: 108 logger.info("No access token, requesting...") --> 109 self._get_jwt() 110 elif self._refresh_token_expired: 111 logger.info("Refresh token has expired, performing new auth...") File ~/redhat/iqe-workspace-dev/iqe-core/.iqe_venv/lib64/python3.8/site-packages/iqe_jwt/__init__.py:156, in JwtAuth._get_jwt(self) 154 return 155 else: --> 156 self._rhsm_style() File ~/redhat/iqe-workspace-dev/iqe-core/.iqe_venv/lib64/python3.8/site-packages/iqe_jwt/__init__.py:218, in JwtAuth._rhsm_style(self) 211 sess = requests.Session() 212 data_refresh = { 213 "client_id": self.client_id, 214 "grant_type": "password", 215 "username": self.username, 216 "password": self.password, 217 } --> 218 self._refresh_token(sess, data_refresh) File ~/redhat/iqe-workspace-dev/iqe-core/.iqe_venv/lib64/python3.8/site-packages/iqe_jwt/__init__.py:193, in JwtAuth._refresh_token(self, session, data_refresh) 188 response_text = response.json() 189 error_message = ( 190 f"Cannot get token, error: {response_text['error']}," 191 f" reason:{response_text['error_description']}" 192 ) --> 193 raise ValueError(error_message) 195 response.raise_for_status() 197 response_json = response.json() ValueError: Cannot get token, error: unauthorized_client, reason:Client not allowed for direct access grants In [5]: