Author: mcalmer
Date: Tue Jul 1 15:38:48 2008
New Revision: 2533
URL: http://svn.opensuse.org/viewcvs/limal?rev=2533&view=rev
Log:
- fix initIP6Check
- add testcase for IPv6 addresses
Added:
limal-head/limal-ca-mgm/testsuite/IPv6CheckTest.cc
limal-head/limal-ca-mgm/testsuite/single.out/IPv6CheckTest.err
limal-head/limal-ca-mgm/testsuite/single.out/IPv6CheckTest.out
Modified:
limal-head/limal-ca-mgm/src/Utils.hpp
limal-head/limal-ca-mgm/testsuite/Makefile.am
Modified: limal-head/limal-ca-mgm/src/Utils.hpp
URL: http://svn.opensuse.org/viewcvs/limal/limal-head/limal-ca-mgm/src/Utils.hpp?rev=2533&r1=2532&r2=2533&view=diff
==============================================================================
--- limal-head/limal-ca-mgm/src/Utils.hpp (original)
+++ limal-head/limal-ca-mgm/src/Utils.hpp Tue Jul 1 15:38:48 2008
@@ -154,7 +154,18 @@
inline limal::ValueCheck initIP6Check() {
limal::ValueCheck checkIP =
- limal::ValueCheck(new limal::ValuePosixRECheck("^([0-9a-fA-F]{0,4}:){7}[0-9a-fA-F]{0,4}$"));
+ limal::ValueCheck(new limal::ValuePosixRECheck("^([0-9a-fA-F]{1,4}:){7}([0-9a-fA-F]){1,4}$"))
+ .Or(new limal::ValuePosixRECheck("^:(:[0-9a-fA-F]{1,4}){1,6}$"))
+ .Or(new limal::ValuePosixRECheck("^([0-9a-fA-F]{1,4}:){1,6}:$"))
+ .Or(
+ limal::ValueCheck(
+ limal::ValueCheck( new limal::ValuePosixRECheck( "^(([0-9a-fA-F]{1,4}):){1,6}(:([0-9a-fA-F]{1,4})){1,6}$"))
+ ).And(
+ limal::ValueCheck( new limal::ValuePosixRECheck("^([^:]*:){8,}")).Not()
+ ).And(
+ limal::ValueCheck( new limal::ValuePosixRECheck("::.*::") ).Not()
+ )
+ );
return checkIP;
}
Added: limal-head/limal-ca-mgm/testsuite/IPv6CheckTest.cc
URL: http://svn.opensuse.org/viewcvs/limal/limal-head/limal-ca-mgm/testsuite/IPv6CheckTest.cc?rev=2533&view=auto
==============================================================================
--- limal-head/limal-ca-mgm/testsuite/IPv6CheckTest.cc (added)
+++ limal-head/limal-ca-mgm/testsuite/IPv6CheckTest.cc Tue Jul 1 15:38:48 2008
@@ -0,0 +1,82 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "Utils.hpp"
+
+#include <iostream>
+#include <fstream>
+#include
+
+using namespace blocxx;
+using namespace limal;
+using namespace limal::ca_mgm;
+using namespace std;
+
+int main()
+{
+ try
+ {
+ cout << "START" << endl;
+
+ blocxx::StringArray cat;
+ cat.push_back("FATAL");
+ cat.push_back("ERROR");
+ cat.push_back("INFO");
+ //cat.push_back("DEBUG");
+
+ // Logging
+ LoggerRef l = limal::Logger::createCerrLogger(
+ "IPv6CheckTest",
+ LogAppender::ALL_COMPONENTS,
+ cat,
+ "%-5p %c - %m"
+ );
+ limal::Logger::setDefaultLogger(l);
+
+ cout << "=================== start Test ======================" << endl;
+
+ ValueCheck check = initIP6Check();
+
+ blocxx::StringArray iparr ;
+ iparr.push_back("2001:780:101:a00:211:11ff:fee6:a5af");
+ iparr.push_back("fe80::211:11ff:fee6:a5af");
+ iparr.push_back("2001::a5af");
+ iparr.push_back("fe80:1:211:11ff:fee6::");
+
+ iparr.push_back("fe80::211::fee6:a5af");
+ iparr.push_back("2001:780:101:a00:211:11ff:fee6:a5af:afff");
+ iparr.push_back("g001:780:101:a00:211:11ff:fee6:a5af");
+
+ StringArray::const_iterator ip_it;
+ for(ip_it = iparr.begin(); ip_it != iparr.end(); ++ip_it)
+ {
+ //cout << "Explain: "<< check.explain(*ip_it) << endl;
+ if(check.isValid((*ip_it)))
+ {
+ cout << *ip_it << " => is valid" << endl;
+ }
+ else
+ {
+ cout << *ip_it << " => is not valid" << endl;
+ }
+ }
+
+ cout << "DONE" << endl;
+ }
+ catch(Exception& e)
+ {
+ cerr << e << endl;
+ }
+
+ return 0;
+}
+
+/* vim: set ts=8 sts=8 sw=8 ai noet: */
Modified: limal-head/limal-ca-mgm/testsuite/Makefile.am
URL: http://svn.opensuse.org/viewcvs/limal/limal-head/limal-ca-mgm/testsuite/Makefile.am?rev=2533&r1=2532&r2=2533&view=diff
==============================================================================
--- limal-head/limal-ca-mgm/testsuite/Makefile.am (original)
+++ limal-head/limal-ca-mgm/testsuite/Makefile.am Tue Jul 1 15:38:48 2008
@@ -33,7 +33,7 @@
ImportCommonCertificateTest.single \
ConvertTest.single iniParser.multi \
sysConfig.single RequestTest.single \
- CRLTest.single
+ CRLTest.single IPv6CheckTest.single
CAConfig_single_SOURCES = CAConfig.cc
@@ -119,6 +119,8 @@
CRLTest_single_SOURCES = CRLTest.cc
+IPv6CheckTest_single_SOURCES = IPv6CheckTest.cc
+
clean-local:
rm -f tmp.err.* tmp.out.* site.exp site.bak openssl.cnf.tmpl.test
rm -f *~ limal.log limal.sum .rnd
Added: limal-head/limal-ca-mgm/testsuite/single.out/IPv6CheckTest.err
URL: http://svn.opensuse.org/viewcvs/limal/limal-head/limal-ca-mgm/testsuite/single.out/IPv6CheckTest.err?rev=2533&view=auto
==============================================================================
(empty)
Added: limal-head/limal-ca-mgm/testsuite/single.out/IPv6CheckTest.out
URL: http://svn.opensuse.org/viewcvs/limal/limal-head/limal-ca-mgm/testsuite/single.out/IPv6CheckTest.out?rev=2533&view=auto
==============================================================================
--- limal-head/limal-ca-mgm/testsuite/single.out/IPv6CheckTest.out (added)
+++ limal-head/limal-ca-mgm/testsuite/single.out/IPv6CheckTest.out Tue Jul 1 15:38:48 2008
@@ -0,0 +1,10 @@
+START
+=================== start Test ======================
+2001:780:101:a00:211:11ff:fee6:a5af => is valid
+fe80::211:11ff:fee6:a5af => is valid
+2001::a5af => is valid
+fe80:1:211:11ff:fee6:: => is valid
+fe80::211::fee6:a5af => is not valid
+2001:780:101:a00:211:11ff:fee6:a5af:afff => is not valid
+g001:780:101:a00:211:11ff:fee6:a5af => is not valid
+DONE
--
To unsubscribe, e-mail: limal-commit+unsubscribe@opensuse.org
For additional commands, e-mail: limal-commit+help@opensuse.org