Merge ~ahasenack/ubuntu/+source/freeradius:kinetic-dep8-for-python3 into ubuntu/+source/freeradius:ubuntu/devel

Proposed by Andreas Hasenack
Status: Merged
Merged at revision: 35dd74c958bec7a16f1a1b54df0635f906dc6d50
Proposed branch: ~ahasenack/ubuntu/+source/freeradius:kinetic-dep8-for-python3
Merge into: ubuntu/+source/freeradius:ubuntu/devel
Diff against target: 284 lines (+235/-1)
7 files modified
debian/changelog (+10/-0)
debian/tests/control (+4/-0)
debian/tests/freeradius (+1/-1)
debian/tests/rlm_python3-data/python3.mods-available (+66/-0)
debian/tests/rlm_python3-data/python3.sites-available (+85/-0)
debian/tests/rlm_python3-data/ubuntu_example.py.mods-config (+26/-0)
debian/tests/rlm_python3-test (+43/-0)
Reviewer Review Type Date Requested Status
Sergio Durigan Junior (community) Approve
Canonical Server Pending
Review via email: mp+421436@code.launchpad.net

Description of the change

This pulls in the DEP8 test that I created for bug #1873923 for the focal upload. They apply as is, but due to different checks that this version of freeradius in jammy/kinetic does, I had to put one small commit on top of it. I kept it separate to facilitate review, and it can be squashed together in the next upload.

Speaking of review, you can use this range-diff command line if you also have the focal branch for that bug:

git range-diff pkg/ubuntu/focal-devel..focal-freeradius-py3.8-1873923 pkg/ubuntu/devel..kinetic-dep8-for-python3

(atm focal-devel works, because the SRU team didn't accept the package yet)

I ran DEP8 tests locally (that's how I found out about the need of that extra commit on top) on a kinetic VM:

(...)
autopkgtest [17:20:45]: test rlm_python3-test: [-----------------------
Test that "ubuntu" can login with any password
    Reply-Message = "Hello ubuntu!"
Test that any other user won't work
    Reply-Message = "You are not ubuntu!"
autopkgtest [17:20:47]: test rlm_python3-test: -----------------------]
autopkgtest [17:20:47]: test rlm_python3-test: - - - - - - - - - - results - - - - - - - - - -
rlm_python3-test PASS
autopkgtest [17:20:47]: @@@@@@@@@@@@@@@@@@@@ summary
freeradius PASS
daemon PASS
clients PASS
rlm_python3-test PASS

As usual, I'll send this to Debian after the review.

To post a comment you must log in.
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

I'm reviewing this one.

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks for the MP, Andreas.

I built the package locally and ran autopkgtest; everything is working as expected. Since I've already reviewed the changes for Focal, this also LGTM. I verified the commit you put on top and it looks OK.

+1

review: Approve
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Thanks, uploaded
Uploading freeradius_3.0.26~dfsg~git20220223.1.00ed0241fa-0ubuntu4.dsc
Uploading freeradius_3.0.26~dfsg~git20220223.1.00ed0241fa-0ubuntu4.debian.tar.xz
Uploading freeradius_3.0.26~dfsg~git20220223.1.00ed0241fa-0ubuntu4_source.buildinfo
Uploading freeradius_3.0.26~dfsg~git20220223.1.00ed0241fa-0ubuntu4_source.changes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 41187e9..9fe2e0a 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,13 @@
6+freeradius (3.0.26~dfsg~git20220223.1.00ed0241fa-0ubuntu4) kinetic; urgency=medium
7+
8+ * Add test for rlm_python3 (LP: #1969381):
9+ - d/t/control: new rlm_python3 test
10+ - d/t/rlm_python3-test: test the rlm_python3 module
11+ - d/t/rlm_python3-data/*: test files
12+ * d/t/freeradius: run python tests in verbose mode
13+
14+ -- Andreas Hasenack <andreas@canonical.com> Wed, 04 May 2022 15:38:02 -0300
15+
16 freeradius (3.0.26~dfsg~git20220223.1.00ed0241fa-0ubuntu3) jammy; urgency=medium
17
18 * d/p/fix-python-version-parsing.patch: fix parsing of python versions
19diff --git a/debian/tests/control b/debian/tests/control
20index 8f1aaeb..f8a3e2a 100644
21--- a/debian/tests/control
22+++ b/debian/tests/control
23@@ -1,3 +1,7 @@
24 Tests: freeradius daemon clients
25 Depends: freeradius, freeradius-utils, python3, lsb-release
26 Restrictions: needs-root
27+
28+Tests: rlm_python3-test
29+Depends: freeradius, freeradius-python3, freeradius-utils
30+Restrictions: needs-root
31diff --git a/debian/tests/freeradius b/debian/tests/freeradius
32index d7c51a8..7445a93 100644
33--- a/debian/tests/freeradius
34+++ b/debian/tests/freeradius
35@@ -3,4 +3,4 @@
36 # Testing freeradius
37 #-------------------
38 set -e
39-python3 `dirname $0`/test-freeradius.py 2>&1
40+python3 `dirname $0`/test-freeradius.py -v 2>&1
41diff --git a/debian/tests/rlm_python3-data/python3.mods-available b/debian/tests/rlm_python3-data/python3.mods-available
42new file mode 100644
43index 0000000..d10a019
44--- /dev/null
45+++ b/debian/tests/rlm_python3-data/python3.mods-available
46@@ -0,0 +1,66 @@
47+#
48+# Make sure the PYTHONPATH environmental variable contains the
49+# directory(s) for the modules listed below.
50+#
51+# Uncomment any func_* which are included in your module. If
52+# rlm_python is called for a section which does not have
53+# a function defined, it will return NOOP.
54+#
55+python3 {
56+ # Path to the python modules
57+ #
58+ # Note that due to limitations on Python, this configuration
59+ # item is GLOBAL TO THE SERVER. That is, you cannot have two
60+ # instances of the python module, each with a different path.
61+ #
62+# python_path="/path/to/python/files:/another_path/to/python_files/"
63+
64+ python_path="${modconfdir}/${.:name}"
65+ module = ubuntu_example
66+
67+ # Pass all VPS lists as a 6-tuple to the callbacks
68+ # (request, reply, config, state, proxy_req, proxy_reply)
69+ # pass_all_vps = no
70+
71+ # Pass all VPS lists as a dictionary to the callbacks
72+ # Keys: "request", "reply", "config", "session-state", "proxy-request",
73+ # "proxy-reply"
74+ # This option prevales over "pass_all_vps"
75+ # pass_all_vps_dict = no
76+
77+ mod_instantiate = ${.module}
78+ func_instantiate = instantiate
79+
80+ mod_detach = ${.module}
81+ func_detach = detach
82+
83+ mod_authorize = ${.module}
84+ func_authorize = authorize
85+
86+# mod_authenticate = ${.module}
87+# func_authenticate = authenticate
88+
89+# mod_preacct = ${.module}
90+# func_preacct = preacct
91+
92+# mod_accounting = ${.module}
93+# func_accounting = accounting
94+
95+# mod_checksimul = ${.module}
96+# func_checksimul = checksimul
97+
98+# mod_pre_proxy = ${.module}
99+# func_pre_proxy = pre_proxy
100+
101+# mod_post_proxy = ${.module}
102+# func_post_proxy = post_proxy
103+
104+# mod_post_auth = ${.module}
105+# func_post_auth = post_auth
106+
107+# mod_recv_coa = ${.module}
108+# func_recv_coa = recv_coa
109+
110+# mod_send_coa = ${.module}
111+# func_send_coa = send_coa
112+}
113diff --git a/debian/tests/rlm_python3-data/python3.sites-available b/debian/tests/rlm_python3-data/python3.sites-available
114new file mode 100644
115index 0000000..93333f8
116--- /dev/null
117+++ b/debian/tests/rlm_python3-data/python3.sites-available
118@@ -0,0 +1,85 @@
119+server python3_test {
120+listen {
121+ type = auth
122+ ipaddr = *
123+ port = 1234
124+ limit {
125+ max_connections = 16
126+ lifetime = 0
127+ idle_timeout = 30
128+ }
129+}
130+authorize {
131+ filter_username
132+ preprocess
133+ python3
134+ chap
135+ mschap
136+ digest
137+ suffix
138+ eap {
139+ ok = return
140+ }
141+ files
142+ -sql
143+ -ldap
144+ expiration
145+ logintime
146+ pap
147+}
148+authenticate {
149+ Auth-Type PAP {
150+ pap
151+ }
152+ Auth-Type CHAP {
153+ chap
154+ }
155+ Auth-Type MS-CHAP {
156+ mschap
157+ }
158+ mschap
159+ digest
160+ eap
161+}
162+preacct {
163+ preprocess
164+ acct_unique
165+ suffix
166+ files
167+}
168+accounting {
169+ detail
170+ unix
171+ -sql
172+ exec
173+ attr_filter.accounting_response
174+}
175+session {
176+}
177+post-auth {
178+ if (session-state:User-Name && reply:User-Name && request:User-Name && (reply:User-Name == request:User-Name)) {
179+ update reply {
180+ &User-Name !* ANY
181+ }
182+ }
183+ update {
184+ &reply: += &session-state:
185+ }
186+ -sql
187+ exec
188+ remove_reply_message_if_eap
189+ Post-Auth-Type REJECT {
190+ -sql
191+ attr_filter.access_reject
192+ eap
193+ remove_reply_message_if_eap
194+ }
195+ Post-Auth-Type Challenge {
196+ }
197+}
198+pre-proxy {
199+}
200+post-proxy {
201+ eap
202+}
203+}
204diff --git a/debian/tests/rlm_python3-data/ubuntu_example.py.mods-config b/debian/tests/rlm_python3-data/ubuntu_example.py.mods-config
205new file mode 100644
206index 0000000..5b6330f
207--- /dev/null
208+++ b/debian/tests/rlm_python3-data/ubuntu_example.py.mods-config
209@@ -0,0 +1,26 @@
210+#! /usr/bin/env python3
211+
212+import radiusd
213+
214+def instantiate(p):
215+ radiusd.radlog(radiusd.L_INFO, '*** example.py instantiate ***')
216+ return radiusd.RLM_MODULE_OK
217+
218+def authorize(p):
219+ radiusd.radlog(radiusd.L_INFO, '*** example.py authorize ***')
220+ # whatever password was supplied
221+ config = ( ('Cleartext-Password', p[1][1]), )
222+ if p[0][1] == "ubuntu":
223+ msg = "Hello ubuntu!"
224+ status = radiusd.RLM_MODULE_OK
225+ reply = ( ('Reply-Message', msg), )
226+ return (radiusd.RLM_MODULE_OK, reply, config)
227+ else:
228+ msg = "You are not ubuntu!"
229+ reply = ( ('Reply-Message', msg), )
230+ status = radiusd.RLM_MODULE_REJECT
231+ return (status, reply, config)
232+
233+def detach(p):
234+ radiusd.radlog(radiusd.L_INFO, "*** example.py detach ***")
235+ return radiusd.RLM_MODULE_OK
236diff --git a/debian/tests/rlm_python3-test b/debian/tests/rlm_python3-test
237new file mode 100644
238index 0000000..ddf0982
239--- /dev/null
240+++ b/debian/tests/rlm_python3-test
241@@ -0,0 +1,43 @@
242+#!/bin/sh
243+
244+set -e
245+
246+cp debian/tests/rlm_python3-data/python3.mods-available \
247+ /etc/freeradius/3.0/mods-available/python3
248+cp debian/tests/rlm_python3-data/python3.sites-available \
249+ /etc/freeradius/3.0/sites-available/python3-test
250+cp debian/tests/rlm_python3-data/ubuntu_example.py.mods-config \
251+ /etc/freeradius/3.0/mods-config/python3/ubuntu_example.py
252+
253+# enable our python3 test site
254+ln -sf /etc/freeradius/3.0/sites-available/python3-test \
255+ /etc/freeradius/3.0/sites-enabled
256+
257+# enable the python3 module
258+ln -sf /etc/freeradius/3.0/mods-available/python3 \
259+ /etc/freeradius/3.0/mods-enabled
260+
261+# restart
262+systemctl restart freeradius.service
263+
264+echo "Test that \"ubuntu\" can login with any password"
265+result=0
266+output=$(radtest ubuntu anypass$$ 127.0.0.1:1234 0 testing123) || result=$?
267+if [ ${result} -ne 0 ]; then
268+ echo "Failed. Output:"
269+ echo "${output}"
270+ exit 1
271+else
272+ echo "${output}" | grep "Reply-Message"
273+fi
274+
275+echo "Test that any other user won't work"
276+result=0
277+output=$(radtest otheruser$$ secret$$ 127.0.0.1:1234 0 testing123 2>&1) || result=$?
278+echo "${output}" | grep "Reply-Message"
279+if [ ${result} -eq 0 ]; then
280+ echo "This shouldn't have worked..."
281+ echo "Output:"
282+ echo "${output}"
283+ exit 1
284+fi

Subscribers

People subscribed via source and target branches