Merge ~woutervb/charm-sudo-pair:focal into ~sudo-pair-charmers/charm-sudo-pair:master

Proposed by Wouter van Bommel
Status: Rejected
Rejected by: Paul Goins
Proposed branch: ~woutervb/charm-sudo-pair:focal
Merge into: ~sudo-pair-charmers/charm-sudo-pair:master
Diff against target: 201 lines (+56/-72)
1 file modified
tests/functional/test_deploy.py (+56/-72)
Reviewer Review Type Date Requested Status
Paul Goins Needs Fixing
Xav Paice (community) Approve
Review via email: mp+378781@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Xav Paice (xavpaice) wrote :

Tests work fine for me. This is a big looking change, but mostly it's reformatting (Black?). The actual guts of the change is to add testing and metadata.yaml for focal - the rest is lint.

review: Approve
Revision history for this message
Paul Goins (vultaire) wrote :

Suggestion for next time to make it easier to review: try to do 2 separate commits, one for black and one for the actual updates. It sounds like black was called automatically in this case, but at least where we can in the future, that'd help ease reviewing. :)

Revision history for this message
Paul Goins (vultaire) wrote :

"2 separate commits" - not literally meant, could be 2 or more.

Revision history for this message
Paul Goins (vultaire) wrote :

I don't see an update to metadata.yaml here; looks like it was done immediately prior before.

Looks good; approved.

review: Approve
Revision history for this message
Paul Goins (vultaire) wrote :

...This does not apply cleanly to the current master branch of the top-level repo.

review: Needs Fixing
Revision history for this message
Paul Goins (vultaire) wrote :

I checked out the previous commit, ran black on the file, then diffed against this code.

The only change here is:

diff --git a/tests/functional/test_deploy.py b/tests/functional/test_deploy.py
index 27a3f9d..73971dd 100644
--- a/tests/functional/test_deploy.py
+++ b/tests/functional/test_deploy.py
@@ -7,7 +7,7 @@ pytestmark = pytest.mark.asyncio

 def get_series():
- series = os.getenv("test_series", "xenial bionic focal").strip()
+ series = os.getenv("test_series", "xenial bionic").strip()
     return series.split()

I will submit a new merge proposal.

Revision history for this message
Paul Goins (vultaire) wrote :

Unmerged commits

62b8c98... by Wouter van Bommel

Added focal as testing target

By updating series focal is also a test target. It does require an juju
environment capable of running focal (test) images

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/functional/test_deploy.py b/tests/functional/test_deploy.py
2index 5c8e690..27a3f9d 100644
3--- a/tests/functional/test_deploy.py
4+++ b/tests/functional/test_deploy.py
5@@ -7,9 +7,10 @@ pytestmark = pytest.mark.asyncio
6
7
8 def get_series():
9- series = os.getenv('test_series', 'xenial bionic').strip()
10+ series = os.getenv("test_series", "xenial bionic focal").strip()
11 return series.split()
12
13+
14 ############
15 # FIXTURES #
16 ############
17@@ -17,130 +18,113 @@ def get_series():
18
19 # This fixture shouldn't really be in conftest.py since it's specific to this
20 # charm
21-@pytest.fixture(scope='module',
22- params=get_series())
23+@pytest.fixture(scope="module", params=get_series())
24 async def deploy_app(request, model):
25- '''Deploys the sudo_pair app as a subordinate of ubuntu'''
26+ """Deploys the sudo_pair app as a subordinate of ubuntu"""
27 release = request.param
28
29 await model.deploy(
30- 'ubuntu',
31- application_name='ubuntu-' + release,
32- series=release,
33- channel='stable'
34+ "ubuntu", application_name="ubuntu-" + release, series=release, channel="stable"
35 )
36 sudo_pair_app = await model.deploy(
37- '{}/builds/sudo-pair'.format(os.getenv('JUJU_REPOSITORY')),
38- application_name='sudo-pair-' + release,
39+ "{}/builds/sudo-pair".format(os.getenv("JUJU_REPOSITORY")),
40+ application_name="sudo-pair-" + release,
41 series=release,
42 num_units=0,
43 config={
44- 'bypass_cmds': '/bin/ls',
45- 'groups_enforced': 'ubuntu',
46- 'bypass_group': 'warthogs',
47- }
48+ "bypass_cmds": "/bin/ls",
49+ "groups_enforced": "ubuntu",
50+ "bypass_group": "warthogs",
51+ },
52 )
53 await model.add_relation(
54- 'ubuntu-{}:juju-info'.format(release),
55- 'sudo-pair-{}:juju-info'.format(release))
56+ "ubuntu-{}:juju-info".format(release), "sudo-pair-{}:juju-info".format(release)
57+ )
58
59- await model.block_until(lambda: sudo_pair_app.status == 'active')
60+ await model.block_until(lambda: sudo_pair_app.status == "active")
61 yield sudo_pair_app
62 # no need to cleanup since the model will be be torn down at the end of the
63 # testing
64
65
66-@pytest.fixture(scope='module')
67+@pytest.fixture(scope="module")
68 async def unit(deploy_app):
69- '''Returns the sudo_pair unit we've deployed'''
70+ """Returns the sudo_pair unit we've deployed"""
71 return deploy_app.units.pop()
72
73+
74 #########
75 # TESTS #
76 #########
77
78
79 async def test_deploy(deploy_app):
80- assert deploy_app.status == 'active'
81-
82-
83-@pytest.mark.parametrize("path,expected_stat", [
84- ('/usr/lib/sudo/sudo_pair.so', {
85- 'gid': 0,
86- 'uid': 0,
87- 'mode': '0o100644'}),
88- ('/usr/bin/sudo_approve', {
89- 'gid': 0,
90- 'uid': 0,
91- 'mode': '0o100755'}),
92- ('/etc/sudo_pair.prompt.user', {
93- 'gid': 0,
94- 'uid': 0,
95- 'mode': '0o100644'}),
96- ('/etc/sudo_pair.prompt.pair', {
97- 'gid': 0,
98- 'uid': 0,
99- 'mode': '0o100644'}),
100- ('/var/run/sudo_pair', {
101- 'gid': 0,
102- 'uid': 0,
103- 'mode': '0o40644'})])
104+ assert deploy_app.status == "active"
105+
106+
107+@pytest.mark.parametrize(
108+ "path,expected_stat",
109+ [
110+ ("/usr/lib/sudo/sudo_pair.so", {"gid": 0, "uid": 0, "mode": "0o100644"}),
111+ ("/usr/bin/sudo_approve", {"gid": 0, "uid": 0, "mode": "0o100755"}),
112+ ("/etc/sudo_pair.prompt.user", {"gid": 0, "uid": 0, "mode": "0o100644"}),
113+ ("/etc/sudo_pair.prompt.pair", {"gid": 0, "uid": 0, "mode": "0o100644"}),
114+ ("/var/run/sudo_pair", {"gid": 0, "uid": 0, "mode": "0o40644"}),
115+ ],
116+)
117 async def test_stats(path, expected_stat, unit, file_stat):
118 test_stat = await file_stat(path, unit)
119- assert test_stat['size'] > 0
120- assert test_stat['gid'] == expected_stat['gid']
121- assert test_stat['uid'] == expected_stat['uid']
122- assert test_stat['mode'] == expected_stat['mode']
123+ assert test_stat["size"] > 0
124+ assert test_stat["gid"] == expected_stat["gid"]
125+ assert test_stat["uid"] == expected_stat["uid"]
126+ assert test_stat["mode"] == expected_stat["mode"]
127
128
129 async def test_sudoers(file_contents, unit):
130 sudoers_content = await file_contents("/etc/sudoers", unit)
131- assert 'Defaults log_output' in sudoers_content
132+ assert "Defaults log_output" in sudoers_content
133
134
135 async def test_sudoers_bypass_conf(file_contents, unit):
136 path = "/etc/sudoers.d/91-bypass-sudopair-cmds"
137- sudoers_bypass_content = await file_contents(path=path,
138- target=unit)
139- content = '%warthogs ALL = (ALL) NOLOG_OUTPUT: /bin/ls'
140+ sudoers_bypass_content = await file_contents(path=path, target=unit)
141+ content = "%warthogs ALL = (ALL) NOLOG_OUTPUT: /bin/ls"
142 assert content in sudoers_bypass_content
143
144
145 async def test_reconfigure(reconfigure_app, file_contents, unit, deploy_app):
146- '''Change a charm config parameter and verify that it has been propagated to
147- the unit'''
148- sudo_approve_path = '/usr/bin/sudo_approve'
149- await reconfigure_app(cfg={'auto_approve': 'false'},
150- target=deploy_app)
151- sudo_approve_content = await file_contents(path=sudo_approve_path,
152- target=unit)
153+ """Change a charm config parameter and verify that it has been propagated to
154+ the unit"""
155+ sudo_approve_path = "/usr/bin/sudo_approve"
156+ await reconfigure_app(cfg={"auto_approve": "false"}, target=deploy_app)
157+ sudo_approve_content = await file_contents(path=sudo_approve_path, target=unit)
158 new_content = 'echo "You can\'t approve your own session."'
159 assert new_content in sudo_approve_content
160
161
162 async def test_remove_relation(deploy_app, model, run_command):
163- series = deploy_app.units[0].data['series']
164- app_name = 'sudo-pair-{}'.format(series)
165- principalname = 'ubuntu-{}'.format(series)
166+ series = deploy_app.units[0].data["series"]
167+ app_name = "sudo-pair-{}".format(series)
168+ principalname = "ubuntu-{}".format(series)
169 await deploy_app.remove_relation(
170- '{}:juju-info'.format(app_name),
171- '{}:juju-info'.format(principalname))
172+ "{}:juju-info".format(app_name), "{}:juju-info".format(principalname)
173+ )
174 await model.block_until(lambda: not deploy_app.relations)
175 principal = model.applications[principalname].units[0]
176- res = await run_command('test -f /etc/sudo.conf || echo gone', target=principal)
177- assert res['Stdout'].strip() == 'gone'
178+ res = await run_command("test -f /etc/sudo.conf || echo gone", target=principal)
179+ assert res["Stdout"].strip() == "gone"
180 await model.add_relation(
181- '{}:juju-info'.format(principalname),
182- '{}:juju-info'.format(app_name))
183+ "{}:juju-info".format(principalname), "{}:juju-info".format(app_name)
184+ )
185 await model.block_until(lambda: deploy_app.relations)
186
187
188 async def test_remove_unit(deploy_app, model, run_command):
189- series = deploy_app.units[0].data['series']
190- app_name = 'sudo-pair-{}'.format(series)
191+ series = deploy_app.units[0].data["series"]
192+ app_name = "sudo-pair-{}".format(series)
193 await deploy_app.destroy()
194 while app_name in model.applications:
195 await asyncio.sleep(2)
196- principal = model.applications['ubuntu-{}'.format(series)].units[0]
197- res = await run_command('test -f /etc/sudo.conf || echo gone', target=principal)
198- assert res['Stdout'].strip() == 'gone'
199+ principal = model.applications["ubuntu-{}".format(series)].units[0]
200+ res = await run_command("test -f /etc/sudo.conf || echo gone", target=principal)
201+ assert res["Stdout"].strip() == "gone"

Subscribers

People subscribed via source and target branches