From 3e6768937e2bd8e4149972dd6226eeb9bc4e0088 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 16 Nov 2016 14:55:21 +0100 Subject: [PATCH] Use IPA module for vty tests Replace hackish ipa_send_* routines with proper implementation from IPA module thus making it part of extended tests. Change-Id: If13ed7fd243ce3aeef505d2e8468e221aa62f79e --- openbsc/tests/vty_test_runner.py | 40 +++++++------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index cf2cf180f..89b7a1990 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import os +import os, sys import time import unittest import socket @@ -23,6 +23,9 @@ import socket import osmopy.obscvty as obscvty import osmopy.osmoutil as osmoutil +sys.path.append("../contrib") +from ipa import IPA + confpath = '.' class TestVTYBase(unittest.TestCase): @@ -911,13 +914,13 @@ class TestVTYNAT(TestVTYGenericBSC): self.assertEqual(data, "\x00\x01\xfe\x04") print "Going to send ID_RESP response" - res = ipa_send_resp(ussdSocket, "\x6b\x65\x79") + res = ussdSocket.send(IPA().id_resp(IPA().tag_name('key'))) self.assertEqual(res, 10) # initiating PING/PONG cycle to know, that the ID_RESP message has been processed print "Going to send PING request" - res = ipa_send_ping(ussdSocket) + res = ussdSocket.send(IPA().ping()) self.assertEqual(res, 4) print "Expecting PONG response" @@ -1184,31 +1187,6 @@ def add_nat_test(suite, workdir): test = unittest.TestLoader().loadTestsFromTestCase(TestVTYNAT) suite.addTest(test) -def ipa_send_pong(x, verbose = False): - if (verbose): - print "\tBSC -> NAT: PONG!" - return x.send("\x00\x01\xfe\x01") - -def ipa_send_ping(x, verbose = False): - if (verbose): - print "\tBSC -> NAT: PING?" - return x.send("\x00\x01\xfe\x00") - -def ipa_send_ack(x, verbose = False): - if (verbose): - print "\tBSC -> NAT: IPA ID ACK" - return x.send("\x00\x01\xfe\x06") - -def ipa_send_reset(x, verbose = False): - if (verbose): - print "\tBSC -> NAT: RESET" - return x.send("\x00\x12\xfd\x09\x00\x03\x05\x07\x02\x42\xfe\x02\x42\xfe\x06\x00\x04\x30\x04\x01\x20") - -def ipa_send_resp(x, tk, verbose = False): - if (verbose): - print "\tBSC -> NAT: IPA ID RESP" - return x.send("\x00\x07\xfe\x05\x00\x04\x01" + tk) - def nat_bsc_reload(x): x.vty.command("configure terminal") x.vty.command("nat") @@ -1264,11 +1242,11 @@ def ipa_handle_small(x, verbose = False): if "0001fe00" == s: if (verbose): print "\tBSC <- NAT: PING?" - ipa_send_pong(x, verbose) + x.send(IPA().pong()) elif "0001fe06" == s: if (verbose): print "\tBSC <- NAT: IPA ID ACK" - ipa_send_ack(x, verbose) + x.send(IPA().id_ack()) elif "0001fe00" == s: if (verbose): print "\tBSC <- NAT: PONG!" @@ -1279,7 +1257,7 @@ def ipa_handle_small(x, verbose = False): def ipa_handle_resp(x, tk, verbose = False): s = data2str(x.recv(38)) if "0023fe040108010701020103010401050101010011" in s: - ipa_send_resp(x, tk, verbose) + x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8')))) else: if (verbose): print "\tBSC <- NAT: ", s