Skip to content

Commit 8ef2e04

Browse files
committed
Ignore 403 errors when searching default_tester_id() by email
1 parent 282ca36 commit 8ef2e04

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ Each RF suite may define the following variables:
5252
changes! If subsequent test scenarios, aka .robot files don't override
5353
``plan_id`` the current one will be used!
5454
- **${product}**: Existing product name when creating a new TestPlan
55-
- **${build_user_email}**: Email for an existing user
55+
- **${build_user_email}**: Email for an existing user,
56+
override with ``TCMS_DEFAULT_TESTER_ID``!
5657

5758
.. warning::
5859

zealand/listener.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22

3+
from xmlrpc.client import ProtocolError
34
from robot.libraries.BuiltIn import BuiltIn
45
from tcms_api.plugin_helpers import Backend
56

@@ -12,21 +13,33 @@ class RFBackend(Backend):
1213
built_in = BuiltIn()
1314
cwd = os.getcwd() + os.sep
1415

16+
@property
1517
def default_tester_id(self):
1618
"""
17-
If ${build_user_email} is specified witin the suite then use it,
18-
otherwise default to the user connecting via API!
19+
If ${build_user_email} is specified within the suite then use it!
20+
21+
.. warning::
22+
23+
Searching users via email requires ``auth.view_user``! See
24+
https://kiwitcms.readthedocs.io/en/latest/admin.html?highlight=auth.view_user#managing-permissions
25+
If this permission is not assigned to the user performing the
26+
API request you may try defining the ``TCMS_DEFAULT_TESTER_ID``
27+
environment variable instead!
1928
"""
20-
user_email = self.built_in.get_variable_value('${build_user_email}')
2129
result = None
30+
user_email = self.built_in.get_variable_value('${build_user_email}')
2231

2332
if user_email:
24-
result = self.rpc.User.filter({'email': user_email})
33+
try:
34+
result = self.rpc.User.filter({'email': user_email})
35+
except ProtocolError as err:
36+
if err.errcode != 403:
37+
raise
2538

2639
if result:
2740
return result[0]['id']
2841

29-
return super().default_tester_id()
42+
return super().default_tester_id
3043

3144
def external_plan_id(self):
3245
"""

0 commit comments

Comments
 (0)