From ab68fcadbfa51e6cdd5edd950c4252da2d16de53 Mon Sep 17 00:00:00 2001 From: Jackie Huang Date: Wed, 26 Apr 2017 16:22:05 +0800 Subject: libauthen-radius-perl: add new recipe The Authen::Radius module provides a simple class that allows you to send/receive Radius requests/responses to/from a Radius server. Signed-off-by: Jackie Huang Signed-off-by: Martin Jansa --- .../libauthen/libauthen-radius-perl/run-ptest | 21 +++++ .../test.pl-adjust-for-ptest.patch | 90 ++++++++++++++++++++++ .../libauthen/libauthen-radius-perl_0.22.bb | 39 ++++++++++ 3 files changed, 150 insertions(+) create mode 100644 meta-perl/recipes-perl/libauthen/libauthen-radius-perl/run-ptest create mode 100644 meta-perl/recipes-perl/libauthen/libauthen-radius-perl/test.pl-adjust-for-ptest.patch create mode 100644 meta-perl/recipes-perl/libauthen/libauthen-radius-perl_0.22.bb (limited to 'meta-perl/recipes-perl') diff --git a/meta-perl/recipes-perl/libauthen/libauthen-radius-perl/run-ptest b/meta-perl/recipes-perl/libauthen/libauthen-radius-perl/run-ptest new file mode 100644 index 000000000..f1c833e6c --- /dev/null +++ b/meta-perl/recipes-perl/libauthen/libauthen-radius-perl/run-ptest @@ -0,0 +1,21 @@ +#!/bin/sh +# + +# prepare testing config +CONF_USERS=`readlink -f /etc/raddb/users` +mv ${CONF_USERS} ${CONF_USERS}_orig +echo "testing Cleartext-Password := \"testpassword\"" > ${CONF_USERS} +cat ${CONF_USERS}_orig >> ${CONF_USERS} + +# restart radiusd server +systemctl restart radiusd || /etc/init.d/radiusd restart || { + echo "FAIL: Start radiusd service." + exit 1 +} + +# run teests +perl test.pl + +# restore the config and restart +mv ${CONF_USERS}_orig ${CONF_USERS} +systemctl restart radiusd || /etc/init.d/radiusd restart diff --git a/meta-perl/recipes-perl/libauthen/libauthen-radius-perl/test.pl-adjust-for-ptest.patch b/meta-perl/recipes-perl/libauthen/libauthen-radius-perl/test.pl-adjust-for-ptest.patch new file mode 100644 index 000000000..9798af497 --- /dev/null +++ b/meta-perl/recipes-perl/libauthen/libauthen-radius-perl/test.pl-adjust-for-ptest.patch @@ -0,0 +1,90 @@ +From 829302792bf0e4935d29efc23ca1f2e9e7ee7dfd Mon Sep 17 00:00:00 2001 +From: Jackie Huang +Date: Thu, 7 Jan 2016 03:12:38 -0500 +Subject: [PATCH] test.pl: adjust for ptest + +* Don't use interactive inputs, set default test + settings instead. +* Change the test results output to the ptest format + +Upstream-Status: Inappropriate [OE ptest specific] + +Signed-off-by: Jackie Huang +--- + test.pl | 31 ++++++++++++++++++------------- + 1 file changed, 18 insertions(+), 13 deletions(-) + +diff --git a/test.pl b/test.pl +index cfd1c1e..9b4f10e 100644 +--- a/test.pl ++++ b/test.pl +@@ -7,11 +7,11 @@ + # Change 1..1 below to 1..last_test_to_print . + # (It may become useful if the test is moved to ./t subdirectory.) + +-BEGIN {print "1..5\n";} +-END {print "not ok 1\n" unless $loaded;} ++BEGIN {print "Start testing for libauthen-radius-perl\n";} ++END {print "\nFAIL: test1\n" unless $loaded;} + use Authen::Radius; + $loaded = 1; +-print "ok 1\n"; ++print "\nPASS: test1\n"; + + ######################### End of black magic. + +@@ -19,26 +19,31 @@ print "ok 1\n"; + # (correspondingly "not ok 13") depending on the success of chunk 13 + # of the test code): + ++$host = "127.0.0.1"; ++$secret = "testing123"; ++$user = "testing"; ++$pwd = "testpassword"; ++ + print "Make sure this machine is in your Radius clients file!\n"; +-print "Enter hostname[:port] of your Radius server: "; chomp ($host = ); +-print "Enter shared-secret of your Radius server: "; chomp ($secret = ); +-print "Enter a username to be validated: "; chomp ($user = ); +-print "Enter this user's password: "; chomp ($pwd = ); ++print "hostname of your Radius server: $host\n"; ++print "shared-secret of your Radius server: $secret\n"; ++print "The username to be validated: $user\n"; ++print "The user's password: $pwd\n"; + + $t = 2; + if ($host ne '') { + $r = new Authen::Radius(Host => $host, Secret => $secret, Debug => 1); +- print defined($r) ? "" : "not ", "ok $t\n"; $t++; ++ print defined($r) ? "\nPASS: test$t\n" : "\nFAIL: test$t\n"; $t++; + #Authen::Radius->load_dictionary; +- print $r->check_pwd($user, $pwd) ? "" : "not ", "ok $t\n"; $t++; ++ print $r->check_pwd($user, $pwd) ? "\nPASS: test$t\n" : "\nFAIL: test$t\n"; $t++; + @a = $r->get_attributes; +- print $#a != -1 ? "" : "not ", "ok $t\n"; $t++; ++ print $#a != -1 ? "\nPASS: test$t\n" : "\nFAIL: test$t\n"; $t++; + #for $a (@a) { + # print "attr: name=$a->{'Name'} value=$a->{'Value'}\n"; + #} + } else { + foreach my $t (2..4) { +- print "skipped $t\n"; ++ print "\nSKIP test$t\n"; + } + } + +@@ -53,9 +58,9 @@ my $data = "what do ya want for nothing?"; + my $etalon_digest = hex_to_ascii("750c783e6ab0b503eaa86e310a5db738"); + my $digest = Authen::Radius::hmac_md5(undef, $data, $key); + if ($etalon_digest eq $digest) { +- print "ok 5\n"; ++ print "\nPASS: test5\n"; + } else { +- print "not ok 5\n"; ++ print "\nFAIL: test5\n"; + } + + exit; +-- +1.9.1 + diff --git a/meta-perl/recipes-perl/libauthen/libauthen-radius-perl_0.22.bb b/meta-perl/recipes-perl/libauthen/libauthen-radius-perl_0.22.bb new file mode 100644 index 000000000..ea5bb1b0c --- /dev/null +++ b/meta-perl/recipes-perl/libauthen/libauthen-radius-perl_0.22.bb @@ -0,0 +1,39 @@ +SUMMARY = "Authen::Radius - provide simple Radius client facilities" +DESCRIPTION = "The Authen::Radius module provides a simple class that \ + allows you to send/receive Radius requests/responses to/from a \ + Radius server. \ +" + +HOMEPAGE = "http://search.cpan.org/~manowar/RadiusPerl" +SECTION = "libs" + +LICENSE = "Artistic-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=78ab6ea0cba1f1ec1680ebb149e3bc11" + +DEPENDS = "perl" + +SRC_URI = "http://search.cpan.org/CPAN/authors/id/M/MA/MANOWAR/RadiusPerl-${PV}.tar.gz \ + file://test.pl-adjust-for-ptest.patch \ + file://run-ptest \ +" +SRC_URI[md5sum] = "d1fe2d6ecf7ea99299e4e3a8f945aad8" +SRC_URI[sha256sum] = "3b276506986ccaa4949d92b13ce053a0017ad11562a991cc753364923fe81ca7" + +S = "${WORKDIR}/Authen-Radius-${PV}" + +inherit cpan ptest + +do_install_ptest() { + install -m 0755 ${S}/test.pl ${D}${PTEST_PATH} +} + +RDEPENDS_${PN} += "\ + libdata-hexdump-perl \ + perl-module-digest-md5 \ + perl-module-data-dumper \ + perl-module-io-select \ + perl-module-io-socket \ +" +RDEPENDS_${PN}-ptest += "${PN} freeradius" + +BBCLASSEXTEND = "native" -- cgit v1.2.3-54-g00ecf