Skip to content

Commit

Permalink
Adding proxy tests
Browse files Browse the repository at this point in the history
[noissue]

(cherry picked from commit 750e8b0)
  • Loading branch information
fao89 committed Jan 27, 2022
1 parent e12b431 commit 29b7d33
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ services:
image: "pulp:${TAG}"
volumes:
- ./settings:/etc/pulp
- name: ciproxy
image: ghcr.io/abhinavsingh/proxy.py:latest
command: "--basic-auth foo:bar --hostname 0.0.0.0"
VARSYAML
fi

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/scripts/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ if [[ "$TEST" == "performance" ]]; then
exit
fi

# Enable proxy.py
export PULP_PROXY_TEST=enabled

if [ -f $FUNC_TEST_SCRIPT ]; then
source $FUNC_TEST_SCRIPT
else
Expand Down
48 changes: 48 additions & 0 deletions pulp_ansible/tests/functional/api/collection/v3/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,54 @@ def test_sync_with_missing_collection(self):
msg = "absent.not_present does not exist"
self.assertIn(msg, task_result["error"]["description"], task_result["error"]["description"])

def test_sync_with_proxy_auth(self):
"""Test sync collections from pulp server."""
if not os.getenv("PULP_PROXY_TEST"):
self.skipTest("Proxy isn't set.")

second_body = gen_ansible_remote(
url=self.distribution.client_url,
requirements_file=self.requirements_file,
sync_dependencies=False,
proxy_url="http://ciproxy:8899",
proxy_username="foo",
proxy_password="bar",
)
second_remote = self.remote_collection_api.create(second_body)
self.addCleanup(self.remote_collection_api.delete, second_remote.pulp_href)

second_repo = self._create_repo_and_sync_with_remote(second_remote)

first_content = self.cv_api.list(
repository_version=f"{self.first_repo.pulp_href}versions/1/"
)
self.assertGreaterEqual(len(first_content.results), 1)
second_content = self.cv_api.list(repository_version=f"{second_repo.pulp_href}versions/1/")
self.assertGreaterEqual(len(second_content.results), 1)

def test_sync_with_proxy_auth_without_credentials(self):
"""Test sync collections from pulp server."""
if not os.getenv("PULP_PROXY_TEST"):
self.skipTest("Proxy isn't set.")

second_body = gen_ansible_remote(
url=self.distribution.client_url,
requirements_file=self.requirements_file,
sync_dependencies=False,
proxy_url="http://ciproxy:8899",
)
second_remote = self.remote_collection_api.create(second_body)
self.addCleanup(self.remote_collection_api.delete, second_remote.pulp_href)

with self.assertRaises(PulpTaskError) as ctx:
self._create_repo_and_sync_with_remote(second_remote)

task_result = ctx.exception.task.to_dict()
msg = "407, message='Proxy Authentication Required', url=URL(" "'http://ciproxy:8899')"
self.assertEqual(
msg, task_result["error"]["description"], task_result["error"]["description"]
)


@unittest.skipUnless(
"AUTOMATION_HUB_TOKEN_AUTH" in os.environ,
Expand Down

0 comments on commit 29b7d33

Please sign in to comment.