From: "cron2 (Code Review)" Date: Mon, 29 Jan 2024 13:55:24 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <2f7c95aa683c0ea563bf7f0e21b7645037e81803-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="k1edvpRiJpA="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: test_user_pass: Add UTs for character filtering List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --k1edvpRiJpA= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#7) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/473?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2, Code-Review+2 by plaisthos Change subject: test_user_pass: Add UTs for character filtering ...................................................................... test_user_pass: Add UTs for character filtering For simplicity I implemented them only with the inline method, but they actually apply to all methods. Change-Id: Ie8d2d5f6f58679baaf5eb817a7e2ca1afcb8c4db Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe Acked-by: Gert Doering Message-Id: <20240129105358.11161-1-gert@...1296...> URL: https://www.mail-archive.com/search?l=3Dmid&q=3D20240129105358.11161-1= -gert@...1296... Signed-off-by: Gert Doering --- M tests/unit_tests/openvpn/test_user_pass.c 1 file changed, 23 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/73/473/7 diff --git a/tests/unit_tests/openvpn/test_user_pass.c b/tests/unit_tests/o= penvpn/test_user_pass.c index ab4dfe4..277cb1d 100644 --- a/tests/unit_tests/openvpn/test_user_pass.c +++ b/tests/unit_tests/openvpn/test_user_pass.c @@ -141,6 +141,29 @@ reset_user_pass(&up); + /* Test various valid characters */ + /*FIXME: query_user_exec() called even though nothing queued */ + will_return(query_user_exec_builtin, true); + /* FIXME? content after first two lines just ignored */ + assert_true(get_user_pass_cr(&up, "#iuser and =EC=BB=A4=EB=AE=A4=EB=8B= =88=ED=8B=B0\n//ipassw=C3=B6rd!\nsome other content\nnot relevant", "UT", f= lags, NULL)); + assert_true(up.defined); + assert_string_equal(up.username, "#iuser and =EC=BB=A4=EB=AE=A4=EB=8B= =88=ED=8B=B0"); + assert_string_equal(up.password, "//ipassw=C3=B6rd!"); + + reset_user_pass(&up); + + /* Test various invalid characters */ + /*FIXME: query_user_exec() called even though nothing queued */ + will_return(query_user_exec_builtin, true); + /*FIXME? allows arbitrary crap if c > 127 */ + /*FIXME? silently removes control characters */ + assert_true(get_user_pass_cr(&up, "\tiuser\r\nipass\xffwo\x1erd", "UT"= , flags, NULL)); + assert_true(up.defined); + assert_string_equal(up.username, "iuser"); + assert_string_equal(up.password, "ipass\xffword"); + + reset_user_pass(&up); + expect_string(query_user_exec_builtin, query_user[i].prompt, "Enter UT= Password:"); will_return(query_user_exec_builtin, "cpassword"); will_return(query_user_exec_builtin, true); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/473?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ie8d2d5f6f58679baaf5eb817a7e2ca1afcb8c4db Gerrit-Change-Number: 473 Gerrit-PatchSet: 7 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --k1edvpRiJpA= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #7 to the change originally cr= eated by flichtenheld.

View Change

The following approvals got outda= ted and were removed: Code-Review+2 by cron2, Code-Review+2 by plaisthos

test_user_pass: Add UTs =
for character filtering

For simplicity I implemented them only with = the
inline method, but they actually apply to all methods.

Change= -Id: Ie8d2d5f6f58679baaf5eb817a7e2ca1afcb8c4db
Signed-off-by: Frank Lich= tenheld <frank@...2641...>
Acked-by: Arne Schwabe <arne-openvpn= @...1227...>
Acked-by: Gert Doering <gert@...1296...>
Messag= e-Id: <20240129105358.11161-1-gert@...1296...>
URL: https://www.ma= il-archive.com/search?l=3Dmid&q=3D20240129105358.11161-1-gert@...2132...= .
Signed-off-by: Gert Doering <gert@...1296...>
---
M tests/= unit_tests/openvpn/test_user_pass.c
1 file changed, 23 insertions(+), 0 = deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs=
/changes/73/473/7
diff --git a/tests/unit_tests/openvpn/test_user_p=
ass.c b/tests/unit_tests/openvpn/test_user_pass.c
index ab4= dfe4..277cb1d 100644
--- a/tests/unit_tests/openvpn/test_us= er_pass.c
+++ b/tests/unit_tests/openvpn/test_user_pass.c
@@ -141,6 +141,29 @@

= reset_user_pass(&up);

+ /* Test various valid characters */
<= span style=3D"color: hsl(120, 100%, 40%);">+ /*FIXME: query_user_exec() = called even though nothing queued */

+ will_return(query_user_exec_builtin, true);
= + /* FIXME? content after fi= rst two lines just ignored */
+ assert_true(get_user_pass_cr(&up, "#iuser and =EC=BB= =A4=EB=AE=A4=EB=8B=88=ED=8B=B0\n//ipassw=C3=B6rd!\nsome other content\nnot = relevant", "UT", flags, NULL));
+ assert_true(up.defined);
+ assert_string_equal(up.username, &q= uot;#iuser and =EC=BB=A4=EB=AE=A4=EB=8B=88=ED=8B=B0");
+ assert_string_equal(up.password= , "//ipassw=C3=B6rd!");
+
+ r= eset_user_pass(&up);
+
+ /* Test va= rious invalid characters */
+ /*FIXME: query_user_exec() called even though nothing queued */=
+ will_return(que= ry_user_exec_builtin, true);
+ /*FIXME? allows arbitrary crap if c > 127 */
+ /*FIXME? silently removes cont= rol characters */
+ = assert_true(get_user_pass_cr(&up, "\tiuser\r\nipass\xffwo\x1erd&= quot;, "UT", flags, NULL));
+ assert_true(up.defined);
+ assert_string_equal(up.username, "iuser= ");
+ assert_= string_equal(up.password, "ipass\xffword");
+
+ reset_user_pass(&up);
+
expect_string(query_user_exe= c_builtin, query_user[i].prompt, "Enter UT Password:"); will_return(query_user_exec_builtin, "cpassword");
will_return(query_user_exec_builtin, true);

To view, visit change 473. To unsubscribe, or for help w= riting mail filters, visit s= ettings.

=
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie8d2d5f6f58679baaf5eb817a7e= 2ca1afcb8c4db
Gerrit-Change-Number: 473
Gerrit-PatchSet: 7
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--k1edvpRiJpA=--