Skip to content

Commit

Permalink
Fix cli yum repo authentication test
Browse files Browse the repository at this point in the history
There were multiple levels to this error:

* fix parametrization error
  AttributeError: 'generator' object has no attribute 'copy'
* fix assertion
* filter invalid parametrizations by adding 'yum_compatible' flag
  - 'latin-1' codec can't encode characters
  - Validation failed: Upstream password requires upstream username be set.
  - Validation failed: Upstream username is too long (maximum is 255 characters)

What was sadly not done:
* make parametrization ids readable for meanigful debugging
  • Loading branch information
dosas committed Oct 22, 2024
1 parent 5535ae0 commit 7d3041d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
15 changes: 12 additions & 3 deletions robottelo/utils/datafactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,26 +496,35 @@ def valid_http_credentials(url_encoded=False):
'quote': False,
'http_valid': True,
},
{'login': 'admin', 'pass': '', 'quote': False, 'http_valid': False},
{'login': '', 'pass': 'mypassword', 'quote': False, 'http_valid': False},
{'login': '', 'pass': '', 'quote': False, 'http_valid': False},
{'login': 'admin', 'pass': '', 'quote': False, 'http_valid': False, 'yum_compatible': True},
{
'login': '',
'pass': 'mypassword',
'quote': False,
'http_valid': False,
'yum_compatible': False,
},
{'login': '', 'pass': '', 'quote': False, 'http_valid': False, 'yum_compatible': True},
{
'login': gen_string('alpha', gen_integer(1, 512)),
'pass': gen_string('alpha'),
'quote': False,
'http_valid': False,
'yum_compatible': False,
},
{
'login': gen_string('alphanumeric', gen_integer(1, 512)),
'pass': gen_string('alphanumeric'),
'quote': False,
'http_valid': False,
'yum_compatible': False,
},
{
'login': gen_string('utf8', gen_integer(1, 50)),
'pass': gen_string('utf8'),
'quote': True,
'http_valid': False,
'yum_compatible': False,
'encoding': 'utf8',
},
]
Expand Down
21 changes: 10 additions & 11 deletions tests/foreman/cli/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,16 +716,14 @@ def test_positive_synchronize_file_repo(self, repo_options, repo, target_sat):
'repo_options',
**parametrized(
[
(
{
'content-type': 'yum',
'url': FAKE_5_YUM_REPO,
'upstream-username': creds['login'],
'upstream-password': creds['pass'],
}
for creds in valid_http_credentials()
if not creds['http_valid']
)
{
'content-type': 'yum',
'url': FAKE_5_YUM_REPO,
'upstream-username': creds['login'],
'upstream-password': creds['pass'],
}
for creds in valid_http_credentials()
if not creds['http_valid'] and creds.get('yum_compatible')
]
),
indirect=['repo_options'],
Expand All @@ -747,7 +745,8 @@ def test_negative_synchronize_auth_yum_repo(self, repo, target_sat):
response = target_sat.cli.Task.progress(
{'id': repo_sync[0]['id']}, return_raw_response=True
)
assert "Error: 401, message='Unauthorized'" in response.stderr[1].decode('utf-8')

assert "Error: 401, message='Unauthorized'" in response.stderr

@pytest.mark.tier2
@pytest.mark.upgrade
Expand Down

0 comments on commit 7d3041d

Please sign in to comment.