blob: 0a4ca94af6e38be44041456165a88ece4cfcd5a4 [file] [log] [blame]
ChetanGaonker3441faf2016-10-27 12:15:21 -07001#
2# Copyright 2016-present Ciena Corporation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16import unittest
17from threading import Timer
18from nose.tools import *
19from nose.twistedtools import reactor, deferred
20from twisted.internet import defer
21from scapy.all import *
22import time, monotonic
23import os, sys
24import tempfile
25import random
ChetanGaonkerfc7b0302016-11-10 08:45:56 -080026import Queue
ChetanGaonker3441faf2016-10-27 12:15:21 -070027import threading
28from IGMP import *
29from McastTraffic import *
30from Stats import Stats
31from OnosCtrl import OnosCtrl
32from OltConfig import OltConfig
33from Channels import IgmpChannel
34from EapTLS import TLSAuthTest
35from scapy_ssl_tls.ssl_tls import *
36from scapy_ssl_tls.ssl_tls_crypto import *
ChetanGaonker3441faf2016-10-27 12:15:21 -070037from EapolAAA import *
A R Karthick74d00312017-04-18 14:26:01 -070038from Enum import *
ChetanGaonker3441faf2016-10-27 12:15:21 -070039import noseTlsAuthHolder as tlsAuthHolder
40from tls_cert import Key
41from socket import *
42from CordTestServer import cord_test_radius_restart
43import struct
44import scapy
45from CordTestBase import CordTester
46from CordContainer import *
A R Karthick9313b762016-11-07 13:14:35 -080047from CordLogger import CordLogger
A R Karthick76a497a2017-04-12 10:59:39 -070048from CordTestUtils import log_test
ChetanGaonker3441faf2016-10-27 12:15:21 -070049import re
50from random import randint
51from time import sleep
ChetanGaonker3441faf2016-10-27 12:15:21 -070052import json
53from OnosFlowCtrl import OnosFlowCtrl
54from OltConfig import OltConfig
55from threading import current_thread
56import collections
A R Karthick76a497a2017-04-12 10:59:39 -070057log_test.setLevel('INFO')
ChetanGaonker3441faf2016-10-27 12:15:21 -070058
59class IGMPTestState:
60
61 def __init__(self, groups = [], df = None, state = 0):
62 self.df = df
63 self.state = state
64 self.counter = 0
65 self.groups = groups
66 self.group_map = {} ##create a send/recv count map
67 for g in groups:
68 self.group_map[g] = (Stats(), Stats())
69
70 def update(self, group, tx = 0, rx = 0, t = 0):
71 self.counter += 1
72 index = 0 if rx == 0 else 1
73 v = tx if rx == 0 else rx
74 if self.group_map.has_key(group):
75 self.group_map[group][index].update(packets = v, t = t)
76
77 def update_state(self):
78 self.state = self.state ^ 1
79
A R Karthick9313b762016-11-07 13:14:35 -080080class netCondition_exchange(CordLogger):
ChetanGaonker3441faf2016-10-27 12:15:21 -070081
82 V_INF1 = 'veth0'
83 V_INF2 = 'veth1'
84 MGROUP1 = '239.1.2.3'
85 MGROUP2 = '239.2.2.3'
86 MINVALIDGROUP1 = '255.255.255.255'
87 MINVALIDGROUP2 = '239.255.255.255'
88 MMACGROUP1 = "01:00:5e:01:02:03"
89 MMACGROUP2 = "01:00:5e:02:02:03"
90 IGMP_DST_MAC = "01:00:5e:00:00:16"
91 IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1"
92 IP_SRC = '1.2.3.4'
93 IP_DST = '224.0.0.22'
94 NEGATIVE_TRAFFIC_STATUS = 1
95 igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP)
96 igmp_ip = IP(dst = IP_DST)
97 IGMP_TEST_TIMEOUT = 5
98 IGMP_QUERY_TIMEOUT = 60
99 MCAST_TRAFFIC_TIMEOUT = 10
100 TEST_TIMEOUT_DELAY = 340
101 PORT_TX_DEFAULT = 2
102 PORT_RX_DEFAULT = 1
103 max_packets = 100
104 app_igmp = 'org.opencord.igmp'
A.R Karthick5968e0d2017-05-16 14:50:46 -0700105 olt_conf_file = os.getenv('OLT_CONFIG_FILE', os.path.join(os.path.dirname(os.path.realpath(__file__)), '../setup/olt_config.json'))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700106 ROVER_TEST_TIMEOUT = 10 #3600*86
107 ROVER_TIMEOUT = (ROVER_TEST_TIMEOUT - 100)
108 ROVER_JOIN_TIMEOUT = 60
109
110 app_tls = 'org.opencord.aaa'
111 TLS_TIMEOUT = 20
112 CLIENT_CERT_INVALID = '''-----BEGIN CERTIFICATE-----
113MIIEyTCCA7GgAwIBAgIJAM6l2jUG56pLMA0GCSqGSIb3DQEBCwUAMIGLMQswCQYD
114VQQGEwJVUzELMAkGA1UECBMCQ0ExEjAQBgNVBAcTCVNvbWV3aGVyZTETMBEGA1UE
115ChMKQ2llbmEgSW5jLjEeMBwGCSqGSIb3DQEJARYPYWRtaW5AY2llbmEuY29tMSYw
116JAYDVQQDEx1FeGFtcGxlIENlcnRpZmljYXRlIEF1dGhvcml0eTAeFw0xNjAzMTEx
117ODUzMzVaFw0xNzAzMDYxODUzMzVaMIGLMQswCQYDVQQGEwJVUzELMAkGA1UECBMC
118Q0ExEjAQBgNVBAcTCVNvbWV3aGVyZTETMBEGA1UEChMKQ2llbmEgSW5jLjEeMBwG
119CSqGSIb3DQEJARYPYWRtaW5AY2llbmEuY29tMSYwJAYDVQQDEx1FeGFtcGxlIENl
120cnRpZmljYXRlIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
121ggEBAL9Jv54TkqycL3U2Fdd/y5NXdnPVXwAVV3m6I3eIffVCv8eS+mwlbl9dnbjo
122qqlGEgA3sEg5HtnKoW81l3PSyV/YaqzUzbcpDlgWlbNkFQ3nVxh61gSU34Fc4h/W
123plSvCkwGSbV5udLtEe6S9IflP2Fu/eXa9vmUtoPqDk66p9U/nWVf2H1GJy7XanWg
124wke+HpQvbzoSfPJS0e5Rm9KErrzaIkJpqt7soW+OjVJitUax7h45RYY1HHHlbMQ0
125ndWW8UDsCxFQO6d7nsijCzY69Y8HarH4mbVtqhg3KJevxD9UMRy6gdtPMDZLah1c
126LHRu14ucOK4aF8oICOgtcD06auUCAwEAAaOCASwwggEoMB0GA1UdDgQWBBQwEs0m
127c8HARTVp21wtiwgav5biqjCBwAYDVR0jBIG4MIG1gBQwEs0mc8HARTVp21wtiwga
128v5biqqGBkaSBjjCBizELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRIwEAYDVQQH
129EwlTb21ld2hlcmUxEzARBgNVBAoTCkNpZW5hIEluYy4xHjAcBgkqhkiG9w0BCQEW
130D2FkbWluQGNpZW5hLmNvbTEmMCQGA1UEAxMdRXhhbXBsZSBDZXJ0aWZpY2F0ZSBB
131dXRob3JpdHmCCQDOpdo1BueqSzAMBgNVHRMEBTADAQH/MDYGA1UdHwQvMC0wK6Ap
132oCeGJWh0dHA6Ly93d3cuZXhhbXBsZS5jb20vZXhhbXBsZV9jYS5jcmwwDQYJKoZI
133hvcNAQELBQADggEBAK+fyAFO8CbH35P5mOX+5wf7+AeC+5pwaFcoCV0zlfwniANp
134jISgcIX9rcetLxeYRAO5com3+qLdd9dGVNL0kwufH4QhlSPErG7OLHHAs4JWVhUo
135bH3lK9lgFVlnCDBtQhslzqScR64SCicWcQEjv3ZMZsJwYLvl8unSaKz4+LVPeJ2L
136opCpmZw/V/S2NhBbe3QjTiRPmDev2gbaO4GCfi/6sCDU7UO3o8KryrkeeMIiFIej
137gfwn9fovmpeqCEyupy2JNNUTJibEuFknwx7JAX+htPL27nEgwV1FYtwI3qLiZqkM
138729wo9cFSslJNZBu+GsBP5LszQSuvNTDWytV+qY=
139-----END CERTIFICATE-----'''
140
141 def onos_aaa_config(self):
A.R Karthicka6c88fd2017-03-13 09:29:41 -0700142 aaa_dict = {'apps' : { 'org.opencord.aaa' : { 'AAA' : { 'radiusSecret': 'radius_password',
143 'radiusIp': '172.17.0.2' } } } }
ChetanGaonker3441faf2016-10-27 12:15:21 -0700144 radius_ip = os.getenv('ONOS_AAA_IP') or '172.17.0.2'
A.R Karthicka6c88fd2017-03-13 09:29:41 -0700145 aaa_dict['apps']['org.opencord.aaa']['AAA']['radiusIp'] = radius_ip
ChetanGaonker3441faf2016-10-27 12:15:21 -0700146 self.onos_ctrl.activate()
147 time.sleep(2)
148 self.onos_load_tls_config(aaa_dict)
149
150 def onos_load_tls_config(self, config):
151 status, code = OnosCtrl.config(config)
152 if status is False:
A R Karthick76a497a2017-04-12 10:59:39 -0700153 log_test.info('Configure request for AAA returned status %d' %code)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700154 assert_equal(status, True)
155 time.sleep(3)
156
157 @classmethod
158 def setUpClass(cls):
159 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
160 cls.port_map, _ = cls.olt.olt_port_map()
A R Karthick0f6b6842016-12-06 17:17:44 -0800161 OnosCtrl.cord_olt_config(cls.olt)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700162 cls.device_id = OnosCtrl.get_device_id()
163
164 @classmethod
165 def tearDownClass(cls): pass
166
167 def setUp_igmp(self):
168 ''' Activate the igmp app'''
169 apps = self.app_igmp
170 self.onos_ctrl = OnosCtrl(apps)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700171 self.onos_aaa_config()
172 self.onos_ctrl.activate()
173 self.igmp_channel = IgmpChannel()
174
175 def setUp_tls(self):
Thangavelu K Sef6f0a52016-12-14 19:57:05 +0000176 ''' Activate the aaa app'''
ChetanGaonker3441faf2016-10-27 12:15:21 -0700177 apps = self.app_tls
178 self.onos_ctrl = OnosCtrl(apps)
179 self.onos_aaa_config()
180
181 def tearDown(self):
182 '''Deactivate the dhcp app'''
183 apps = [self.app_igmp, self.app_tls]
184 for app in apps:
185 onos_ctrl = OnosCtrl(app)
186 onos_ctrl.deactivate()
ChetanGaonker3441faf2016-10-27 12:15:21 -0700187
188 def onos_load_igmp_config(self, config):
A R Karthick76a497a2017-04-12 10:59:39 -0700189 log_test.info('onos load config is %s'%config)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700190 status, code = OnosCtrl.config(config)
191 if status is False:
A R Karthick76a497a2017-04-12 10:59:39 -0700192 log_test.info('JSON request returned status %d' %code)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700193 assert_equal(status, True)
194 time.sleep(2)
195
196 def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False):
197 ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
198 ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
199 if flag: #to maintain seperate group-source pair.
200 for i in range(len(groups)):
201 d = {}
202 d['source'] = src_list[i] or '0.0.0.0'
203 d['group'] = groups[i]
204 ssm_xlate_list.append(d)
205 else:
206 for g in groups:
207 for s in src_list:
208 d = {}
209 d['source'] = s or '0.0.0.0'
210 d['group'] = g
211 ssm_xlate_list.append(d)
212 self.onos_load_igmp_config(ssm_dict)
213 cord_port_map = {}
214 for g in groups:
215 cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT)
216 self.igmp_channel.cord_port_table_load(cord_port_map)
217 time.sleep(2)
218
219 def mcast_ip_range(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
220 start = list(map(int, start_ip.split(".")))
221 end = list(map(int, end_ip.split(".")))
222 temp = start
223 ip_range = []
224 ip_range.append(start_ip)
225 while temp != end:
226 start[3] += 1
227 for i in (3, 2, 1):
228 if temp[i] == 255:
229 temp[i] = 0
230 temp[i-1] += 1
231 ip_range.append(".".join(map(str, temp)))
232 return ip_range
233
234 def random_mcast_ip(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
235 start = list(map(int, start_ip.split(".")))
236 end = list(map(int, end_ip.split(".")))
237 temp = start
238 ip_range = []
239 ip_range.append(start_ip)
240 while temp != end:
241 start[3] += 1
242 for i in (3, 2, 1):
243 if temp[i] == 255:
244 temp[i] = 0
245 temp[i-1] += 1
246 ip_range.append(".".join(map(str, temp)))
247 return random.choice(ip_range)
248
249 def source_ip_range(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
250 start = list(map(int, start_ip.split(".")))
251 end = list(map(int, end_ip.split(".")))
252 temp = start
253 ip_range = []
254 ip_range.append(start_ip)
255 while temp != end:
256 start[3] += 1
257 for i in (3, 2, 1):
258 if temp[i] == 255:
259 temp[i] = 0
260 temp[i-1] += 1
261 ip_range.append(".".join(map(str, temp)))
262 return ip_range
263
264 def randomsourceip(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
265 start = list(map(int, start_ip.split(".")))
266 end = list(map(int, end_ip.split(".")))
267 temp = start
268 ip_range = []
269 ip_range.append(start_ip)
270 while temp != end:
271 start[3] += 1
272 for i in (3, 2, 1):
273 if temp[i] == 255:
274 temp[i] = 0
275 temp[i-1] += 1
276 ip_range.append(".".join(map(str, temp)))
277 return random.choice(ip_range)
278
279 def get_igmp_intf(self):
280 inst = os.getenv('TEST_INSTANCE', None)
281 if not inst:
282 return 'veth0'
283 inst = int(inst) + 1
284 if inst >= self.port_map['uplink']:
285 inst += 1
286 if self.port_map.has_key(inst):
287 return self.port_map[inst]
288 return 'veth0'
289
290 def igmp_verify_join(self, igmpStateList):
291 sendState, recvState = igmpStateList
292 ## check if the send is received for the groups
293 for g in sendState.groups:
294 tx_stats = sendState.group_map[g][0]
295 tx = tx_stats.count
296 assert_greater(tx, 0)
297 rx_stats = recvState.group_map[g][1]
298 rx = rx_stats.count
299 assert_greater(rx, 0)
A R Karthick76a497a2017-04-12 10:59:39 -0700300 log_test.info('Receive stats %s for group %s' %(rx_stats, g))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700301
A R Karthick76a497a2017-04-12 10:59:39 -0700302 log_test.info('IGMP test verification success')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700303
304 def igmp_verify_leave(self, igmpStateList, leave_groups):
305 sendState, recvState = igmpStateList[0], igmpStateList[1]
306 ## check if the send is received for the groups
307 for g in sendState.groups:
308 tx_stats = sendState.group_map[g][0]
309 rx_stats = recvState.group_map[g][1]
310 tx = tx_stats.count
311 rx = rx_stats.count
312 assert_greater(tx, 0)
313 if g not in leave_groups:
A R Karthick76a497a2017-04-12 10:59:39 -0700314 log_test.info('Received %d packets for group %s' %(rx, g))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700315 for g in leave_groups:
316 rx = recvState.group_map[g][1].count
317 assert_equal(rx, 0)
318
A R Karthick76a497a2017-04-12 10:59:39 -0700319 log_test.info('IGMP test verification success')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700320
321 def mcast_traffic_timer(self):
322 self.mcastTraffic.stopReceives()
323
324 def send_mcast_cb(self, send_state):
325 for g in send_state.groups:
326 send_state.update(g, tx = 1)
327 return 0
328
329 ##Runs in the context of twisted reactor thread
330 def igmp_recv(self, igmpState, iface = 'veth0'):
331 p = self.recv_socket.recv()
332 try:
333 send_time = float(p.payload.load)
334 recv_time = monotonic.monotonic()
335 except:
A R Karthick76a497a2017-04-12 10:59:39 -0700336 log_test.info('Unexpected Payload received: %s' %p.payload.load)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700337 return 0
A R Karthick76a497a2017-04-12 10:59:39 -0700338 #log_test.info( 'Recv in %.6f secs' %(recv_time - send_time))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700339 igmpState.update(p.dst, rx = 1, t = recv_time - send_time)
340 return 0
341
342 def send_igmp_join(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE,
Thangavelu K Sef6f0a52016-12-14 19:57:05 +0000343 ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1, ip_src = None):
ChetanGaonker3441faf2016-10-27 12:15:21 -0700344 if ssm_load is True:
345 self.onos_ssm_table_load(groups, src_list)
346 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
347 gaddr=self.IP_DST)
348 for g in groups:
349 gr = IGMPv3gr(rtype= record_type, mcaddr=g)
350 gr.sources = src_list
351 igmp.grps.append(gr)
352 if ip_pkt is None:
Thangavelu K Sef6f0a52016-12-14 19:57:05 +0000353 if ip_src is None:
354 ip_pkt = self.igmp_eth/self.igmp_ip
355 else:
356 igmp_ip_src = IP(dst = self.IP_DST, src = ip_src)
357 ip_pkt = self.igmp_eth/igmp_ip_src
ChetanGaonker3441faf2016-10-27 12:15:21 -0700358 pkt = ip_pkt/igmp
359 IGMPv3.fixup(pkt)
360 sendp(pkt, iface=iface)
361 if delay != 0:
362 time.sleep(delay)
363
ChetanGaonkerfc7b0302016-11-10 08:45:56 -0800364
365 def send_igmp_join_negative(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE,
366 ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1, ip_src = None, invalid_igmp_join = None ):
367 if ssm_load is True:
368 self.onos_ssm_table_load(groups, src_list)
369 if invalid_igmp_join == 'igmp_type':
370 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT_NEGATIVE, max_resp_code=30,
371 gaddr=self.IP_DST)
372 else:
373 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
374 gaddr=self.IP_DST)
375 if invalid_igmp_join == 'record_type':
376 record_type = IGMP_V3_GR_TYPE_INCLUDE_NEGATIVE
377
378 for g in groups:
379 gr = IGMPv3gr(rtype= record_type, mcaddr=g)
380 gr.sources = src_list
381 igmp.grps.append(gr)
382 if ip_pkt is None:
383 if ip_src is None:
384 ip_pkt = self.igmp_eth/self.igmp_ip
385 else:
386 igmp_ip_src = IP(dst = self.IP_DST, src = ip_src)
387 ip_pkt = self.igmp_eth/igmp_ip_src
388 pkt = ip_pkt/igmp
389 if invalid_igmp_join == 'ttl':
390 set_ttl = 10
391 IGMPv3.fixup(pkt,invalid_ttl = set_ttl)
392 else:
393 IGMPv3.fixup(pkt)
394 sendp(pkt, iface=iface)
395 if delay != 0:
396 time.sleep(delay)
397
ChetanGaonker3441faf2016-10-27 12:15:21 -0700398 def send_igmp_join_recvQuery(self, groups, rec_queryCount = None, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
399 self.onos_ssm_table_load(groups, src_list)
400 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
401 gaddr=self.IP_DST)
402 for g in groups:
403 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g)
404 gr.sources = src_list
405 gr.sources = src_list
406 igmp.grps.append(gr)
407 if ip_pkt is None:
408 ip_pkt = self.igmp_eth/self.igmp_ip
409 pkt = ip_pkt/igmp
410 IGMPv3.fixup(pkt)
411 if rec_queryCount == None:
A R Karthick76a497a2017-04-12 10:59:39 -0700412 log_test.info('Sending IGMP join for group %s and waiting for one query packet and printing the packet' %groups)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700413 resp = srp1(pkt, iface=iface)
414 else:
A R Karthick76a497a2017-04-12 10:59:39 -0700415 log_test.info('Sending IGMP join for group %s and waiting for periodic query packets and printing one packet' %groups)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700416 resp = srp1(pkt, iface=iface)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700417 resp[0].summary()
A R Karthick76a497a2017-04-12 10:59:39 -0700418 log_test.info('Sent IGMP join for group %s and received a query packet and printing packet' %groups)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700419 if delay != 0:
420 time.sleep(delay)
421
422 def send_igmp_leave(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
A R Karthick76a497a2017-04-12 10:59:39 -0700423 log_test.info('entering into igmp leave function')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700424 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
425 gaddr=self.IP_DST)
426 for g in groups:
427 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
428 gr.sources = src_list
429 igmp.grps.append(gr)
430 if ip_pkt is None:
431 ip_pkt = self.igmp_eth/self.igmp_ip
432 pkt = ip_pkt/igmp
433 IGMPv3.fixup(pkt)
434 sendp(pkt, iface = iface)
435 if delay != 0:
436 time.sleep(delay)
437
438 def send_igmp_leave_listening_group_specific_query(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
439 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
440 gaddr=self.IP_DST)
441 for g in groups:
442 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
443 gr.sources = src_list
444 igmp.grps.append(gr)
445 if ip_pkt is None:
446 ip_pkt = self.igmp_eth/self.igmp_ip
447 pkt = ip_pkt/igmp
448 IGMPv3.fixup(pkt)
A R Karthick76a497a2017-04-12 10:59:39 -0700449 log_test.info('Sending IGMP leave for group %s and waiting for one group specific query packet and printing the packet' %groups)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700450 resp = srp1(pkt, iface=iface)
451 resp[0].summary()
A R Karthick76a497a2017-04-12 10:59:39 -0700452 log_test.info('Sent IGMP leave for group %s and received a group specific query packet and printing packet' %groups)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700453 if delay != 0:
454 time.sleep(delay)
455
456 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+390)
457 def test_netCondition_with_delay_between_igmp_join_and_data_recv(self):
458 self.setUp_igmp()
459 randomDelay = randint(10,300)
460 groups = ['224.0.1.1', '225.0.0.1']
461 self.onos_ssm_table_load(groups)
462 df = defer.Deferred()
463 igmpState = IGMPTestState(groups = groups, df = df)
464 igmpStateRecv = IGMPTestState(groups = groups, df = df)
465 igmpStateList = (igmpState, igmpStateRecv)
466 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, arg = igmpState)
467 self.df = df
468 self.mcastTraffic = mcastTraffic
469 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
470
471 def mcast_traffic_delay_start():
472 mcastTraffic.start()
473
474 def igmp_srp_task(stateList):
475 igmpSendState, igmpRecvState = stateList
476 if not mcastTraffic.isRecvStopped():
477 result = self.igmp_recv(igmpRecvState)
478 reactor.callLater(0, igmp_srp_task, stateList)
479 else:
480 self.mcastTraffic.stop()
481 self.recv_socket.close()
482 self.igmp_verify_join(stateList)
483 self.df.callback(0)
484
485 self.send_igmp_join(groups)
A R Karthick76a497a2017-04-12 10:59:39 -0700486 log_test.info('Holding multicast data for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700487 t = Timer(randomDelay, mcast_traffic_delay_start)
488 t.start()
489
490 self.test_timer = reactor.callLater(randomDelay+30, self.mcast_traffic_timer)
491 reactor.callLater(randomDelay+10, igmp_srp_task, igmpStateList)
492 return df
493
494 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+390)
495 def test_netCondition_with_delay_between_data_recv_and_igmp_join(self):
496 self.setUp_igmp()
497 randomDelay = randint(10,300)
498 groups = ['224.0.1.1', '225.0.0.1']
499 self.onos_ssm_table_load(groups)
500 df = defer.Deferred()
501 igmpState = IGMPTestState(groups = groups, df = df)
502 igmpStateRecv = IGMPTestState(groups = groups, df = df)
503 igmpStateList = (igmpState, igmpStateRecv)
504 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, arg = igmpState)
505 self.df = df
506 self.mcastTraffic = mcastTraffic
507 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
508
509 def mcast_join_delay_start():
A R Karthick76a497a2017-04-12 10:59:39 -0700510 log_test.info('Holding channel join for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700511 self.send_igmp_join(groups)
512
513 def igmp_srp_task(stateList):
514 igmpSendState, igmpRecvState = stateList
515 if not mcastTraffic.isRecvStopped():
516 result = self.igmp_recv(igmpRecvState)
517 reactor.callLater(0, igmp_srp_task, stateList)
518 else:
519 self.mcastTraffic.stop()
520 self.recv_socket.close()
521 self.igmp_verify_join(stateList)
522 self.df.callback(0)
523
524 mcastTraffic.start()
525 t = Timer(randomDelay, mcast_join_delay_start)
526 t.start()
527
528 self.test_timer = reactor.callLater(randomDelay+30, self.mcast_traffic_timer)
529 reactor.callLater(randomDelay+10, igmp_srp_task, igmpStateList)
530 return df
531
532
533 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+340)
534 def test_netCondition_with_delay_between_igmp_leave_and_data(self):
535 self.setUp_igmp()
536 randomDelay = randint(10,300)
537 groups = ['224.0.1.10', '225.0.0.10']
538 leave_groups = ['224.0.1.10']
539 self.onos_ssm_table_load(groups)
540 df = defer.Deferred()
541 igmpState = IGMPTestState(groups = groups, df = df)
542 igmpStateRecv = IGMPTestState(groups = groups, df = df)
543 igmpStateList = (igmpState, igmpStateRecv)
544 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
545 arg = igmpState)
546 self.df = df
547 self.mcastTraffic = mcastTraffic
548 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
549
550 def mcast_leave_delay_start():
551 self.send_igmp_leave(leave_groups, delay = 3)
552 join_state = IGMPTestState(groups = leave_groups)
553 status = self.igmp_not_recv_task(self.V_INF1,leave_groups, join_state)
A R Karthick76a497a2017-04-12 10:59:39 -0700554 log_test.info('Verified status for igmp recv task %s'%status)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700555 assert status == 1 , 'EXPECTED RESULT'
556 self.df.callback(0)
557
558 mcastTraffic.start()
559 self.send_igmp_join(groups)
A R Karthick76a497a2017-04-12 10:59:39 -0700560 log_test.info('Holding multicast leave packet for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700561 t = Timer(randomDelay+10, mcast_leave_delay_start)
562 t.start()
563 return df
564
565 def igmp_not_recv_task(self, intf, groups, join_state):
A R Karthick76a497a2017-04-12 10:59:39 -0700566 log_test.info('Entering igmp not recv task loop')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700567 recv_socket = L2Socket(iface = intf, type = ETH_P_IP)
568 group_map = {}
569 for g in groups:
570 group_map[g] = [0,0]
571
A R Karthick76a497a2017-04-12 10:59:39 -0700572 log_test.info('Verifying join interface should not receive any multicast data')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700573 self.NEGATIVE_TRAFFIC_STATUS = 1
574 def igmp_recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700575 log_test.info('Multicast packet %s received for left groups %s' %(pkt[IP].dst, groups))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700576 self.NEGATIVE_TRAFFIC_STATUS = 2
577 sniff(prn = igmp_recv_cb, count = 1, lfilter = lambda p: IP in p and p[IP].dst in groups,
578 timeout = 3, opened_socket = recv_socket)
579 recv_socket.close()
580 return self.NEGATIVE_TRAFFIC_STATUS
581
582 ## Its sample test case based on this test case we had added all below scenarios.
583 @deferred(TEST_TIMEOUT_DELAY+50)
584 def test_netCondition_in_eap_tls_with_delay_between_positive_IdReq_and_tlsHelloReq(self):
585 self.setUp_tls()
586 randomDelay = randint(10,300)
587 df = defer.Deferred()
588 tls = TLSAuthTest()
589 def eap_tls_eapTlsHelloReq_pkt_delay():
590 tls._eapTlsHelloReq()
591 tls._eapTlsCertReq()
592 tls._eapTlsChangeCipherSpec()
593 tls._eapTlsFinished()
594 df.callback(0)
595 def eap_tls_verify(df):
596 tls._eapSetup()
597 tls.tlsEventTable.EVT_EAP_SETUP
598 tls._eapStart()
599 tls.tlsEventTable.EVT_EAP_START
600 tls._eapIdReq()
601 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -0700602 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700603 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
604 t.start()
605 reactor.callLater(0, eap_tls_verify, df)
606 return df
607
608 @deferred(TEST_TIMEOUT_DELAY+50)
609 def test_netCondition_in_eap_tls_with_delay_between_IdReq_and_tlsHelloReq(self):
610 self.setUp_tls()
611 randomDelay = randint(10,300)
612 df = defer.Deferred()
613 tls = TLSAuthTest()
614 def eap_tls_eapTlsHelloReq_pkt_delay():
A R Karthick76a497a2017-04-12 10:59:39 -0700615 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700616 tls._eapTlsHelloReq()
617 tls._eapTlsCertReq()
618 tls._eapTlsChangeCipherSpec()
619 tls._eapTlsFinished()
620 df.callback(0)
621 def eap_tls_verify(df):
622 tls._eapSetup()
623 tls.tlsEventTable.EVT_EAP_SETUP
624 tls._eapStart()
625 tls.tlsEventTable.EVT_EAP_START
626 tls._eapIdReq()
627 tls.tlsEventTable.EVT_EAP_ID_REQ
628 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
629 t.start()
630 reactor.callLater(0, eap_tls_verify, df)
631 return df
632
633 @deferred(TEST_TIMEOUT_DELAY+100)
634 def test_netCondition_in_eap_tls_with_delay_between_tlsHelloReq_and_eapTlsCertReq(self):
635 self.setUp_tls()
636 randomDelay = randint(10,300)
637 df = defer.Deferred()
638 tls = TLSAuthTest()
639 def eap_tls_eapTlsCertReq_pkt_delay():
A R Karthick76a497a2017-04-12 10:59:39 -0700640 log_test.info('Holding eapTlsCertReq packet for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700641 tls._eapTlsCertReq_delay()
642 tls._eapTlsChangeCipherSpec()
643 tls._eapTlsFinished()
644 df.callback(0)
645 def eap_tls_verify(df):
646 tls._eapSetup()
647 tls.tlsEventTable.EVT_EAP_SETUP
648 tls._eapStart()
649 tls.tlsEventTable.EVT_EAP_START
650 tls._eapIdReq()
651 tls.tlsEventTable.EVT_EAP_ID_REQ
652 tls._eapTlsHelloReq()
653 while tls.server_hello_done_received == False:
654 r = tls.eapol_scapy_recv(cb = tls.eapol_server_hello_cb,
655 lfilter =
656 lambda pkt: EAP in pkt and pkt[EAP].type == EAP_TYPE_TLS and \
657 pkt[EAP].code == EAP.REQUEST)
658 if len(r) == 0:
659 tls.tlsFail()
660 t = Timer(randomDelay, eap_tls_eapTlsCertReq_pkt_delay)
661 t.start()
662 reactor.callLater(0, eap_tls_verify, df)
663 return df
664
665 @deferred(TEST_TIMEOUT_DELAY+50)
666 def test_netCondition_in_eap_tls_with_delay_between_TlsCertReq_and_TlsChangeCipherSpec(self):
667 self.setUp_tls()
668 randomDelay = randint(10,300)
669 df = defer.Deferred()
670 tls = TLSAuthTest()
671 def eap_tls_TlsChangeCipherSpec_pkt_delay():
A R Karthick76a497a2017-04-12 10:59:39 -0700672 log_test.info('Holding TlsChangeCipherSpec packet for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700673 tls._eapTlsChangeCipherSpec()
674 tls._eapTlsFinished()
675 df.callback(0)
676 def eap_tls_verify(df):
677 tls._eapSetup()
678 tls.tlsEventTable.EVT_EAP_SETUP
679 tls._eapStart()
680 tls.tlsEventTable.EVT_EAP_START
681 tls._eapIdReq()
682 tls.tlsEventTable.EVT_EAP_ID_REQ
683 tls._eapTlsHelloReq()
684 tls._eapTlsCertReq()
685 t = Timer(randomDelay, eap_tls_TlsChangeCipherSpec_pkt_delay)
686 t.start()
687 reactor.callLater(0, eap_tls_verify, df)
688 return df
689
690 @deferred(TEST_TIMEOUT_DELAY+50)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -0800691 def test_netCondition_in_eap_tls_with_no_cert_and_delay_between_IdReq_and_HelloReq(self):
ChetanGaonker3441faf2016-10-27 12:15:21 -0700692 self.setUp_tls()
693 randomDelay = randint(10,300)
694 df = defer.Deferred()
695 def tls_no_cert_cb():
A R Karthick76a497a2017-04-12 10:59:39 -0700696 log_test.info('TLS authentication failed with no certificate')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700697 tls = TLSAuthTest(fail_cb = tls_no_cert_cb, client_cert = '')
698 def eap_tls_eapTlsHelloReq_pkt_delay():
A R Karthick76a497a2017-04-12 10:59:39 -0700699 log_test.info('Holding HelloReq packet with no cert for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700700 tls._eapTlsHelloReq()
701 tls._eapTlsCertReq()
702 assert_equal(tls.failTest, True)
703 tls._eapTlsChangeCipherSpec()
704 tls._eapTlsFinished()
705 df.callback(0)
706 def eap_tls_no_cert(df):
707 tls._eapSetup()
708 tls.tlsEventTable.EVT_EAP_SETUP
709 tls._eapStart()
710 tls.tlsEventTable.EVT_EAP_START
711 tls._eapIdReq()
712 tls.tlsEventTable.EVT_EAP_ID_REQ
713 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
714 t.start()
715 reactor.callLater(0, eap_tls_no_cert, df)
716 return df
717
718 @deferred(TEST_TIMEOUT_DELAY+100)
719 def test_netCondition_in_eap_tls_with_delay_and_no_cert_between_tlsHelloReq_and_eapTlsCertReq(self):
720 self.setUp_tls()
721 randomDelay = randint(10,300)
722 df = defer.Deferred()
723 def tls_no_cert_cb():
A R Karthick76a497a2017-04-12 10:59:39 -0700724 log_test.info('TLS authentication failed with no certificate')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700725 tls = TLSAuthTest(fail_cb = tls_no_cert_cb, client_cert = '')
726 def eap_tls_eapTlsHelloReq_pkt_delay():
A R Karthick76a497a2017-04-12 10:59:39 -0700727 log_test.info('Holding eapTlsCertReq packet with no cert for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700728 tls._eapTlsCertReq_delay()
729 assert_equal(tls.failTest, True)
730 tls._eapTlsChangeCipherSpec()
731 assert_equal(tls.failTest, True)
732 tls._eapTlsFinished()
733 df.callback(0)
734 def eap_tls_no_cert(df):
735 tls._eapSetup()
736 tls.tlsEventTable.EVT_EAP_SETUP
737 tls._eapStart()
738 tls.tlsEventTable.EVT_EAP_START
739 tls._eapIdReq()
740 tls.tlsEventTable.EVT_EAP_ID_REQ
741 tls._eapTlsHelloReq()
742 while tls.server_hello_done_received == False:
743 r = tls.eapol_scapy_recv(cb = tls.eapol_server_hello_cb,
744 lfilter =
745 lambda pkt: EAP in pkt and pkt[EAP].type == EAP_TYPE_TLS and \
746 pkt[EAP].code == EAP.REQUEST)
747 if len(r) == 0:
748 tls.tlsFail()
749 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
750 t.start()
751 reactor.callLater(0, eap_tls_no_cert, df)
752 return df
753
754
755 @deferred(TEST_TIMEOUT_DELAY+50)
756 def test_netCondition_in_eap_tls_with_delay_and_no_cert_between_TlsCertReq_and_TlsChangeCipherSpec(self):
757 self.setUp_tls()
758 randomDelay = randint(10,300)
759 df = defer.Deferred()
760 def tls_no_cert_cb():
A R Karthick76a497a2017-04-12 10:59:39 -0700761 log_test.info('TLS authentication failed with no certificate')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700762 tls = TLSAuthTest(fail_cb = tls_no_cert_cb, client_cert = '')
763 def eap_tls_TlsChangeCipherSpec_pkt_delay():
764 tls._eapTlsChangeCipherSpec()
765 assert_equal(tls.failTest, True)
766 tls._eapTlsFinished()
767 df.callback(0)
768 def eap_tls_no_cert(df):
769 tls._eapSetup()
770 tls.tlsEventTable.EVT_EAP_SETUP
771 tls._eapStart()
772 tls._eapIdReq()
773 tls.tlsEventTable.EVT_EAP_ID_REQ
774 tls._eapTlsHelloReq()
775 tls._eapTlsCertReq()
A R Karthick76a497a2017-04-12 10:59:39 -0700776 log_test.info('Holding TlsChangeCipherSpec packet with no cert for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700777 t = Timer(randomDelay, eap_tls_TlsChangeCipherSpec_pkt_delay)
778 t.start()
779 reactor.callLater(0, eap_tls_no_cert, df)
780 return df
781
782 @deferred(TEST_TIMEOUT_DELAY+50)
783 def test_netCondition_in_eap_tls_with_invalid_cert_and_delay_between_IdReq_and_HelloReq(self):
784 self.setUp_tls()
785 randomDelay = randint(10,300)
786 df = defer.Deferred()
787 def tls_invalid_cert_cb():
A R Karthick76a497a2017-04-12 10:59:39 -0700788 log_test.info('TLS authentication failed with invalid certificate')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700789 tls = TLSAuthTest(fail_cb = tls_invalid_cert_cb, client_cert = self.CLIENT_CERT_INVALID)
790 def eap_tls_eapTlsHelloReq_pkt_delay():
791 tls._eapTlsHelloReq()
792 tls._eapTlsCertReq()
793 assert_equal(tls.failTest, True)
794 tls._eapTlsChangeCipherSpec()
795 tls._eapTlsFinished()
796 df.callback(0)
797 def eap_tls_invalid_cert(df):
798 tls._eapSetup()
799 tls.tlsEventTable.EVT_EAP_SETUP
800 tls._eapStart()
801 tls.tlsEventTable.EVT_EAP_START
802 tls._eapIdReq()
803 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -0700804 log_test.info('Holding HelloReq packet with invalid cert for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700805 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
806 t.start()
807 reactor.callLater(0, eap_tls_invalid_cert, df)
808 return df
809
810 @deferred(TEST_TIMEOUT_DELAY+100)
811 def test_netCondition_in_eap_tls_with_invalid_cert_and_delay_between_tlsHelloReq_and_eapTlsCertReq(self):
812 self.setUp_tls()
813 randomDelay = randint(10,300)
814 df = defer.Deferred()
815 def tls_invalid_cert_cb():
A R Karthick76a497a2017-04-12 10:59:39 -0700816 log_test.info('TLS authentication failed with invalid certificate')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700817 tls = TLSAuthTest(fail_cb = tls_invalid_cert_cb, client_cert = self.CLIENT_CERT_INVALID)
818 def eap_tls_eapTlsHelloReq_pkt_delay():
A R Karthick76a497a2017-04-12 10:59:39 -0700819 log_test.info('Holding eapTlsCertReq packet with invalid cert for a period of random delay = {} sec, delay'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700820 tls._eapTlsCertReq_delay()
821 tls._eapTlsChangeCipherSpec()
822 assert_equal(tls.failTest, True)
823 tls._eapTlsFinished()
824 df.callback(0)
825 def eap_tls_invalid_cert(df):
826 tls._eapSetup()
827 tls.tlsEventTable.EVT_EAP_SETUP
828 tls._eapStart()
829 tls.tlsEventTable.EVT_EAP_START
830 tls._eapIdReq()
831 tls.tlsEventTable.EVT_EAP_ID_REQ
832 tls._eapTlsHelloReq()
833 while tls.server_hello_done_received == False:
834 r = tls.eapol_scapy_recv(cb = tls.eapol_server_hello_cb,
835 lfilter =
836 lambda pkt: EAP in pkt and pkt[EAP].type == EAP_TYPE_TLS and \
837 pkt[EAP].code == EAP.REQUEST)
838 if len(r) == 0:
839 tls.tlsFail()
840
A R Karthick76a497a2017-04-12 10:59:39 -0700841 log_test.info('Holding eapTlsCertReq packet with invalid cert for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700842 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
843 t.start()
844 reactor.callLater(0, eap_tls_invalid_cert, df)
845 return df
846
847
848 @deferred(TEST_TIMEOUT_DELAY+50)
849 def test_netCondition_in_eap_tls_with_invalid_cert_delay_between_TlsCertReq_and_TlsChangeCipherSpec(self):
850 self.setUp_tls()
851 randomDelay = randint(10,300)
852 df = defer.Deferred()
853 def tls_invalid_cert_cb():
A R Karthick76a497a2017-04-12 10:59:39 -0700854 log_test.info('TLS authentication failed with invalid certificate')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700855 tls = TLSAuthTest(fail_cb = tls_invalid_cert_cb, client_cert = self.CLIENT_CERT_INVALID)
856 def eap_tls_TlsChangeCipherSpec_pkt_delay():
857 tls._eapTlsChangeCipherSpec()
858 assert_equal(tls.failTest, True)
859 tls._eapTlsFinished()
860 df.callback(0)
861 def eap_tls_invalid_cert(df):
862 tls._eapSetup()
863 tls.tlsEventTable.EVT_EAP_SETUP
864 tls._eapStart()
865 tls.tlsEventTable.EVT_EAP_START
866 tls._eapIdReq()
867 tls.tlsEventTable.EVT_EAP_ID_REQ
868 tls._eapTlsHelloReq()
869 tls._eapTlsCertReq()
A R Karthick76a497a2017-04-12 10:59:39 -0700870 log_test.info('Holding TlsChangeCipherSpec packet with invalid cert for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700871 t = Timer(randomDelay, eap_tls_TlsChangeCipherSpec_pkt_delay)
872 t.start()
873 reactor.callLater(0, eap_tls_invalid_cert, df)
874 return df
875
876 @deferred(TEST_TIMEOUT_DELAY+50)
877 def test_netCondition_in_multiple_eap_tls_requests_with_delay_between_IdReq_and_HelloReq(self):
878 self.setUp_tls()
879 df = defer.Deferred()
880 threads = []
881 clients = 10
882 def eap_tls_eapTlsHelloReq_pkt_delay(df):
883 def multiple_tls_random_delay():
884 randomDelay = randint(10,300)
885 tls = TLSAuthTest(src_mac = 'random')
886 tls._eapSetup()
887 tls.tlsEventTable.EVT_EAP_SETUP
888 tls._eapStart()
889 tls.tlsEventTable.EVT_EAP_START
890 tls._eapIdReq()
891 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -0700892 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700893 time.sleep(randomDelay)
894 tls._eapTlsHelloReq()
895 tls._eapTlsCertReq()
896 tls._eapTlsChangeCipherSpec()
897 tls._eapTlsFinished()
A R Karthick76a497a2017-04-12 10:59:39 -0700898 log_test.info('Authentication successful for user %d'%i)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700899 # Sending multiple tls clients and making random delay in between client and server packets.
900 for i in xrange(clients):
901 thread = threading.Thread(target = multiple_tls_random_delay)
902 time.sleep(randint(1,2))
903 thread.start()
904 threads.append(thread)
905 time.sleep(300)
906 for thread in threads:
907 thread.join()
ChetanGaonker3441faf2016-10-27 12:15:21 -0700908 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
909 return df
910
911 @deferred(TEST_TIMEOUT_DELAY+450)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -0800912 def test_netCondition_with_multiple_authentication_and_delay_between_complete_authentication(self):
ChetanGaonker3441faf2016-10-27 12:15:21 -0700913 self.setUp_tls()
914 df = defer.Deferred()
915 threads = []
916 clients = 100
917 def eap_tls_eapTlsHelloReq_pkt_delay(df):
918 def multiple_tls_random_delay():
919 randomDelay = randint(10,300)
920 tls = TLSAuthTest(src_mac = 'random')
921 tls._eapSetup()
922 tls.tlsEventTable.EVT_EAP_SETUP
923 tls._eapStart()
924 tls.tlsEventTable.EVT_EAP_START
925 tls._eapIdReq()
926 tls.tlsEventTable.EVT_EAP_ID_REQ
927 tls._eapTlsHelloReq()
928 tls._eapTlsCertReq()
929 tls._eapTlsChangeCipherSpec()
930 tls._eapTlsFinished()
A R Karthick76a497a2017-04-12 10:59:39 -0700931 log_test.info('Authentication successful for user %d'%i)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700932 # Client authendicating multiple times one after other and making random delay in between authendication.
933 for i in xrange(clients):
ChetanGaonker3441faf2016-10-27 12:15:21 -0700934 multiple_tls_random_delay()
935 time.sleep(randomDelay)
936 df.callback(0)
937 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
938 return df
939
940 @deferred(TEST_TIMEOUT_DELAY+450)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -0800941 def test_netCondition_with_multiple_authentication_and_delay_between_every_100_tls_burst(self):
ChetanGaonker3441faf2016-10-27 12:15:21 -0700942 self.setUp_tls()
943 randomDelay = randint(10,300)
944 df = defer.Deferred()
945 threads = []
946 tls = []
947 clients = 10
948 def eap_tls_eapTlsHelloReq_pkt_delay(df):
949 def multiple_tls_random_delay():
ChetanGaonker3441faf2016-10-27 12:15:21 -0700950 for x in xrange(clients):
951 tls.append(TLSAuthTest(src_mac = 'random'))
952 for x in xrange(clients):
953 tls[x]._eapSetup()
954 tls[x].tlsEventTable.EVT_EAP_SETUP
955 for x in xrange(clients):
956 tls[x]._eapStart()
957 tls[x].tlsEventTable.EVT_EAP_START
958 for x in xrange(clients):
959 tls[x]._eapIdReq()
960 tls[x].tlsEventTable.EVT_EAP_ID_REQ
961 for x in xrange(clients):
962 tls[x]._eapTlsHelloReq()
963 for x in xrange(clients):
964 tls[x]._eapTlsCertReq()
965 for x in xrange(clients):
966 tls[x]._eapTlsChangeCipherSpec()
967 for x in xrange(clients):
968 tls[x]._eapTlsFinished()
969 for x in xrange(clients):
A R Karthick76a497a2017-04-12 10:59:39 -0700970 log_test.info('Authentication successful for user %d'%i)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700971 # Client authendicating multiple times one after other and making random delay in between authendication.
972 for i in xrange(2):
973 multiple_tls_random_delay()
974 time.sleep(randomDelay)
975 df.callback(0)
976 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
977 return df
978
979 @deferred(TEST_TIMEOUT_DELAY+90)
980 def test_netCondition_with_delay_between_mac_flow_and_traffic(self):
981 df = defer.Deferred()
982 randomDelay = randint(10,300)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700983 egress = 1
984 ingress = 2
985 egress_mac = '00:00:00:00:00:01'
986 ingress_mac = '00:00:00:00:00:02'
987 pkt = Ether(src = ingress_mac, dst = egress_mac)/IP()
988 self.success = False
989
990 def mac_recv_task():
991 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700992 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700993 self.success = True
994 sniff(count=2, timeout=randomDelay+50, lfilter = lambda p: p.src == ingress_mac,
995 prn = recv_cb, iface = self.port_map[egress])
996
997 thread = threading.Thread(target = mac_recv_task)
998
999 def send_flow_pkt_delay():
1000 sendp(pkt, count=50, iface = self.port_map[ingress])
1001 thread.join()
1002 assert_equal(self.success, True)
1003 df.callback(0)
1004
1005 def creating_mac_flow(df):
1006
1007 flow = OnosFlowCtrl(deviceId = self.device_id,
1008 egressPort = egress,
1009 ingressPort = ingress,
1010 ethSrc = ingress_mac,
1011 ethDst = egress_mac)
1012 result = flow.addFlow()
1013 assert_equal(result, True)
1014 ##wait for flows to be added to ONOS
1015 time.sleep(1)
1016 thread.start()
A R Karthick76a497a2017-04-12 10:59:39 -07001017 log_test.info('Holding a packet to verify if flows are active after {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -07001018 t = Timer(randomDelay, send_flow_pkt_delay)
1019 t.start()
1020 reactor.callLater(0, creating_mac_flow, df)
1021 return df
1022
1023
1024 @deferred(TEST_TIMEOUT_DELAY+90)
1025 def test_netCondition_with_delay_between_ip_flow_and_traffic(self):
1026 df = defer.Deferred()
1027 randomDelay = randint(10,300)
1028 egress = 1
1029 ingress = 2
1030 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
1031 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
1032 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
1033 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
1034 pkt = L2/L3
1035
1036 def mac_recv_task():
1037 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001038 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
ChetanGaonker3441faf2016-10-27 12:15:21 -07001039 self.success = True
1040 sniff(count=2, timeout= randomDelay + 30,
1041 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip'],
1042 prn = recv_cb, iface = self.port_map[egress])
1043
1044 thread = threading.Thread(target = mac_recv_task)
1045
1046 def send_flow_ip_pkt_delay():
1047 sendp(pkt, count=50, iface = self.port_map[ingress])
1048 thread.join()
1049 assert_equal(self.success, True)
1050 df.callback(0)
1051
1052 def creating_ip_flow(df):
1053 flow = OnosFlowCtrl(deviceId = self.device_id,
1054 egressPort = egress,
1055 ingressPort = ingress,
1056 ethType = '0x0800',
1057 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/32'),
1058 ipDst = ('IPV4_DST', egress_map['ip']+'/32')
1059 )
1060 result = flow.addFlow()
1061 assert_equal(result, True)
1062 ##wait for flows to be added to ONOS
1063 time.sleep(1)
1064 self.success = False
1065 ##wait for flows to be added to ONOS
1066 time.sleep(1)
1067 thread.start()
A R Karthick76a497a2017-04-12 10:59:39 -07001068 log_test.info('Holding a packet to verify if flows are active after {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -07001069 t = Timer(randomDelay, send_flow_ip_pkt_delay)
1070 t.start()
1071 reactor.callLater(0, creating_ip_flow, df)
1072 return df
1073
1074 @deferred(TEST_TIMEOUT_DELAY+90)
1075 def test_netCondition_with_delay_between_tcp_port_flow_and_traffic(self):
1076 df = defer.Deferred()
1077 egress = 1
1078 ingress = 2
1079 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 9500 }
1080 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 9000 }
1081 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
1082 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
1083 L4 = TCP(sport = ingress_map['tcp_port'], dport = egress_map['tcp_port'])
1084 pkt = L2/L3/L4
1085
1086 def mac_recv_task():
1087 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001088 log_test.info('Pkt seen with ingress TCP port %s, egress TCP port %s' %(pkt[TCP].sport, pkt[TCP].dport))
ChetanGaonker3441faf2016-10-27 12:15:21 -07001089 self.success = True
1090 sniff(count=2, timeout= randomDelay+30, lfilter = lambda p: TCP in p and p[TCP].dport == egress_map['tcp_port']
1091 and p[TCP].sport == ingress_map['tcp_port'], prn = recv_cb, iface = self.port_map[egress])
1092
1093 thread = threading.Thread(target = mac_recv_task)
1094
1095 def send_flow_tcp_pkt_delay():
1096 sendp(pkt, count=50, iface = self.port_map[ingress])
1097 thread.join()
1098 assert_equal(self.success, True)
ChetanGaonker3441faf2016-10-27 12:15:21 -07001099
1100 def creating_tcp_flow(df):
1101 flow = OnosFlowCtrl(deviceId = self.device_id,
1102 egressPort = egress,
1103 ingressPort = ingress,
1104 tcpSrc = ingress_map['tcp_port'],
1105 tcpDst = egress_map['tcp_port']
1106 )
1107 result = flow.addFlow()
1108 assert_equal(result, True)
1109 ##wait for flows to be added to ONOS
1110 time.sleep(1)
1111 self.success = False
1112 thread.start()
A R Karthick76a497a2017-04-12 10:59:39 -07001113 log_test.info('Holding a packet to verify if flows are active after {} sec, delay'.format(randomDelay))
ChetanGaonker12f9f422016-11-10 23:21:21 -08001114 t = Timer(randomDelay, send_flow_tcp_pkt_delay)
ChetanGaonker3441faf2016-10-27 12:15:21 -07001115 t.start()
1116 df.callback(0)
1117 reactor.callLater(0, creating_tcp_flow, df)
1118 return df
1119
1120 @deferred(TEST_TIMEOUT_DELAY+90)
1121 def test_netCondition_with_delay_between_udp_port_flow_and_traffic(self):
1122 df = defer.Deferred()
1123 randomDelay = randint(10,300)
1124 egress = 1
1125 ingress = 2
1126 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 9500 }
1127 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 9000 }
1128 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
1129 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
1130 L4 = UDP(sport = ingress_map['udp_port'], dport = egress_map['udp_port'])
1131 pkt = L2/L3/L4
1132
1133 def mac_recv_task():
1134 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001135 log_test.info('Pkt seen with ingress UDP port %s, egress UDP port %s' %(pkt[UDP].sport, pkt[UDP].dport))
ChetanGaonker3441faf2016-10-27 12:15:21 -07001136 self.success = True
1137 sniff(count=2, timeout=randomDelay + 30,
1138 lfilter = lambda p: UDP in p and p[UDP].dport == egress_map['udp_port']
1139 and p[UDP].sport == ingress_map['udp_port'], prn = recv_cb, iface = self.port_map[egress])
1140
1141 thread = threading.Thread(target = mac_recv_task)
1142
1143 def send_flow_udp_pkt_delay():
1144 sendp(pkt, count=50, iface = self.port_map[ingress])
1145 thread.join()
1146 assert_equal(self.success, True)
1147 df.callback(0)
1148
1149 def creating_udp_flow(df):
1150 flow = OnosFlowCtrl(deviceId = self.device_id,
1151 egressPort = egress,
1152 ingressPort = ingress,
1153 udpSrc = ingress_map['udp_port'],
1154 udpDst = egress_map['udp_port']
1155 )
1156 result = flow.addFlow()
1157 assert_equal(result, True)
1158 ##wait for flows to be added to ONOS
1159 time.sleep(1)
1160 self.success = False
1161 thread.start()
A R Karthick76a497a2017-04-12 10:59:39 -07001162 log_test.info('Holding a packet to verify if flows are active after {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -07001163 t = Timer(randomDelay, send_flow_udp_pkt_delay)
1164 t.start()
1165
1166 df.callback(0)
1167 reactor.callLater(0, creating_udp_flow, df)
1168 return df
1169
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001170 def netCondition_with_delay_between_multiple_igmp_joins_and_data(self,users,group_end_ip,source_list_end_ip,user_src_end_ip, data_pkt =50):
1171 self.setUp_igmp()
ChetanGaonker12f9f422016-11-10 23:21:21 -08001172 randomDelay = []
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001173 groups = []
1174 sources = []
1175 subscribers_src_ip = []
1176 status = []
1177 join_threads = []
1178 delay_threads = []
1179 data_threads = []
1180 threads = []
1181 subscriber = users
1182 count = 1
1183 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = group_end_ip)
1184 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = source_list_end_ip)
1185 subscriber_sourceips = self.source_ip_range(start_ip = '20.20.0.1',end_ip = user_src_end_ip)
1186 while count<=subscriber:
1187 group = random.choice(mcastips)
1188 source = random.choice(sourceips)
1189 subscriber_sourceip = random.choice(subscriber_sourceips)
1190 if group in groups:
1191 pass
1192 else:
A R Karthick76a497a2017-04-12 10:59:39 -07001193 log_test.info('group = %s source list = %s and subscriber source ip in join = %s'%(group,source, subscriber_sourceip))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001194 groups.append(group)
1195 sources.append(source)
1196 subscribers_src_ip.append(subscriber_sourceip)
1197 count += 1
1198 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1199
1200 def multiple_joins_send_in_threads(group, source, subscriber_src_ip,data_pkt = data_pkt):
1201 self.send_igmp_join(groups = [group], src_list = [source],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1202 iface = self.V_INF1, ip_src = [subscriber_src_ip])
ChetanGaonker12f9f422016-11-10 23:21:21 -08001203 randomDelay_in_thread = randint(10,30)
A R Karthick76a497a2017-04-12 10:59:39 -07001204 log_test.info('This is running in a thread, with igmp join sent and delay {}'.format(randomDelay_in_thread))
ChetanGaonker12f9f422016-11-10 23:21:21 -08001205 time.sleep(randomDelay_in_thread)
A R Karthick76a497a2017-04-12 10:59:39 -07001206 log_test.info('This is running in a thread, with igmp join sent and delay {}'.format(randomDelay_in_thread))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001207 status = self.verify_igmp_data_traffic_in_thread(group,intf=self.V_INF1,source=source, data_pkt = data_pkt)
A R Karthick76a497a2017-04-12 10:59:39 -07001208 log_test.info('Data received for group %s from source %s and status is %s '%(group,source,status))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001209 self.igmp_threads_result.append(status)
1210
1211 for i in range(subscriber):
1212 thread = threading.Thread(target = multiple_joins_send_in_threads, args = (groups[i], sources[i], subscribers_src_ip[i]))
1213 time.sleep(randint(1,2))
1214 thread.start()
1215 threads.append(thread)
1216
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001217 for thread in threads:
1218 thread.join()
1219
1220 def verify_igmp_data_traffic_in_thread(self, group, intf='veth0', source='1.2.3.4', data_pkt =50, negative = None):
A R Karthick76a497a2017-04-12 10:59:39 -07001221 log_test.info('Verifying multicast traffic for group %s from source %s'%(group,source))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001222 self.success = False
1223 def recv_task():
1224 def igmp_recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001225 #log_test.info('received multicast data packet is %s'%pkt.show())
1226 log_test.info('Multicast data received for group %s from source %s'%(group,source))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001227 self.success = True
1228 sniff(prn = igmp_recv_cb,lfilter = lambda p: IP in p and p[IP].dst == group and p[IP].src == source, count=1,timeout = 2, iface='veth0')
1229 t = threading.Thread(target = recv_task)
1230 t.start()
1231 self.send_multicast_data_traffic_from_thread(group,source=source, data_pkt=data_pkt)
1232 t.join()
1233 if (negative is None) and self.success is True:
1234 return self.success
1235 elif (negative is not None) and self.success is True:
A R Karthick76a497a2017-04-12 10:59:39 -07001236 log_test.info('Multicast traffic should not received because this is negative scenario, but it is received')
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001237 self.success = False
1238 elif (negative is not None) and self.success is False:
A R Karthick76a497a2017-04-12 10:59:39 -07001239 log_test.info('Multicast traffic should is not received because this is negative scenario, hence status is True')
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001240 self.success = True
1241 return self.success
1242
1243 def send_multicast_data_traffic_from_thread(self, group, intf= 'veth2',source = '1.2.3.4', data_pkt = 50):
1244 dst_mac = self.iptomac_convert(group)
1245 eth = Ether(dst= dst_mac)
1246 ip = IP(dst=group,src=source)
1247 data = repr(monotonic.monotonic())
A R Karthick76a497a2017-04-12 10:59:39 -07001248 log_test.info('Sending %s number of multicast packet to the multicast group %s'%(data_pkt, group))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001249 sendp(eth/ip/data,count=data_pkt, iface = intf)
1250 pkt = (eth/ip/data)
A R Karthick76a497a2017-04-12 10:59:39 -07001251 #log_test.info('multicast traffic packet %s'%pkt.show())
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001252
1253 def iptomac_convert(self, mcast_ip):
1254 mcast_mac = '01:00:5e:'
1255 octets = mcast_ip.split('.')
1256 second_oct = int(octets[1]) & 127
1257 third_oct = int(octets[2])
1258 fourth_oct = int(octets[3])
1259 mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x')
1260 return mcast_mac
1261
1262 @deferred(TEST_TIMEOUT_DELAY+50)
1263 def test_netCondition_with_delay_between_multiple_igmp_joins_and_data_for_multiple_subscribers(self):
1264 self.setUp_tls()
1265 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001266 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001267 def netCondition_multiple_igmp_joins_and_data(df):
1268 ### Start ips of multicast, source list and subscriber source ip are '229.0.0.1', '10.10.0.1' and '20.20.0.1' respectively
1269 no_users = 10
1270 group_end_ip = '229.0.30.254'
1271 source_list_end_ip = '10.10.30.254'
1272 subscriber_src_end_ip = '20.20.20.254'
1273 self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip,
1274 source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip )
A R Karthick76a497a2017-04-12 10:59:39 -07001275 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001276 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001277 log_test.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i]))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001278 if assert_equal(self.igmp_threads_result[i], True) is True:
1279 df.callback(0)
1280 df.callback(0)
1281 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1282 return df
1283
1284 @deferred(TEST_TIMEOUT_DELAY+50)
1285 def test_netCondition_with_delay_between_multiple_igmp_joins_and_data_from_multiple_subscribers_with_low_multicast_data_rate(self):
1286 self.setUp_tls()
1287 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001288 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001289 def netCondition_multiple_igmp_joins_and_data(df):
1290 ### Start ips of multicast, source list and subscriber source ip are '229.0.0.1', '10.10.0.1' and '20.20.0.1' respectively
1291 no_users = 10
1292 group_end_ip = '229.0.30.254'
1293 source_list_end_ip = '10.10.30.254'
1294 subscriber_src_end_ip = '20.20.20.254'
1295 self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip,
1296 source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip, data_pkt = 20)
A R Karthick76a497a2017-04-12 10:59:39 -07001297 log_test.info('IGMP Thread status after running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001298 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001299 log_test.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i]))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001300 if assert_equal(self.igmp_threads_result[i], True) is True:
1301 df.callback(0)
1302 df.callback(0)
1303 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1304 return df
1305
1306 @deferred(TEST_TIMEOUT_DELAY+50)
1307 def test_netCondition_with_delay_between_multiple_igmp_joins_and_data_for_same_subscriber(self):
1308 self.setUp_tls()
1309 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001310 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001311 def netCondition_multiple_igmp_joins_and_data(df):
1312 ### Start ips of multicast, source list and subscriber source ip are '229.0.0.1', '10.10.0.1' and '20.20.0.1' respectively
1313 no_users = 5
1314 group_end_ip = '229.0.30.254'
1315 source_list_end_ip = '10.10.30.254'
1316 subscriber_src_end_ip = '20.20.0.1'
1317 self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip,
1318 source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip )
A R Karthick76a497a2017-04-12 10:59:39 -07001319 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001320 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001321 log_test.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i]))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001322 if assert_equal(self.igmp_threads_result[i], True) is True:
1323 df.callback(0)
1324 df.callback(0)
1325 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1326 return df
1327
1328
1329 @deferred(TEST_TIMEOUT_DELAY+50)
1330 def test_netCondition_with_delay_between_same_igmp_joins_and_data_from_multiple_subscriber(self):
1331 self.setUp_tls()
1332 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001333 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001334 def netCondition_multiple_igmp_joins_and_data(df):
1335 ### Start ips of multicast, source list and subscriber source ip are '229.0.0.1', '10.10.0.1' and '20.20.0.1' respectively
1336 no_users = 100
1337 group_end_ip = '229.0.0.1'
1338 source_list_end_ip = '10.10.30.254'
1339 subscriber_src_end_ip = '20.20.20.254'
1340 self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip,
1341 source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip )
A R Karthick76a497a2017-04-12 10:59:39 -07001342 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001343 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001344 log_test.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i]))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001345 if assert_equal(self.igmp_threads_result[i], True) is True:
1346 df.callback(0)
1347 df.callback(0)
1348 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1349 return df
1350
1351 @deferred(TEST_TIMEOUT_DELAY+50)
1352 def test_netCondition_with_delay_between_multiple_igmp_joins_and_data_from_same_sourcelist_for_multiple_subscriber(self):
1353 self.setUp_tls()
1354 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001355 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001356 def netCondition_multiple_igmp_joins_and_data(df):
1357 ### Start ips of multicast, source list and subscriber source ip are '229.0.0.1', '10.10.0.1' and '20.20.0.1' respectively
1358 no_users = 20
1359 group_end_ip = '229.0.30.254'
1360 source_list_end_ip = '10.10.0.1'
1361 subscriber_src_end_ip = '20.20.20.254'
1362 self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip,
1363 source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip )
A R Karthick76a497a2017-04-12 10:59:39 -07001364 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001365 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001366 log_test.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i]))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001367 if assert_equal(self.igmp_threads_result[i], True) is True:
1368 df.callback(0)
1369 df.callback(0)
1370 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1371 return df
1372
1373
1374 def netCondition_with_multiple_scenarios_igmp_joins_and_data(self,users,group_end_ip,source_list_end_ip,user_src_end_ip,bunch_traffic, data_pkt =50,invalid_joins = None):
1375 self.setUp_igmp()
ChetanGaonker12f9f422016-11-10 23:21:21 -08001376 randomDelay = []
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001377 groups = []
1378 sources = []
1379 subscribers_src_ip = []
1380 status = []
1381 join_threads = []
1382 delay_threads = []
1383 data_threads = []
1384 threads = []
1385 subscriber = users
1386 count = 1
1387 j = 1
1388 negative_traffic = None
1389 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = group_end_ip)
1390 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = source_list_end_ip)
1391 subscriber_sourceips = self.source_ip_range(start_ip = '20.20.0.1',end_ip = user_src_end_ip)
1392 while count<=subscriber:
1393 group = random.choice(mcastips)
1394 source = random.choice(sourceips)
1395 subscriber_sourceip = random.choice(subscriber_sourceips)
1396 if group in groups:
1397 pass
1398 else:
A R Karthick76a497a2017-04-12 10:59:39 -07001399 log_test.info('group = %s source list = %s and subscriber source ip in join = %s'%(group,source, subscriber_sourceip))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001400 groups.append(group)
1401 sources.append(source)
1402 subscribers_src_ip.append(subscriber_sourceip)
1403 count += 1
1404 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001405 def multiple_joins_send_in_threads(group, source, subscriber_src_ip,invalid_igmp_join,data_pkt = data_pkt):
1406 if invalid_igmp_join is None:
1407 self.send_igmp_join(groups = [group], src_list = [source],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1408 iface = self.V_INF1, ip_src = [subscriber_src_ip])
1409 else:
1410 negative_traffic = True
1411 self.send_igmp_join_negative(groups = [group], src_list = [source],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1412 iface = self.V_INF1, ip_src = [subscriber_src_ip], invalid_igmp_join = invalid_igmp_join)
ChetanGaonker12f9f422016-11-10 23:21:21 -08001413 randomDelay_in_thread = randint(10,30)
A R Karthick76a497a2017-04-12 10:59:39 -07001414 log_test.info('This is running in thread with igmp join sent and delay {}'.format(randomDelay_in_thread))
ChetanGaonker12f9f422016-11-10 23:21:21 -08001415 time.sleep(randomDelay_in_thread)
A R Karthick76a497a2017-04-12 10:59:39 -07001416 log_test.info('This is running in thread with igmp join sent and delay {}'.format(randomDelay_in_thread))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001417 status = self.verify_igmp_data_traffic_in_thread(group,intf=self.V_INF1,source=source, data_pkt = data_pkt,negative=negative_traffic)
A R Karthick76a497a2017-04-12 10:59:39 -07001418 log_test.info('data received for group %s from source %s and status is %s '%(group,source,status))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001419 self.igmp_threads_result.append(status)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001420 for i in range(subscriber):
1421 thread = threading.Thread(target = multiple_joins_send_in_threads, args = (groups[i], sources[i], subscribers_src_ip[i], invalid_joins))
1422 if bunch_traffic == 'yes':
1423 if j == 10:
A R Karthick76a497a2017-04-12 10:59:39 -07001424 log_test.info('Here we are throttle traffic for 100 sec of delay and agian creating igmp threads')
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001425 time.sleep(randint(100,110))
1426 j = 1
1427 else:
1428 j = j+ 1
1429 time.sleep(randint(1,2))
1430 thread.start()
1431 threads.append(thread)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001432 for thread in threads:
1433 thread.join()
1434
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001435 @deferred(TEST_TIMEOUT_DELAY+50)
1436 def test_netCondition_with_throttle_between_multiple_igmp_joins_and_data_from_multiple_subscribers(self):
1437 self.setUp_tls()
1438 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001439 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001440 def netCondition_multiple_igmp_joins_and_data(df):
1441 ### Start ips of multicast, source list and subscriber source ip are '229.0.0.1', '10.10.0.1' and '20.20.0.1' respectively
1442 batch_traffic_run = 'yes'
1443 no_users = 11
1444 group_end_ip = '229.0.30.254'
1445 source_list_end_ip = '10.10.30.254'
1446 subscriber_src_end_ip = '20.20.20.254'
1447 self.netCondition_with_multiple_scenarios_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip, source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip, bunch_traffic = batch_traffic_run, data_pkt = 50 )
A R Karthick76a497a2017-04-12 10:59:39 -07001448 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001449 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001450 log_test.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i]))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001451 if assert_equal(self.igmp_threads_result[i], True) is True:
1452 df.callback(0)
1453 df.callback(0)
1454 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1455 return df
1456
1457 @deferred(TEST_TIMEOUT_DELAY+50)
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001458 def test_netCondition_with_invalid_igmp_type_multiple_igmp_joins_and_data_from_multiple_subscribers(self):
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001459 self.setUp_tls()
1460 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001461 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001462 def netCondition_multiple_igmp_joins_and_data(df):
1463 ### Start ips of multicast, source list and subscriber source ip are '229.0.0.1', '10.10.0.1' and '20.20.0.1' respectively
1464 batch_traffic_run = 'no'
1465 invalid_igmp_join = 'igmp_type'
1466 no_users = 11
1467 group_end_ip = '229.0.30.254'
1468 source_list_end_ip = '10.10.30.254'
1469 subscriber_src_end_ip = '20.20.20.254'
1470 self.netCondition_with_multiple_scenarios_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip, source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip, bunch_traffic = batch_traffic_run, data_pkt = 50, invalid_joins = invalid_igmp_join )
A R Karthick76a497a2017-04-12 10:59:39 -07001471 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001472 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001473 log_test.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i]))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001474 if assert_equal(self.igmp_threads_result[i], True) is True:
1475 df.callback(0)
1476 df.callback(0)
1477 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1478 return df
1479
1480 @deferred(TEST_TIMEOUT_DELAY+50)
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001481 def test_netCondition_with_invalid_record_type_multiple_igmp_joins_and_data_from_multiple_subscribers(self):
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001482 self.setUp_tls()
1483 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001484 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001485 def netCondition_multiple_igmp_joins_and_data(df):
1486 ### Start ips of multicast, source list and subscriber source ip are '229.0.0.1', '10.10.0.1' and '20.20.0.1' respectively
1487 batch_traffic_run = 'no'
1488 invalid_igmp_join = 'record_type'
1489 no_users = 11
1490 group_end_ip = '229.0.30.254'
1491 source_list_end_ip = '10.10.30.254'
1492 subscriber_src_end_ip = '20.20.20.254'
1493 self.netCondition_with_multiple_scenarios_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip, source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip, bunch_traffic = batch_traffic_run, data_pkt = 50, invalid_joins = invalid_igmp_join )
A R Karthick76a497a2017-04-12 10:59:39 -07001494 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001495 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001496 log_test.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i]))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001497 if assert_equal(self.igmp_threads_result[i], True) is True:
1498 df.callback(0)
1499 df.callback(0)
1500 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1501 return df
1502
1503
1504 @deferred(TEST_TIMEOUT_DELAY+50)
1505 def test_netCondition_with_invalid_ttl_and_multiple_igmp_joins_and_data_from_multiple_subscribers(self):
1506 self.setUp_tls()
1507 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001508 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001509 def netCondition_multiple_igmp_joins_and_data(df):
1510 ### Start ips of multicast, source list and subscriber source ip are '229.0.0.1', '10.10.0.1' and '20.20.0.1' respectively
1511 batch_traffic_run = 'no'
1512 invalid_igmp_join = 'ttl_type'
1513 no_users = 11
1514 group_end_ip = '229.0.30.254'
1515 source_list_end_ip = '10.10.30.254'
1516 subscriber_src_end_ip = '20.20.20.254'
1517 self.netCondition_with_multiple_scenarios_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip, source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip, bunch_traffic = batch_traffic_run, data_pkt = 10, invalid_joins = invalid_igmp_join )
A R Karthick76a497a2017-04-12 10:59:39 -07001518 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001519 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001520 log_test.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i]))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001521 if assert_equal(self.igmp_threads_result[i], True) is True:
1522 df.callback(0)
1523 df.callback(0)
1524 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1525 return df
1526
1527
1528 @deferred(TEST_TIMEOUT_DELAY-250)
1529 def test_netCondition_in_multiple_eap_tls_sessions_with_out_of_order_exchanges_between_serverHello_and_client_packet(self):
1530 self.setUp_tls()
1531 df = defer.Deferred()
1532 threads = []
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001533 clients = 100
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001534 def eap_tls_eapTlsHelloReq_pkt_delay(df):
1535 def multiple_tls_random_delay():
ChetanGaonker12f9f422016-11-10 23:21:21 -08001536 randomDelay = randint(10,300)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001537 tls = TLSAuthTest(src_mac = 'random')
1538 tls._eapSetup()
1539 tls.tlsEventTable.EVT_EAP_SETUP
1540 tls._eapStart()
1541 tls.tlsEventTable.EVT_EAP_START
1542 tls._eapIdReq()
1543 tls.tlsEventTable.EVT_EAP_ID_REQ
1544 tls._eapTlsCertReq()
1545 assert_equal(tls.failTest, True)
1546 tls._eapTlsHelloReq()
1547 assert_equal(tls.failTest, True)
1548 tls._eapTlsChangeCipherSpec()
1549 assert_equal(tls.failTest, True)
1550 tls._eapTlsFinished()
1551 assert_equal(tls.failTest, True)
A R Karthick76a497a2017-04-12 10:59:39 -07001552 log_test.info('Authentication successful for user %d'%i)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001553 # Sending multiple tls clients and making random delay in between client and server packets.
1554 for i in xrange(clients):
1555 thread = threading.Thread(target = multiple_tls_random_delay)
1556 time.sleep(randint(1,2))
1557 thread.start()
1558 threads.append(thread)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001559 for thread in threads:
1560 thread.join()
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001561 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
1562 return df
1563
1564 @deferred(TEST_TIMEOUT_DELAY-250)
1565 def test_netCondition_in_multiple_eap_tls_session_with_out_of_order_exchanges_in_eapTlsCertReq_packets(self):
1566 self.setUp_tls()
1567 df = defer.Deferred()
1568 threads = []
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001569 clients = 100
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001570 def eap_tls_eapTlsHelloReq_pkt_delay(df):
1571 def multiple_tls_random_delay():
ChetanGaonker12f9f422016-11-10 23:21:21 -08001572 randomDelay = randint(10,300)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001573 tls = TLSAuthTest(src_mac = 'random')
1574 tls._eapSetup()
1575 tls.tlsEventTable.EVT_EAP_SETUP
1576 tls._eapStart()
1577 tls.tlsEventTable.EVT_EAP_START
1578 tls._eapTlsCertReq()
1579 assert_equal(tls.failTest, True)
1580 tls._eapIdReq()
1581 tls.tlsEventTable.EVT_EAP_ID_REQ
1582 assert_equal(tls.failTest, True)
1583 tls._eapTlsCertReq()
1584 assert_equal(tls.failTest, True)
1585 tls._eapTlsHelloReq()
1586 assert_equal(tls.failTest, True)
1587 tls._eapTlsChangeCipherSpec()
1588 assert_equal(tls.failTest, True)
1589 tls._eapTlsFinished()
1590 assert_equal(tls.failTest, True)
A R Karthick76a497a2017-04-12 10:59:39 -07001591 log_test.info('Authentication successful for user %d'%i)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001592 # Sending multiple tls clients and making random delay in between client and server packets.
1593 for i in xrange(clients):
1594 thread = threading.Thread(target = multiple_tls_random_delay)
1595 time.sleep(randint(1,2))
1596 thread.start()
1597 threads.append(thread)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001598 for thread in threads:
1599 thread.join()
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001600 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
1601 return df
1602
1603 @deferred(TEST_TIMEOUT_DELAY-250)
1604 def test_netCondition_in_multiple_eap_tls_sessions_with_out_of_order_eapTlsChangeCipherSpec_packets(self):
1605 self.setUp_tls()
1606 df = defer.Deferred()
1607 threads = []
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001608 clients = 100
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001609 def eap_tls_eapTlsHelloReq_pkt_delay(df):
1610 def multiple_tls_random_delay():
ChetanGaonker12f9f422016-11-10 23:21:21 -08001611 randomDelay = randint(10,300)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001612 tls = TLSAuthTest(src_mac = 'random')
1613 tls._eapSetup()
1614 tls.tlsEventTable.EVT_EAP_SETUP
1615 tls._eapStart()
1616 tls.tlsEventTable.EVT_EAP_START
1617 tls._eapTlsChangeCipherSpec()
1618 tls.failTest = False
1619 tls._eapIdReq()
1620 tls.tlsEventTable.EVT_EAP_ID_REQ
1621 assert_equal(tls.failTest, True)
1622 tls._eapTlsHelloReq()
1623 assert_equal(tls.failTest, True)
1624 tls._eapTlsCertReq()
1625 assert_equal(tls.failTest, True)
1626 tls._eapTlsChangeCipherSpec()
1627 assert_equal(tls.failTest, True)
1628 tls._eapTlsFinished()
1629 assert_equal(tls.failTest, True)
A R Karthick76a497a2017-04-12 10:59:39 -07001630 log_test.info('Authentication successful for user %d'%i)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001631 # Sending multiple tls clients and making random delay in between client and server packets.
1632 for i in xrange(clients):
1633 thread = threading.Thread(target = multiple_tls_random_delay)
1634 time.sleep(randint(1,2))
1635 thread.start()
1636 threads.append(thread)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001637 for thread in threads:
1638 thread.join()
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001639 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
1640 return df
1641
1642 @deferred(TEST_TIMEOUT_DELAY-250)
1643 def test_netCondition_in_multiple_eap_tls_sessions_dropping_eapTlsHelloReq_packets(self):
1644 self.setUp_tls()
1645 df = defer.Deferred()
1646 threads = []
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001647 clients = 100
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001648 def eap_tls_eapTlsHelloReq_pkt_delay(df):
1649 def multiple_tls_random_delay():
ChetanGaonker12f9f422016-11-10 23:21:21 -08001650 randomDelay = randint(10,300)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001651 tls = TLSAuthTest(src_mac = 'random')
1652 tls._eapSetup()
1653 tls.tlsEventTable.EVT_EAP_SETUP
1654 tls._eapStart()
1655 tls.tlsEventTable.EVT_EAP_START
1656 tls._eapIdReq()
1657 tls.tlsEventTable.EVT_EAP_ID_REQ
1658 #tls._eapTlsHelloReq()
1659 tls._eapTlsCertReq()
1660 tls._eapTlsChangeCipherSpec()
1661 assert_equal(tls.failTest, True)
1662 tls._eapTlsFinished()
A R Karthick76a497a2017-04-12 10:59:39 -07001663 log_test.info('Authentication successful for user %d'%i)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001664 # Sending multiple tls clients and making random delay in between client and server packets.
1665 for i in xrange(clients):
1666 thread = threading.Thread(target = multiple_tls_random_delay)
1667 time.sleep(randint(1,2))
1668 thread.start()
1669 threads.append(thread)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001670 for thread in threads:
1671 thread.join()
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001672 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
1673 return df
1674
1675 @deferred(TEST_TIMEOUT_DELAY-250)
1676 def test_netCondition_in_multiple_eap_tls_sessions_dropping_eapTlsChangeCipherSpec_packets(self):
1677 self.setUp_tls()
1678 df = defer.Deferred()
1679 threads = []
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001680 clients = 100
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001681 def eap_tls_eapTlsHelloReq_pkt_delay(df):
1682 def multiple_tls_random_delay():
ChetanGaonker12f9f422016-11-10 23:21:21 -08001683 randomDelay = randint(10,300)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001684 tls = TLSAuthTest(src_mac = 'random')
1685 tls._eapSetup()
1686 tls.tlsEventTable.EVT_EAP_SETUP
1687 tls._eapStart()
1688 tls.tlsEventTable.EVT_EAP_START
1689 tls._eapIdReq()
1690 tls.tlsEventTable.EVT_EAP_ID_REQ
1691 tls._eapTlsHelloReq()
1692 tls._eapTlsCertReq()
1693 #tls._eapTlsChangeCipherSpec()
1694 assert_equal(tls.failTest, True)
1695 tls._eapTlsFinished()
A R Karthick76a497a2017-04-12 10:59:39 -07001696 log_test.info('Authentication successful for user %d'%i)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001697 # Sending multiple tls clients and making random delay in between client and server packets.
1698 for i in xrange(clients):
1699 thread = threading.Thread(target = multiple_tls_random_delay)
1700 time.sleep(randint(1,2))
1701 thread.start()
1702 threads.append(thread)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001703 for thread in threads:
1704 thread.join()
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001705 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
1706 return df
1707
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001708 @deferred(TEST_TIMEOUT_DELAY+50)
1709 def test_netCondition_in_eapol_tls_with_invalid_eapol_version_field_in_client_auth_packet(self):
1710 self.setUp_tls()
1711 randomDelay = randint(10,300)
1712 df = defer.Deferred()
1713 tls = TLSAuthTest()
1714 def eap_tls_eapTlsHelloReq_pkt_delay():
1715 tls._eapTlsHelloReq()
1716 tls._eapTlsCertReq()
1717 tls._eapTlsChangeCipherSpec()
1718 tls._eapTlsFinished()
1719 EapolPacket.eap_tls_packets_field_value_replace(invalid_field_name= 'eapolTlsVersion')
1720 df.callback(0)
1721 def eap_tls_verify(df):
1722 tls._eapSetup()
1723 tls.tlsEventTable.EVT_EAP_SETUP
1724 tls._eapStart()
1725 EapolPacket.eap_invalid_tls_packets_info(invalid_field_name= 'eapolTlsVersion', invalid_field_value= 20)
1726 tls.tlsEventTable.EVT_EAP_START
1727 tls._eapIdReq()
1728 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001729 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001730 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1731 t.start()
1732 reactor.callLater(0, eap_tls_verify, df)
1733 return df
1734
1735 @deferred(TEST_TIMEOUT_DELAY-150)
1736 def test_netCondition_in_eapol_tls_with_invalid_eapol_tls_type_field_in_client_auth_packet(self):
1737 self.setUp_tls()
1738 randomDelay = randint(10,300)
1739 df = defer.Deferred()
1740 tls = TLSAuthTest()
1741 def eap_tls_eapTlsHelloReq_pkt_delay():
1742 tls._eapTlsHelloReq()
1743 tls._eapTlsCertReq()
1744 tls._eapTlsChangeCipherSpec()
1745 tls._eapTlsFinished()
1746 EapolPacket.eap_tls_packets_field_value_replace(invalid_field_name= 'eapolTlsType')
1747 df.callback(0)
1748 def eap_tls_verify(df):
1749 tls._eapSetup()
1750 tls.tlsEventTable.EVT_EAP_SETUP
1751 tls._eapStart()
1752 EapolPacket.eap_invalid_tls_packets_info(invalid_field_name= 'eapolTlsType', invalid_field_value= 20)
1753 tls.tlsEventTable.EVT_EAP_START
1754 tls._eapIdReq()
1755 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001756 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001757 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1758 t.start()
1759 reactor.callLater(0, eap_tls_verify, df)
1760 return df
1761
1762 @deferred(TEST_TIMEOUT_DELAY-150)
1763 def test_netCondition_in_eapol_tls_with_invalid_eapol_type_ID_field_in_client_auth_packet(self):
1764 self.setUp_tls()
1765 randomDelay = randint(10,300)
1766 df = defer.Deferred()
1767 tls = TLSAuthTest()
1768 def eap_tls_eapTlsHelloReq_pkt_delay():
1769 tls._eapTlsHelloReq()
1770 tls._eapTlsCertReq()
1771 tls._eapTlsChangeCipherSpec()
1772 tls._eapTlsFinished()
1773 EapolPacket.eap_tls_packets_field_value_replace(invalid_field_name= 'eapolTypeID')
1774 df.callback(0)
1775 def eap_tls_verify(df):
1776 tls._eapSetup()
1777 tls.tlsEventTable.EVT_EAP_SETUP
1778 tls._eapStart()
1779 EapolPacket.eap_invalid_tls_packets_info(invalid_field_name= 'eapolTypeID', invalid_field_value= 20)
1780 tls.tlsEventTable.EVT_EAP_START
1781 tls._eapIdReq()
1782 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001783 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001784 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1785 t.start()
1786 reactor.callLater(0, eap_tls_verify, df)
1787 return df
1788
1789 @deferred(TEST_TIMEOUT_DELAY-150)
1790 def test_netCondition_in_eapol_tls_with_invalid_eapol_response_field_in_client_auth_packet(self):
1791 self.setUp_tls()
1792 randomDelay = randint(10,300)
1793 df = defer.Deferred()
1794 tls = TLSAuthTest()
1795 def eap_tls_eapTlsHelloReq_pkt_delay():
1796 tls._eapTlsHelloReq()
1797 tls._eapTlsCertReq()
1798 tls._eapTlsChangeCipherSpec()
1799 tls._eapTlsFinished()
1800 EapolPacket.eap_tls_packets_field_value_replace(invalid_field_name= 'eapolResponse')
1801 df.callback(0)
1802 def eap_tls_verify(df):
1803 tls._eapSetup()
1804 tls.tlsEventTable.EVT_EAP_SETUP
1805 tls._eapStart()
1806 EapolPacket.eap_invalid_tls_packets_info(invalid_field_name= 'eapolResponse', invalid_field_value= 20)
1807 tls.tlsEventTable.EVT_EAP_START
1808 tls._eapIdReq()
1809 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001810 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001811 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1812 t.start()
1813 reactor.callLater(0, eap_tls_verify, df)
1814 return df
1815
1816 @deferred(TEST_TIMEOUT_DELAY-150)
1817 def test_netCondition_in_eap_tls_with_invalid_eap_content_type_field_in_client_auth_packet(self):
1818 self.setUp_tls()
1819 randomDelay = randint(10,300)
1820 df = defer.Deferred()
1821 def tls_invalid_content_type_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07001822 log_test.info('TLS authentication failed with invalid content type in TLSContentType packet')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001823 tls = TLSAuthTest(fail_cb = tls_invalid_content_type_cb, invalid_content_type = 44)
1824 def eap_tls_eapTlsHelloReq_pkt_delay():
1825 tls._eapTlsHelloReq()
1826 tls._eapTlsCertReq()
1827 tls._eapTlsChangeCipherSpec()
1828 tls._eapTlsFinished()
1829 df.callback(0)
1830 def eap_tls_verify(df):
1831 tls._eapSetup()
1832 tls.tlsEventTable.EVT_EAP_SETUP
1833 tls._eapStart()
1834 tls.tlsEventTable.EVT_EAP_START
1835 tls._eapIdReq()
1836 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001837 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001838 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1839 t.start()
1840 reactor.callLater(0, eap_tls_verify, df)
1841 return df
1842
1843 @deferred(TEST_TIMEOUT_DELAY-250)
1844 def test_netCondition_in_eap_tls_with_invalid_tls_version_field_in_client_auth_packet(self):
1845 self.setUp_tls()
1846 randomDelay = randint(10,300)
1847 df = defer.Deferred()
1848 def tls_invalid_eap_tls_version_in_client_auth_packet():
A R Karthick76a497a2017-04-12 10:59:39 -07001849 log_test.info('TLS authentication failed with invalid tls version field in the packet')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001850 tls = TLSAuthTest(fail_cb = tls_invalid_eap_tls_version_in_client_auth_packet, version = 'TLS_2_1')
1851 def eap_tls_eapTlsHelloReq_pkt_delay():
1852 tls._eapTlsHelloReq()
1853 tls._eapTlsCertReq()
1854 tls._eapTlsChangeCipherSpec()
1855 tls._eapTlsFinished()
1856 df.callback(0)
1857 def eap_tls_verify(df):
1858 tls._eapSetup()
1859 tls.tlsEventTable.EVT_EAP_SETUP
1860 tls._eapStart()
1861 tls.tlsEventTable.EVT_EAP_START
1862 tls._eapIdReq()
1863 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001864 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001865 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1866 t.start()
1867 reactor.callLater(0, eap_tls_verify, df)
1868 return df
1869
1870 @deferred(TEST_TIMEOUT_DELAY-250)
1871 def test_netCondition_in_eap_tls_with_invalid_tls_cipher_suite_field_in_client_auth_packet(self):
1872 self.setUp_tls()
1873 randomDelay = randint(10,300)
1874 df = defer.Deferred()
1875 def tls_with_invalid_tls_cipher_suite_field_in_client_auth_packet_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07001876 log_test.info('TLS authentication failed with invalid tls cipher suite field in the packet')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001877 tls = TLSAuthTest(fail_cb = tls_with_invalid_tls_cipher_suite_field_in_client_auth_packet_cb, cipher_suite = 'RSA_WITH_AES_512_CBC_SHA')
1878 def eap_tls_eapTlsHelloReq_pkt_delay():
1879 tls._eapTlsHelloReq()
1880 tls._eapTlsCertReq()
1881 tls._eapTlsChangeCipherSpec()
1882 tls._eapTlsFinished()
1883 df.callback(0)
1884 def eap_tls_verify(df):
1885 tls._eapSetup()
1886 tls.tlsEventTable.EVT_EAP_SETUP
1887 tls._eapStart()
1888 tls.tlsEventTable.EVT_EAP_START
1889 tls._eapIdReq()
1890 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001891 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001892 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1893 t.start()
1894 reactor.callLater(0, eap_tls_verify, df)
1895 return df
1896
1897 @deferred(TEST_TIMEOUT_DELAY-150)
1898 def test_netCondition_in_eap_tls_with_id_mismatch_in_identifier_field_in_client_auth_packet(self):
1899 self.setUp_tls()
1900 randomDelay = randint(10,300)
1901 df = defer.Deferred()
1902 def tls_with_invalid_id_in_identifier_response_packet_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07001903 log_test.info('TLS authentication failed with invalid id in identifier packet')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001904 tls = TLSAuthTest(fail_cb = tls_with_invalid_id_in_identifier_response_packet_cb,
1905 id_mismatch_in_identifier_response_packet = True)
1906 def eap_tls_eapTlsHelloReq_pkt_delay():
1907 tls._eapTlsHelloReq()
1908 tls._eapTlsCertReq()
1909 tls._eapTlsChangeCipherSpec()
1910 tls._eapTlsFinished()
1911 df.callback(0)
1912 def eap_tls_verify(df):
1913 tls._eapSetup()
1914 tls.tlsEventTable.EVT_EAP_SETUP
1915 tls._eapStart()
1916 tls.tlsEventTable.EVT_EAP_START
1917 tls._eapIdReq()
1918 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001919 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001920 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1921 t.start()
1922 reactor.callLater(0, eap_tls_verify, df)
1923 return df
1924
1925 @deferred(TEST_TIMEOUT_DELAY-150)
1926 def test_netCondition_in_eap_tls_with_id_mismatch_in_client_hello_auth_packet(self):
1927 self.setUp_tls()
1928 randomDelay = randint(10,300)
1929 df = defer.Deferred()
1930 def tls_with_invalid_id_in_client_hello_packet_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07001931 log_test.info('TLS authentication failed with invalid id in client hello packet')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001932 tls = TLSAuthTest(fail_cb = tls_with_invalid_id_in_client_hello_packet_cb,
1933 id_mismatch_in_client_hello_packet = True)
1934
1935 def eap_tls_eapTlsHelloReq_pkt_delay():
1936 tls._eapTlsHelloReq()
1937 tls._eapTlsCertReq()
1938 tls._eapTlsChangeCipherSpec()
1939 tls._eapTlsFinished()
1940 df.callback(0)
1941 def eap_tls_verify(df):
1942 tls._eapSetup()
1943 tls.tlsEventTable.EVT_EAP_SETUP
1944 tls._eapStart()
1945 tls.tlsEventTable.EVT_EAP_START
1946 tls._eapIdReq()
1947 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001948 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001949 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1950 t.start()
1951 reactor.callLater(0, eap_tls_verify, df)
1952 return df
1953
1954 @deferred(TEST_TIMEOUT_DELAY-150)
1955 def test_netCondition_in_eap_tls_with_invalid_client_hello_handshake_type_auth_packet(self):
1956 self.setUp_tls()
1957 randomDelay = randint(10,300)
1958 df = defer.Deferred()
1959 def tls_incorrect_handshake_type_client_hello_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07001960 log_test.info('TLS authentication failed with incorrect handshake type in client hello packet')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001961 tls = TLSAuthTest(fail_cb = tls_incorrect_handshake_type_client_hello_cb, invalid_client_hello_handshake_type=True)
1962 def eap_tls_eapTlsHelloReq_pkt_delay():
1963 tls._eapTlsHelloReq()
1964 tls._eapTlsCertReq()
1965 tls._eapTlsChangeCipherSpec()
1966 tls._eapTlsFinished()
1967 df.callback(0)
1968 def eap_tls_verify(df):
1969 tls._eapSetup()
1970 tls.tlsEventTable.EVT_EAP_SETUP
1971 tls._eapStart()
1972 tls.tlsEventTable.EVT_EAP_START
1973 tls._eapIdReq()
1974 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001975 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001976 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1977 t.start()
1978 reactor.callLater(0, eap_tls_verify, df)
1979 return df
1980
1981 @deferred(TEST_TIMEOUT_DELAY-150)
1982 def test_netCondition_in_eap_tls_with_invalid_client_cert_req_handshake_auth_packet(self):
1983 self.setUp_tls()
1984 randomDelay = randint(10,300)
1985 df = defer.Deferred()
1986 def tls_incorrect_handshake_type_certificate_request_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07001987 log_test.info('TLS authentication failed with incorrect handshake type in client certificate request packet')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001988 tls = TLSAuthTest(fail_cb = tls_incorrect_handshake_type_certificate_request_cb, invalid_cert_req_handshake = True)
1989 def eap_tls_eapTlsHelloReq_pkt_delay():
1990 tls._eapTlsHelloReq()
1991 tls._eapTlsCertReq()
1992 tls._eapTlsChangeCipherSpec()
1993 tls._eapTlsFinished()
1994 df.callback(0)
1995 def eap_tls_verify(df):
1996 tls._eapSetup()
1997 tls.tlsEventTable.EVT_EAP_SETUP
1998 tls._eapStart()
1999 tls.tlsEventTable.EVT_EAP_START
2000 tls._eapIdReq()
2001 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07002002 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002003 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
2004 t.start()
2005 reactor.callLater(0, eap_tls_verify, df)
2006 return df
2007
2008 @deferred(TEST_TIMEOUT_DELAY-150)
2009 def test_netCondition_in_eap_tls_with_invalid_client_key_ex_replacing_server_key_ex(self):
2010 self.setUp_tls()
2011 randomDelay = randint(10,300)
2012 df = defer.Deferred()
2013 def tls_clientkeyex_replace_with_serverkeyex_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07002014 log_test.info('TLS authentication failed with client key exchange replaced with server key exchange')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002015 tls = TLSAuthTest(fail_cb = tls_clientkeyex_replace_with_serverkeyex_cb,clientkeyex_replace_with_serverkeyex=True)
2016 def eap_tls_eapTlsHelloReq_pkt_delay():
2017 tls._eapTlsHelloReq()
2018 tls._eapTlsCertReq()
2019 tls._eapTlsChangeCipherSpec()
2020 tls._eapTlsFinished()
2021 df.callback(0)
2022 def eap_tls_verify(df):
2023 tls._eapSetup()
2024 tls.tlsEventTable.EVT_EAP_SETUP
2025 tls._eapStart()
2026 tls.tlsEventTable.EVT_EAP_START
2027 tls._eapIdReq()
2028 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07002029 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002030 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
2031 t.start()
2032 reactor.callLater(0, eap_tls_verify, df)
2033 return df
2034
2035 def tcpreplay_radius_server_packets_from_pcap_file(self, pcap_file_path =None, error_pkt = None):
2036 #default radius server packets in path in test/netCondition/xxx.pcap file
2037 if pcap_file_path and (error_pkt == None):
2038 pcap_file_path = pcap_file_path
2039 elif error_pkt == None:
2040 pcap_file_path = "/root/test/src/test/netCondition/tls_auth_exhange_packets_Radius_server_packets_only.pcap"
2041 elif error_pkt:
2042 pcap_file_path = "/root/test/src/test/netCondition/error_tls_auth_exhange_packets_Radius_server_packets_only.pcap"
A R Karthick76a497a2017-04-12 10:59:39 -07002043 log_test.info('Started replaying pcap file packets on docker0 interface using tcprelay linux command')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002044 time.sleep(0.4)
2045 sendp(rdpcap(pcap_file_path), iface="eth0", loop=0, inter=1)
2046 time.sleep(5)
A R Karthick76a497a2017-04-12 10:59:39 -07002047 log_test.info('Replayed pcap file packets on docker0 interface')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002048
2049 def tcpreplay_radius_server_error_packets_from_pcap_file(self, pcap_file_path =None, error_pkt = None):
2050 #default radius server packets in path in test/netCondition/xxx.pcap file
2051 if pcap_file_path:
2052 pcap_file_path = pcap_file_path
2053 else:
2054 pcap_file_path = "/root/test/src/test/netCondition/error_tls_auth_exhange_packets_Radius_server_packets_only.pcap"
A R Karthick76a497a2017-04-12 10:59:39 -07002055 log_test.info('Started replaying pcap file error packets on docker0 interface using tcprelay linux command')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002056 time.sleep(0.4)
2057 sendp(rdpcap(pcap_file_path), iface="eth0", loop=0, inter=1)
2058 time.sleep(5)
2059 return 'success'
2060
2061 def emulating_invalid_radius_server_packets_from_pcap_file(self, pcap_file_path =None, pkt_no = None,L2 = None, L3 =None, L4=None, no_of_radius_attribute=None):
2062 #default radius server packets in path in test/netCondition/xxx.pcap file
2063 random_port = 1222
2064 if pcap_file_path:
2065 pcap_file_path = pcap_file_path
2066 else:
2067 pcap_file_path = "/root/test/src/test/netCondition/tls_auth_exhange_packets_Radius_server_packets_only.pcap"
A R Karthick76a497a2017-04-12 10:59:39 -07002068 log_test.info('Started corrupting tls server packet no = {}'.format(pkt_no))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002069 radius_server_pkts = rdpcap(pcap_file_path)
2070 error_server_pkt = radius_server_pkts[pkt_no]
2071 if pkt_no == 0:
2072 if L4:
2073 error_server_pkt[UDP].sport = random_port
2074 error_server_pkt[UDP].dport = random_port
2075
2076 if no_of_radius_attribute:
2077 error_server_pkt[3][2].value = '\n\xd8\xf0\xbbW\xd6$;\xd2s\xd5\xc5Ck\xd5\x01'
2078 error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2079 if pkt_no == 1:
2080 if L4:
2081 error_server_pkt[UDP].sport = random_port
2082 error_server_pkt[UDP].dport = random_port
2083
2084 if no_of_radius_attribute:
2085 error_server_pkt[3][2].type = 79
2086 error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2087
2088 if pkt_no == 2:
2089 if L4:
2090 error_server_pkt[UDP].sport = random_port
2091 error_server_pkt[UDP].dport = random_port
2092
2093 if no_of_radius_attribute:
2094 error_server_pkt[3][1].type = 79
2095 error_server_pkt[3][2].len = 18
2096 error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2097 error_server_pkt[3][3].len = 18
2098 error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9'
2099
2100 if pkt_no == 3:
2101 if L4:
2102 error_server_pkt[UDP].sport = random_port
2103 error_server_pkt[UDP].dport = random_port
2104
2105 if no_of_radius_attribute:
2106 error_server_pkt[3][1].type = 79
2107 error_server_pkt[3][2].len = 18
2108 error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2109 error_server_pkt[3][3].len = 18
2110 error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9'
2111
2112 if pkt_no == 4:
2113 if L4:
2114 error_server_pkt[UDP].sport = random_port
2115 error_server_pkt[UDP].dport = random_port
2116
2117 if no_of_radius_attribute:
2118 error_server_pkt[3][1].type = 79
2119 error_server_pkt[3][2].len = 18
2120 error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2121 error_server_pkt[3][3].len = 18
2122 error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9'
2123
2124 if pkt_no == 5:
2125 if L4:
2126 error_server_pkt[UDP].sport = random_port
2127 error_server_pkt[UDP].dport = random_port
2128
2129 if no_of_radius_attribute:
2130 error_server_pkt[3][1].type = 79
2131 error_server_pkt[3][2].len = 18
2132 error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2133 error_server_pkt[3][3].len = 18
2134 error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9'
2135
2136 if pkt_no == 6:
2137 if L4:
2138 error_server_pkt[UDP].sport = random_port
2139 error_server_pkt[UDP].dport = random_port
2140
2141 if no_of_radius_attribute:
2142 error_server_pkt[3][1].type = 79
2143 error_server_pkt[3][2].len = 18
2144 error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2145 error_server_pkt[3][3].len = 18
2146 error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2147 error_server_pkt[3][5].len = 18
2148 error_server_pkt[3][5].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9'
2149
2150
2151 error_server_pkt.show()
2152 radius_server_pkts[pkt_no] = error_server_pkt
2153 wrpcap("/root/test/src/test/netCondition/error_tls_auth_exhange_packets_Radius_server_packets_only.pcap", radius_server_pkts)
2154 pcap_file_path = "/root/test/src/test/netCondition/error_tls_auth_exhange_packets_Radius_server_packets_only.pcap"
2155
A R Karthick76a497a2017-04-12 10:59:39 -07002156 log_test.info('Done corrupting tls server packet no = {} send back filepath along with file name'.format(pkt_no))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002157 return pcap_file_path
2158
2159 @deferred(TEST_TIMEOUT_DELAY-50)
2160 def test_netCondition_in_eap_tls_with_valid_client_and_emulating_server_packets_without_radius_server_container(self):
2161 self.setUp_tls()
2162 df = defer.Deferred()
2163 threads = []
2164 threads_status = []
2165 clients = 1
A R Karthickf7a613b2017-02-24 09:36:44 -08002166 radius_image = 'cordtest/radius:candidate'
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002167 delay = 20
2168 que = Queue.Queue()
2169 def eap_tls_emulating_server_pkts(df):
2170 def tls_client_packets(start):
2171 time.sleep(0.2)
2172 randomDelay = randint(10,300)
2173 tls = TLSAuthTest(src_mac = 'random')
2174 tls._eapSetup()
2175 tls.tlsEventTable.EVT_EAP_SETUP
2176 tls._eapStart()
2177 tls.tlsEventTable.EVT_EAP_START
2178 tls._eapIdReq()
2179 tls.tlsEventTable.EVT_EAP_ID_REQ
2180 tls._eapTlsHelloReq()
2181 tls._eapTlsCertReq()
2182 tls._eapTlsChangeCipherSpec()
2183 tls._eapTlsFinished()
2184 if tls.failTest == False:
A R Karthick76a497a2017-04-12 10:59:39 -07002185 log_test.info('Authentication successful for user')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002186 return 'success'
2187 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002188 log_test.info('Authentication not successful for user')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002189 return 'failed'
2190 thread_client = threading.Thread(target=lambda q, arg1: q.put(tls_client_packets(arg1)), args=(que, 'start'))
2191 thread_radius = threading.Thread(target = Container.pause_container, args = (radius_image,delay))
2192 thread_tcpreplay = threading.Thread(target = self.tcpreplay_radius_server_packets_from_pcap_file)
2193 threads.append(thread_radius)
2194 threads.append(thread_client)
2195 threads.append(thread_tcpreplay)
2196 for thread in threads:
2197 thread.start()
2198 for thread in threads:
2199 thread.join()
2200 while not que.empty():
2201 threads_status = que.get()
2202 assert_equal(threads_status, 'success')
2203 df.callback(0)
2204 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2205 return df
2206
2207
2208 def eap_tls_emulating_server_pkts_negative_testing(df,msg):
2209 threads = []
2210 threads_status = []
2211 clients = 1
A R Karthickf7a613b2017-02-24 09:36:44 -08002212 radius_image = 'cordtest/radius:candidate'
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002213 delay = 20
2214 que = Queue.Queue()
2215 def tls_client_packets(start):
2216 time.sleep(0.2)
2217 randomDelay = randint(10,300)
2218 def tls_invalid_server_packets_scenario_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07002219 log_test.info('TLS authentication failed with {}'.format(msg))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002220 tls = TLSAuthTest(fail_cb = tls_invalid_server_packets_scenario_cb, src_mac = 'random')
2221 tls._eapSetup()
2222 tls.tlsEventTable.EVT_EAP_SETUP
2223 tls._eapStart()
2224 tls.tlsEventTable.EVT_EAP_START
2225 tls._eapIdReq()
2226 tls.tlsEventTable.EVT_EAP_ID_REQ
2227 tls._eapTlsHelloReq()
2228 tls._eapTlsCertReq()
2229 tls._eapTlsChangeCipherSpec()
2230 tls._eapTlsFinished()
2231 if tls.failTest == True:
A R Karthick76a497a2017-04-12 10:59:39 -07002232 log_test.info('Authentication not successful for user')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002233 return 'failed'
2234 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002235 log_test.info('Authentication successful for user')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002236 return 'success'
2237 def tcpreplay_radius_server_error_packets_from_pcap_file(pcap_file_path =None, error_pkt = None):
2238 #default radius server packets in path in test/netCondition/xxx.pcap file
2239 if pcap_file_path:
2240 pcap_file_path = pcap_file_path
2241 else:
2242 pcap_file_path = "/root/test/src/test/netCondition/error_tls_auth_exhange_packets_Radius_server_packets_only.pcap"
2243
A R Karthick76a497a2017-04-12 10:59:39 -07002244 log_test.info('Started replaying pcap file error packets on docker0 interface using tcprelay linux command')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002245 time.sleep(0.4)
2246 sendp(rdpcap(pcap_file_path), iface="eth0", loop=0, inter=1)
2247 time.sleep(5)
2248 return 'success'
2249 thread_client = threading.Thread(target=lambda q, arg1: q.put(tls_client_packets(arg1)), args=(que, 'start'))
2250 thread_radius = threading.Thread(target = Container.pause_container, args = (radius_image,delay))
2251 thread_tcpreplay = threading.Thread(target = tcpreplay_radius_server_error_packets_from_pcap_file)
2252 threads.append(thread_radius)
2253 threads.append(thread_client)
2254 threads.append(thread_tcpreplay)
2255 for thread in threads:
2256 thread.start()
2257 for thread in threads:
2258 thread.join()
2259 while not que.empty():
2260 threads_status = que.get()
2261 assert_equal(threads_status, 'failed')
2262
2263
2264 @deferred(TEST_TIMEOUT_DELAY-250)
2265 def test_netCondition_in_eap_tls_with_valid_client_and_dropped_server_eapid_response_packet(self):
2266 self.setUp_tls()
2267 df = defer.Deferred()
2268 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 0, L4 = True)
2269 def eap_tls_emulating_server_pkts(df):
2270 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping server eapId response')
2271 df.callback(0)
2272 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2273 return df
2274
2275 @deferred(TEST_TIMEOUT_DELAY-50)
2276 def test_netCondition_in_eap_tls_with_valid_client_and_invalid_server_eapid_response_packet(self):
2277 self.setUp_tls()
2278 df = defer.Deferred()
2279 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 0, no_of_radius_attribute = 1)
2280 def eap_tls_emulating_server_pkts(df):
2281 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid server eapId response')
2282 df.callback(0)
2283 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2284 return df
2285 @deferred(TEST_TIMEOUT_DELAY-50)
2286 def test_netCondition_in_eap_tls_with_valid_client_and_dropped_server_hello_packet(self):
2287 self.setUp_tls()
2288 df = defer.Deferred()
2289 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 1, L4 = True)
2290 def eap_tls_emulating_server_pkts(df):
2291 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping server hello packet')
2292 df.callback(0)
2293 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2294 return df
2295
2296 @deferred(TEST_TIMEOUT_DELAY-50)
2297 def test_netCondition_in_eap_tls_with_valid_client_and_invalid_server_hello_packet(self):
2298 self.setUp_tls()
2299 df = defer.Deferred()
2300 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 1, no_of_radius_attribute = 1)
2301 def eap_tls_emulating_server_pkts(df):
2302 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid server hello packet')
2303 df.callback(0)
2304 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2305 return df
2306
2307 @deferred(TEST_TIMEOUT_DELAY-50)
2308 def test_netCondition_in_eap_tls_with_valid_client_and_dropped_client_certficate_access_challenge_server_packet(self):
2309 self.setUp_tls()
2310 df = defer.Deferred()
2311 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 2, L4 = True)
2312 def eap_tls_emulating_server_pkts(df):
2313 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping client certificate access challenge packet')
2314 df.callback(0)
2315 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2316 return df
2317
2318 @deferred(TEST_TIMEOUT_DELAY-50)
2319 def test_netCondition_in_eap_tls_with_valid_client_and_invalid_client_certficate_access_challenge_server_packet(self):
2320 self.setUp_tls()
2321 df = defer.Deferred()
2322 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 2, no_of_radius_attribute = 1)
2323 def eap_tls_emulating_server_pkts(df):
2324 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid client certificate access challenge packet')
2325 df.callback(0)
2326 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2327 return df
2328
2329 @deferred(TEST_TIMEOUT_DELAY-50)
2330 def test_netCondition_in_eap_tls_with_valid_client_and_dropped_client_certficate_with_2nd_fragment_access_challenge_server_packet(self):
2331 self.setUp_tls()
2332 df = defer.Deferred()
2333 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 3, L4 = True)
2334 def eap_tls_emulating_server_pkts(df):
2335 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping client certificate with 2nd fragment access challenge packet')
2336 df.callback(0)
2337 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2338 return df
2339
2340 @deferred(TEST_TIMEOUT_DELAY-50)
2341 def test_netCondition_in_eap_tls_with_valid_client_and_invalid_client_certficate_with_2nd_fragment_access_challenge_server_packet(self):
2342 self.setUp_tls()
2343 df = defer.Deferred()
2344 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 3, no_of_radius_attribute = 1)
2345 def eap_tls_emulating_server_pkts(df):
2346 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid client certificate for 2nd fragment access challenge packet')
2347 df.callback(0)
2348 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2349 return df
2350
2351 @deferred(TEST_TIMEOUT_DELAY-50)
2352 def test_netCondition_in_eap_tls_with_valid_client_and_dropped_client_certficate_with_3rd_fragment_access_challenge_server_packet(self):
2353 self.setUp_tls()
2354 df = defer.Deferred()
2355 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 4, L4 = True)
2356 def eap_tls_emulating_server_pkts(df):
2357 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping client certificate for 3rd fragment access challenge packet')
2358 df.callback(0)
2359 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2360 return df
2361
2362 @deferred(TEST_TIMEOUT_DELAY-50)
2363 def test_netCondition_in_eap_tls_with_valid_client_and_invalid_client_certficate_with_3rd_fragment_access_challenge_server_packet(self):
2364 self.setUp_tls()
2365 df = defer.Deferred()
2366 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 4, no_of_radius_attribute = 1)
2367 def eap_tls_emulating_server_pkts(df):
2368 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid client certificate for 3rd fragment access challenge packet')
2369 df.callback(0)
2370 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2371 return df
2372
2373 @deferred(TEST_TIMEOUT_DELAY-50)
2374 def test_netCondition_in_eap_tls_with_valid_client_and_dropped_cipher_suite_request_server_packet(self):
2375 self.setUp_tls()
2376 df = defer.Deferred()
2377 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 5, L4 = True)
2378 def eap_tls_emulating_server_pkts(df):
2379 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping cipher suite request server packet')
2380 df.callback(0)
2381 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2382 return df
2383
2384 @deferred(TEST_TIMEOUT_DELAY-50)
2385 def test_netCondition_in_eap_tls_with_valid_client_and_invalid_cipher_suite_request_server_packet(self):
2386 self.setUp_tls()
2387 df = defer.Deferred()
2388 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 5, no_of_radius_attribute = 1)
2389 def eap_tls_emulating_server_pkts(df):
2390 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid cipher suite request server packet')
2391 df.callback(0)
2392 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2393 return df
2394
2395 @deferred(TEST_TIMEOUT_DELAY-50)
2396 def test_netCondition_in_eap_tls_with_valid_client_and_dropped_access_accept_server_packet(self):
2397 self.setUp_tls()
2398 df = defer.Deferred()
2399 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 6, L4 = True)
2400 def eap_tls_emulating_server_pkts(df):
2401 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping access accept server packet ')
2402 df.callback(0)
2403 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2404 return df
2405
2406 @deferred(TEST_TIMEOUT_DELAY-50)
2407 def test_netCondition_in_eap_tls_with_valid_client_and_invalid_access_accept_server_packet(self):
2408 self.setUp_tls()
2409 df = defer.Deferred()
2410 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 6, no_of_radius_attribute = 1)
2411 def eap_tls_emulating_server_pkts(df):
2412 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid access accept server packet ')
2413 df.callback(0)
2414 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2415 return df