Adding PAP test case
diff --git a/src/test/builder/buildFsm.sh b/src/test/builder/buildFsm.sh
index 7540008..aee58ca 100644
--- a/src/test/builder/buildFsm.sh
+++ b/src/test/builder/buildFsm.sh
@@ -6,3 +6,6 @@
##Generate TLS authentication state machine
python yamlFsm.py -p TlsAuthHolder -f noseTlsAuthTest.yaml > ${odir}/noseTlsAuthHolder.py
+
+##Generate PAP authentication state machine
+python yamlFsm.py -p PAPAuthHolder -f nosePAPTest.yaml > ${odir}/nosePAPAuthHolder.py
diff --git a/src/test/builder/nosePAPTest.yaml b/src/test/builder/nosePAPTest.yaml
new file mode 100644
index 0000000..ef9caab
--- /dev/null
+++ b/src/test/builder/nosePAPTest.yaml
@@ -0,0 +1,32 @@
+States:
+ ST_EAP_SETUP:
+ Events:
+ EVT_EAP_SETUP:
+ Actions:
+ - _eapSetup
+ NextState: ST_EAP_START
+ ST_EAP_START:
+ Events:
+ EVT_EAP_START:
+ Actions:
+ - _eapStart
+ NextState: ST_EAP_ID_REQ
+ ST_EAP_ID_REQ:
+ Events:
+ EVT_EAP_ID_REQ:
+ Actions:
+ - _eapIdReq
+ NextState: ST_EAP_PAP_USER_REQ
+ ST_EAP_PAP_USER_REQ:
+ Events:
+ EVT_EAP_PAP_USER_REQ:
+ Actions:
+ - _eapPAPUserReq
+ NextState: ST_EAP_PAP_PASSWD_REQ
+ ST_EAP_PAP_PASSWD_REQ:
+ Events:
+ EVT_EAP_PAP_PASSWD_REQ:
+ Actions:
+ - _eapPAPPassReq
+ NextState: ST_EAP_PAP_DONE
+
diff --git a/src/test/fsm/nosePAPAuthHolder.py b/src/test/fsm/nosePAPAuthHolder.py
new file mode 100644
index 0000000..ed797a6
--- /dev/null
+++ b/src/test/fsm/nosePAPAuthHolder.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+def initPAPAuthHolderFsmTable(obj,St,Ev):
+ return {
+
+ ## CurrentState Event Actions NextState
+
+ (St.ST_EAP_SETUP, Ev.EVT_EAP_SETUP ):( (obj._eapSetup,), St.ST_EAP_START),
+
+ ## CurrentState Event Actions NextState
+
+ (St.ST_EAP_PAP_PASSWD_REQ, Ev.EVT_EAP_PAP_PASSWD_REQ ):( (obj._eapPAPPassReq,), St.ST_EAP_PAP_DONE),
+
+ ## CurrentState Event Actions NextState
+
+ (St.ST_EAP_PAP_USER_REQ, Ev.EVT_EAP_PAP_USER_REQ ):( (obj._eapPAPUserReq,), St.ST_EAP_PAP_PASSWD_REQ),
+
+ ## CurrentState Event Actions NextState
+
+ (St.ST_EAP_ID_REQ, Ev.EVT_EAP_ID_REQ ):( (obj._eapIdReq,), St.ST_EAP_PAP_USER_REQ),
+
+ ## CurrentState Event Actions NextState
+
+ (St.ST_EAP_START, Ev.EVT_EAP_START ):( (obj._eapStart,), St.ST_EAP_ID_REQ),
+
+}
+
diff --git a/src/test/fsm/noseTlsAuthHolder.py b/src/test/fsm/noseTlsAuthHolder.py
index a060ac8..127b10b 100644
--- a/src/test/fsm/noseTlsAuthHolder.py
+++ b/src/test/fsm/noseTlsAuthHolder.py
@@ -1,4 +1,4 @@
-#!python
+#!/usr/bin/env python
def initTlsAuthHolderFsmTable(obj,St,Ev):
return {
diff --git a/src/test/pap/papTest.py b/src/test/pap/papTest.py
new file mode 100644
index 0000000..3ce25f9
--- /dev/null
+++ b/src/test/pap/papTest.py
@@ -0,0 +1,16 @@
+import unittest
+import os,sys
+CORD_TEST_UTILS = 'utils'
+test_root = os.getenv('CORD_TEST_ROOT') or './'
+sys.path.append(test_root + CORD_TEST_UTILS)
+from EapPAP import PAPAuthTest
+
+class eap_auth_exchange(unittest.TestCase):
+ def test_eap_pap(self):
+ pap = PAPAuthTest()
+ pap.runTest()
+
+if __name__ == '__main__':
+ t = PAPAuthTest()
+ t.runTest()
+
diff --git a/src/test/utils/EapPAP.py b/src/test/utils/EapPAP.py
new file mode 100644
index 0000000..c936dc3
--- /dev/null
+++ b/src/test/utils/EapPAP.py
@@ -0,0 +1,87 @@
+import sys, os
+cord_root = os.getenv('CORD_TEST_ROOT') or './'
+CORD_TEST_FSM = 'fsm'
+sys.path.append(cord_root + CORD_TEST_FSM)
+from EapolAAA import *
+from enum import *
+import nosePAPAuthHolder as PAPAuthHolder
+from socket import *
+from struct import *
+import scapy
+from nose.tools import *
+from CordTestBase import CordTester
+PAP_USER = "raduser"
+PAP_PASSWD = "radpass"
+
+class PAPAuthTest(EapolPacket, CordTester):
+
+ PAPStateTable = Enumeration("PAPStateTable", ("ST_EAP_SETUP",
+ "ST_EAP_START",
+ "ST_EAP_ID_REQ",
+ "ST_EAP_PAP_USER_REQ",
+ "ST_EAP_PAP_PASSWD_REQ",
+ "ST_EAP_PAP_DONE"
+ )
+ )
+ PAPEventTable = Enumeration("PAPEventTable", ("EVT_EAP_SETUP",
+ "EVT_EAP_START",
+ "EVT_EAP_ID_REQ",
+ "EVT_EAP_PAP_USER_REQ",
+ "EVT_EAP_PAP_PASSWD_REQ",
+ "EVT_EAP_PAP_DONE"
+ )
+ )
+ def __init__(self, intf = 'veth0'):
+ self.fsmTable = PAPAuthHolder.initPAPAuthHolderFsmTable(self, self.PAPStateTable, self.PAPEventTable)
+ EapolPacket.__init__(self, intf)
+ CordTester.__init__(self, self.fsmTable, self.PAPStateTable.ST_EAP_PAP_DONE)
+ #self.PAPStateTable, self.PAPEventTable)
+ self.currentState = self.PAPStateTable.ST_EAP_SETUP
+ self.currentEvent = self.PAPEventTable.EVT_EAP_SETUP
+ self.nextState = None
+ self.nextEvent = None
+
+ def _eapSetup(self):
+ print 'Inside EAP PAP Setup'
+ self.setup()
+ self.nextEvent = self.PAPEventTable.EVT_EAP_START
+
+ def _eapStart(self):
+ print 'Inside EAP PAP Start'
+ self.eapol_start()
+ self.nextEvent = self.PAPEventTable.EVT_EAP_ID_REQ
+
+ def _eapIdReq(self):
+ print 'Inside EAP ID Req'
+ p = self.eapol_recv()
+ code, pkt_id, eaplen = unpack("!BBH", p[0:4])
+ print "Code %d, id %d, len %d" %(code, pkt_id, eaplen)
+ assert_equal(code, EAP_REQUEST)
+ reqtype = unpack("!B", p[4:5])[0]
+ reqdata = p[5:4+eaplen]
+ assert_equal(reqtype, EAP_TYPE_ID)
+ print "<====== Send EAP Response with identity = %s ================>" % PAP_USER
+ self.eapol_id_req(pkt_id, PAP_USER)
+ self.nextEvent = self.PAPEventTable.EVT_EAP_PAP_USER_REQ
+
+ def _eapPAPUserReq(self):
+ print 'Inside Challenge'
+ p = self.eapol_recv()
+ code, pkt_id, eaplen = unpack("!BBH", p[0:4])
+ print "Code %d, id %d, len %d" %(code, pkt_id, eaplen)
+ assert_equal(code, EAP_REQUEST)
+ reqtype = unpack("!B", p[4:5])[0]
+ reqdata = p[5:4+eaplen]
+ assert_equal(reqtype, EAP_TYPE_MD5)
+ print "<====== Send EAP Response with Password = %s ================>" % PAP_PASSWD
+ self.eapol_id_req(pkt_id, PAP_PASSWD)
+ self.nextEvent = self.PAPEventTable.EVT_EAP_PAP_PASSWD_REQ
+
+ def _eapPAPPassReq(self):
+ print 'Inside Challenge'
+ p = self.eapol_recv()
+ code, pkt_id, eaplen = unpack("!BBH", p[0:4])
+ print "Code %d, id %d, len %d" %(code, pkt_id, eaplen)
+ assert_equal(code, EAP_SUCCESS)
+ self.nextEvent = self.PAPEventTable.EVT_EAP_PAP_DONE
+