Mailinglist Archive: limal-commit (5 mails)

< Previous Next >
[limal-commit] r2533 - in /limal-head/limal-ca-mgm: src/Utils.hpp testsuite/IPv6CheckTest.cc testsuite/Makefile.am testsuite/single.out/IPv6CheckTest.err testsuite/single.out/IPv6CheckTest.out
  • From: mcalmer@xxxxxxxxxxxxxxxx
  • Date: Tue, 01 Jul 2008 13:38:48 -0000
  • Message-id: <20080701133849.029DA2A397@xxxxxxxxxxxxxxxx>
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 <blocxx/Logger.hpp>
+#include <blocxx/AppenderLogger.hpp>
+#include <blocxx/CerrLogger.hpp>
+#include <blocxx/CerrAppender.hpp>
+#include <blocxx/String.hpp>
+#include <blocxx/PerlRegEx.hpp>
+#include <limal/Logger.hpp>
+#include <limal/PathInfo.hpp>
+#include <limal/ca-mgm/CA.hpp>
+#include <limal/Exception.hpp>
+#include <limal/ValueCheck.hpp>
+#include "Utils.hpp"
+
+#include <iostream>
+#include <fstream>
+#include <unistd.h>
+
+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@xxxxxxxxxxxx
For additional commands, e-mail: limal-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages