Skip to content

Commit

Permalink
Add functional tests for remotes' URLs
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
lubosmj committed Jul 14, 2021
1 parent ee3c3dd commit ba6e75c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions pulpcore/tests/functional/api/using_plugin/test_crud_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,50 @@ def test_create_remote_using_form(self):
remote = self.api_client.post(FILE_REMOTE_PATH, data=remote_attrs)
self.addCleanup(self.remotes_api.delete, remote["pulp_href"])
self.assertEqual(remote["pulp_labels"], self.pulp_labels)


class RemoteFileURLsValidationTestCase(unittest.TestCase):
"""A test case that verifies the validation of remotes' URLs."""

@classmethod
def setUpClass(cls):
"""Initialize class-wide variables"""
cls.cfg = config.get_config()

cls.api_client = api.Client(cls.cfg, api.json_handler)
cls.file_client = FileApiClient(cls.cfg.get_bindings_config())
cls.remotes_api = RemotesFileApi(cls.file_client)

def test_invalid_absolute_pathname(self):
"""Test the validation of an invalid absolute pathname."""
remote_attrs = {
"name": utils.uuid4(),
"url": "file://error/path/name",
}
self.raise_for_invalid_request(remote_attrs)

def test_invalid_import_path(self):
"""Test the validation of an invalid import pathname."""
remote_attrs = {
"name": utils.uuid4(),
"url": "file:///error/path/name",
}
self.raise_for_invalid_request(remote_attrs)

def raise_for_invalid_request(self, remote_attrs):
"""Check if Pulp returns HTTP 400 after issuing an invalid request."""
with self.assertRaises(ApiException) as ae:
remote = self.remotes_api.create(remote_attrs)
self.addCleanup(self.remotes_api.delete, remote.pulp_href)

self.assertEqual(ae.exception.status, 400)

def test_valid_import_path(self):
"""Test the creation of a remote after passing a valid URL."""
remote_attrs = {
"name": utils.uuid4(),
"url": "file:///tmp/good",
}

remote = self.remotes_api.create(remote_attrs)
self.addCleanup(self.remotes_api.delete, remote.pulp_href)

0 comments on commit ba6e75c

Please sign in to comment.