Skip to content

Commit

Permalink
test: ssh_agent plugin (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanksyoon committed Nov 3, 2023
1 parent 049515f commit 19a5fea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async def install_plugins(
)


def _get_test_job_xml(node_label: str):
def gen_test_job_xml(node_label: str):
"""Generate a job xml with target node label.
Args:
Expand Down Expand Up @@ -121,7 +121,7 @@ def assert_job_success(
(agent_name in key for key in nodes.keys())
), f"Jenkins {agent_name} node not registered."

job = client.create_job(agent_name, _get_test_job_xml(test_target_label))
job = client.create_job(agent_name, gen_test_job_xml(test_target_label))
queue_item = job.invoke()
queue_item.block_until_complete()
build: jenkinsapi.build.Build = queue_item.get_build()
Expand Down
19 changes: 18 additions & 1 deletion tests/integration/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pytest_operator.plugin import OpsTest

from .constants import ALLOWED_PLUGINS, INSTALLED_PLUGINS, REMOVED_PLUGINS
from .helpers import gen_git_test_job_xml, get_job_invoked_unit, install_plugins
from .helpers import gen_git_test_job_xml, gen_test_job_xml, get_job_invoked_unit, install_plugins
from .types_ import TestLDAPSettings, UnitWebClient


Expand Down Expand Up @@ -221,6 +221,23 @@ async def test_postbuildscript_plugin(
assert stdout == test_output


async def test_ssh_agent_plugin(ops_test: OpsTest, unit_web_client: UnitWebClient):
"""
arrange: given jenkins charm with ssh_agent plugin installed.
act: when a job is being configured.
assert: ssh-agent configuration is visible.
"""
await install_plugins(ops_test, unit_web_client.unit, unit_web_client.client, ("ssh-agent",))
unit_web_client.client.create_job("ssh_agent_test", gen_test_job_xml("k8s"))

res = unit_web_client.client.requester.get_url(
f"{unit_web_client.web}/job/ssh_agent_test/configure"
)

config_page = str(res.content, "utf-8")
assert "SSH Agent" in config_page, f"SSH agent configuration not found. {config_page}"


async def test_blueocean_plugin(ops_test: OpsTest, unit_web_client: UnitWebClient):
"""
arrange: given a jenkins charm with blueocean plugin installed.
Expand Down

0 comments on commit 19a5fea

Please sign in to comment.