2424import pytest
2525
2626# noinspection PyPackageRequirements
27- import requests
2827from pytest import Item , Session
2928from reportportal_client import RP , RPLogHandler
3029from reportportal_client .errors import ResponseError
4948LOGGER : Logger = logging .getLogger (__name__ )
5049
5150MANDATORY_PARAMETER_MISSED_PATTERN : str = (
52- "One of the following mandatory parameters is unset: "
53- + "rp_project: {}, "
54- + "rp_endpoint: {}, "
55- + "rp_api_key: {}"
51+ "One of the following mandatory parameters is unset: " + "rp_project: {}, rp_endpoint: {}"
5652)
5753
5854FAILED_LAUNCH_WAIT : str = (
@@ -182,25 +178,6 @@ def register_markers(config) -> None:
182178 config .addinivalue_line ("markers" , "name(name): report the test case with a custom Name." )
183179
184180
185- def check_connection (agent_config : AgentConfig ):
186- """Check connection to RP using provided options.
187-
188- If connection is successful returns True either False.
189- :param agent_config: Instance of the AgentConfig class
190- :return True on successful connection check, either False
191- """
192- url = "{0}/api/v1/project/{1}" .format (agent_config .rp_endpoint , agent_config .rp_project )
193- headers = {"Authorization" : "bearer {0}" .format (agent_config .rp_api_key )}
194- try :
195- resp = requests .get (url , headers = headers , verify = agent_config .rp_verify_ssl )
196- resp .raise_for_status ()
197- return True
198- except requests .exceptions .RequestException as exc :
199- LOGGER .exception (exc )
200- LOGGER .error ("Unable to connect to Report Portal, the launch won't be reported" )
201- return False
202-
203-
204181# no 'config' type for backward compatibility for older pytest versions
205182# noinspection PyProtectedMember
206183def pytest_configure (config ) -> None :
@@ -216,24 +193,17 @@ def pytest_configure(config) -> None:
216193 or not config .option .rp_enabled
217194 )
218195 if not config ._rp_enabled :
196+ LOGGER .debug ("Disabling reporting to RP." )
219197 return
220198
221199 agent_config = AgentConfig (config )
222-
223- cond = (agent_config .rp_project , agent_config .rp_endpoint , agent_config .rp_api_key )
200+ cond = (agent_config .rp_project , agent_config .rp_endpoint )
224201 config ._rp_enabled = all (cond )
225202 if not config ._rp_enabled :
226203 LOGGER .debug (MANDATORY_PARAMETER_MISSED_PATTERN .format (* cond ))
227204 LOGGER .debug ("Disabling reporting to RP." )
228205 return
229206
230- if not agent_config .rp_skip_connection_test :
231- config ._rp_enabled = check_connection (agent_config )
232-
233- if not config ._rp_enabled :
234- LOGGER .debug ("Failed to establish connection with RP. " "Disabling reporting." )
235- return
236-
237207 config ._reporter_config = agent_config
238208
239209 if is_control (config ):
@@ -592,7 +562,6 @@ def add_shared_option(name, help_str, default=None, action="store"):
592562 name = "rp_parent_item_id" ,
593563 help_str = "Create all test item as child items of the given (already " "existing) item." ,
594564 )
595- add_shared_option (name = "rp_uuid" , help_str = "Deprecated: use `rp_api_key` " "instead." )
596565 add_shared_option (name = "rp_api_key" , help_str = "API key of Report Portal. Usually located on UI profile " "page." )
597566 add_shared_option (name = "rp_endpoint" , help_str = "Server endpoint" )
598567 add_shared_option (name = "rp_mode" , help_str = "Visibility of current launch [DEFAULT, DEBUG]" , default = "DEFAULT" )
@@ -613,11 +582,19 @@ def add_shared_option(name, help_str, default=None, action="store"):
613582 help_str = "Launch UUID print output. Default `stdout`. Possible values: [stderr, stdout]" ,
614583 )
615584
585+ # OAuth 2.0 parameters
586+ parser .addini ("rp_oauth_uri" , type = "args" , help = "OAuth 2.0 token endpoint URL for password grant authentication" )
587+ parser .addini ("rp_oauth_username" , type = "args" , help = "OAuth 2.0 username for password grant authentication" )
588+ parser .addini ("rp_oauth_password" , type = "args" , help = "OAuth 2.0 password for password grant authentication" )
589+ parser .addini ("rp_oauth_client_id" , type = "args" , help = "OAuth 2.0 client identifier" )
590+ parser .addini ("rp_oauth_client_secret" , type = "args" , help = "OAuth 2.0 client secret" )
591+ parser .addini ("rp_oauth_scope" , type = "args" , help = "OAuth 2.0 access token scope" )
592+
616593 parser .addini ("rp_launch_attributes" , type = "args" , help = "Launch attributes, i.e Performance Regression" )
617594 parser .addini ("rp_tests_attributes" , type = "args" , help = "Attributes for all tests items, e.g. Smoke" )
618595 parser .addini ("rp_log_batch_size" , default = "20" , help = "Size of batch log requests in async mode" )
619596 parser .addini (
620- "rp_log_batch_payload_size " ,
597+ "rp_log_batch_payload_limit " ,
621598 default = str (MAX_LOG_BATCH_PAYLOAD_SIZE ),
622599 help = "Maximum payload size in bytes of async batch log requests" ,
623600 )
@@ -669,7 +646,6 @@ def add_shared_option(name, help_str, default=None, action="store"):
669646 parser .addini ("rp_issue_id_marks" , type = "bool" , default = True , help = "Add tag with issue id to the test" )
670647 parser .addini ("retries" , default = "0" , help = "Deprecated: use `rp_api_retries` instead" )
671648 parser .addini ("rp_api_retries" , default = "0" , help = "Amount of retries for performing REST calls to RP server" )
672- parser .addini ("rp_skip_connection_test" , default = False , type = "bool" , help = "Skip Report Portal connection test" )
673649 parser .addini (
674650 "rp_launch_timeout" ,
675651 default = 86400 ,
0 commit comments