Skip to content

Commit 94a0098

Browse files
authored
Merge pull request #215 from reportportal/develop
Release
2 parents 984973e + 99e70ce commit 94a0098

File tree

12 files changed

+146
-107
lines changed

12 files changed

+146
-107
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ celerybeat.pid
105105
# Environments
106106
.env
107107
.venv
108+
.venv38
109+
.venv39
110+
.venv310
111+
.venv311
108112
env/
109113
venv/
110114
ENV/

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
## [Unreleased]
44
### Added
5+
- OAuth 2.0 Password Grant authentication, by @HardNorth
6+
### Changed
7+
- Client version updated on [5.6.7](https://github.com/reportportal/client-Python/releases/tag/5.6.7), by @HardNorth
8+
### Fixed
9+
- Some configuration parameter names, which are different in the client, by @HardNorth
10+
### Removed
11+
- `RP_UUID` param support, as it was deprecated pretty while ago, by @HardNorth
12+
13+
## [5.6.4]
14+
### Added
515
- `RP_DEBUG_MODE` configuration variable, by @HardNorth
616

717
## [5.6.3]

README.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,40 @@ The latest stable version of library is available on PyPI:
3838
For reporting results to ReportPortal you need to pass some variables
3939
to `robot` run:
4040

41-
REQUIRED:
41+
**Required**:
42+
43+
These variable should be specified in either case:
4244

4345
```
4446
--listener robotframework_reportportal.listener
45-
--variable RP_API_KEY:"your_user_api_key"
4647
--variable RP_ENDPOINT:"your_reportportal_url"
4748
--variable RP_LAUNCH:"launch_name"
4849
--variable RP_PROJECT:"reportportal_project_name"
4950
```
5051

51-
NOT REQUIRED:
52+
And also one type of authorization is required: API Key or OAuth 2.0 Password grant:
53+
54+
```
55+
--variable RP_API_KEY:"your_user_api_key"
56+
- You can get it in the User Profile section on the UI.
57+
```
58+
Or:
59+
```
60+
--variable RP_OAUTH_URI:"https://reportportal.example.com/uat/sso/oauth/token"
61+
- OAuth 2.0 token endpoint URL for password grant authentication. **Required** if API key is not used.
62+
--variable RP_OAUTH_USERNAME:"my_username"
63+
- OAuth 2.0 username for password grant authentication. **Required** if OAuth 2.0 is used.
64+
--variable RP_OAUTH_PASSWORD:"my_password"
65+
- OAuth 2.0 password for password grant authentication. **Required** if OAuth 2.0 is used.
66+
--variable RP_OAUTH_CLIENT_ID:"client_id"
67+
- OAuth 2.0 client identifier. **Required** if OAuth 2.0 is used.
68+
--variable RP_OAUTH_CLIENT_SECRET:"client_id_secret"
69+
- OAuth 2.0 client secret. **Optional** for OAuth 2.0 authentication.
70+
--variable RP_OAUTH_SCOPE:"offline_access"
71+
- OAuth 2.0 access token scope. **Optional** for OAuth 2.0 authentication.
72+
```
73+
74+
**Optional**:
5275

5376
```
5477
--variable RP_CLIENT_TYPE:"SYNC"
@@ -71,9 +94,8 @@ NOT REQUIRED:
7194
- Default value is "10.0", response read timeout for ReportPortal connection.
7295
--variable RP_LOG_BATCH_SIZE:"10"
7396
- Default value is "20", affects size of async batch log requests
74-
--variable RP_LOG_BATCH_PAYLOAD_SIZE:"10240000"
75-
- Default value is "65000000", maximum payload size of async batch log
76-
requests
97+
--variable RP_LOG_BATCH_PAYLOAD_LIMIT:"10240000"
98+
- Default value is "65000000", maximum payload size of async batch log requests
7799
--variable RP_RERUN:"True"
78100
- Default is "False". Enables rerun mode for the last launch.
79101
--variable RP_RERUN_OF:"xxxxx-xxxx-xxxx-lauch-uuid"

requirements-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
pytest
33
pytest-cov
44
robotframework-datadriver
5+
black
6+
isort

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Basic dependencies
22
python-dateutil~=2.9.0.post0
3-
reportportal-client~=5.6.0
3+
reportportal-client~=5.6.7
44
robotframework

robotframework_reportportal/listener.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import os
1919
import re
2020
import uuid
21+
import warnings
2122
from functools import wraps
2223
from mimetypes import guess_type
2324
from typing import Any, Dict, List, Optional, Union
@@ -299,7 +300,14 @@ def service(self) -> RobotService:
299300
"""Initialize instance of the RobotService."""
300301
if self.variables.enabled and not self._service:
301302
self._service = RobotService()
302-
self._service.init_service(self.variables)
303+
try:
304+
self._service.init_service(self.variables)
305+
except ValueError as e:
306+
# Log warning instead of raising error, since Robot Framework catches all errors
307+
warnings.warn(e.args[0], UserWarning, stacklevel=2)
308+
self.variables.enabled = False
309+
self._service = None
310+
raise e
303311
return self._service
304312

305313
@property

robotframework_reportportal/service.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ def init_service(self, variables: Variables) -> None:
7777
"""
7878
if self.rp is None:
7979
self.debug = variables.debug_mode
80-
logger.debug(
81-
f"ReportPortal - Init service: endpoint={variables.endpoint}, "
82-
f"project={variables.project}, api_key={variables.api_key}"
83-
)
80+
logger.debug(f"ReportPortal - Init service: endpoint={variables.endpoint}, project={variables.project}")
8481

8582
self.rp = create_client(
8683
client_type=variables.client_type,
@@ -92,11 +89,17 @@ def init_service(self, variables: Variables) -> None:
9289
retries=5,
9390
verify_ssl=variables.verify_ssl,
9491
max_pool_size=variables.pool_size,
95-
log_batch_payload_size=variables.log_batch_payload_size,
92+
log_batch_payload_limit=variables.log_batch_payload_limit,
9693
launch_uuid=variables.launch_id,
9794
launch_uuid_print=variables.launch_uuid_print,
9895
print_output=variables.launch_uuid_print_output,
9996
http_timeout=variables.http_timeout,
97+
oauth_uri=variables.oauth_uri,
98+
oauth_username=variables.oauth_username,
99+
oauth_password=variables.oauth_password,
100+
oauth_client_id=variables.oauth_client_id,
101+
oauth_client_secret=variables.oauth_client_secret,
102+
oauth_scope=variables.oauth_scope,
100103
)
101104

102105
def terminate_service(self) -> None:

robotframework_reportportal/variables.py

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,18 @@ class Variables:
4848
_pabot_pool_id: Optional[int]
4949
_pabot_used: Optional[str]
5050
project: Optional[str]
51+
52+
# API key auth parameter
5153
api_key: Optional[str]
54+
55+
# OAuth 2.0 parameters
56+
oauth_uri: Optional[str]
57+
oauth_username: Optional[str]
58+
oauth_password: Optional[str]
59+
oauth_client_id: Optional[str]
60+
oauth_client_secret: Optional[str]
61+
oauth_scope: Optional[str]
62+
5263
attach_log: bool
5364
attach_report: bool
5465
attach_xunit: bool
@@ -62,7 +73,7 @@ class Variables:
6273
rerun_of: Optional[str]
6374
test_attributes: List[str]
6475
skipped_issue: bool
65-
log_batch_payload_size: int
76+
log_batch_payload_limit: int
6677
launch_uuid_print: bool
6778
launch_uuid_print_output: Optional[OutputType]
6879
client_type: ClientType
@@ -92,9 +103,25 @@ def __init__(self) -> None:
92103
self.rerun_of = get_variable("RP_RERUN_OF", default=None)
93104
self.skipped_issue = to_bool(get_variable("RP_SKIPPED_ISSUE", default="True"))
94105
self.test_attributes = get_variable("RP_TEST_ATTRIBUTES", default="").split()
95-
self.log_batch_payload_size = int(
96-
get_variable("RP_LOG_BATCH_PAYLOAD_SIZE", default=str(MAX_LOG_BATCH_PAYLOAD_SIZE))
97-
)
106+
107+
batch_payload_size_limit = get_variable("RP_LOG_BATCH_PAYLOAD_LIMIT", default=None)
108+
batch_payload_size = get_variable("RP_LOG_BATCH_PAYLOAD_SIZE", default=None)
109+
if batch_payload_size:
110+
warn(
111+
"Parameter `RP_LOG_BATCH_PAYLOAD_SIZE` is deprecated since 5.6.5 "
112+
"and will be subject for removing in the next major version. Use `RP_LOG_BATCH_PAYLOAD_LIMIT` argument"
113+
" instead.",
114+
DeprecationWarning,
115+
2,
116+
)
117+
if not batch_payload_size_limit:
118+
batch_payload_size_limit = batch_payload_size
119+
120+
if batch_payload_size_limit:
121+
self.log_batch_payload_limit = int(batch_payload_size_limit)
122+
else:
123+
self.log_batch_payload_limit = MAX_LOG_BATCH_PAYLOAD_SIZE
124+
98125
self.launch_uuid_print = to_bool(get_variable("RP_LAUNCH_UUID_PRINT", default="False"))
99126
output_type = get_variable("RP_LAUNCH_UUID_PRINT_OUTPUT")
100127
self.launch_uuid_print_output = OutputType[output_type.upper()] if output_type else None
@@ -116,29 +143,20 @@ def __init__(self) -> None:
116143
self.remove_keywords = to_bool(get_variable("RP_REMOVE_KEYWORDS", default="False"))
117144
self.flatten_keywords = to_bool(get_variable("RP_FLATTEN_KEYWORDS", default="False"))
118145

146+
# API key auth parameter
119147
self.api_key = get_variable("RP_API_KEY")
120-
if not self.api_key:
121-
token = get_variable("RP_UUID")
122-
if token:
123-
warn(
124-
message="Argument `RP_UUID` is deprecated since version 5.3.3 and will be subject for "
125-
"removing in the next major version. Use `RP_API_KEY` argument instead.",
126-
category=DeprecationWarning,
127-
stacklevel=2,
128-
)
129-
self.api_key = token
130-
else:
131-
warn(
132-
message="Argument `RP_API_KEY` is `None` or empty string, that's not supposed to happen "
133-
"because ReportPortal is usually requires an authorization key. Please check your"
134-
" configuration.",
135-
category=RuntimeWarning,
136-
stacklevel=2,
137-
)
148+
149+
# OAuth 2.0 parameters
150+
self.oauth_uri = get_variable("RP_OAUTH_URI")
151+
self.oauth_username = get_variable("RP_OAUTH_USERNAME")
152+
self.oauth_password = get_variable("RP_OAUTH_PASSWORD")
153+
self.oauth_client_id = get_variable("RP_OAUTH_CLIENT_ID")
154+
self.oauth_client_secret = get_variable("RP_OAUTH_CLIENT_SECRET")
155+
self.oauth_scope = get_variable("RP_OAUTH_SCOPE")
138156

139157
self.debug_mode = to_bool(get_variable("RP_DEBUG_MODE", default="False"))
140158

141-
cond = (self.endpoint, self.launch_name, self.project, self.api_key)
159+
cond = (self.endpoint, self.launch_name, self.project)
142160
self.enabled = all(cond)
143161
if not self.enabled:
144162
warn(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from setuptools import setup
2020

21-
__version__ = "5.6.4"
21+
__version__ = "5.6.5"
2222

2323

2424
def read_file(fname):

tests/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@
1515
"""
1616

1717
REPORT_PORTAL_SERVICE = "reportportal_client.RPClient"
18-
REQUESTS_SERVICE = "reportportal_client.client.requests.Session"

0 commit comments

Comments
 (0)