blob: 34fc883c57e62e69c97d9de4c4f298120e6c4162 [file] [log] [blame]
Matteo Scandolo48d3d2d2017-08-08 13:05:27 -07001
2# Copyright 2017-present Open Networking Foundation
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
16
ChetanGaonker3441faf2016-10-27 12:15:21 -070017#
18# Copyright 2016-present Ciena Corporation
19#
20# Licensed under the Apache License, Version 2.0 (the "License");
21# you may not use this file except in compliance with the License.
22# You may obtain a copy of the License at
23#
24# http://www.apache.org/licenses/LICENSE-2.0
25#
26# Unless required by applicable law or agreed to in writing, software
27# distributed under the License is distributed on an "AS IS" BASIS,
28# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29# See the License for the specific language governing permissions and
30# limitations under the License.
31#
32import unittest
33from threading import Timer
34from nose.tools import *
35from nose.twistedtools import reactor, deferred
36from twisted.internet import defer
37from scapy.all import *
38import time, monotonic
39import os, sys
40import tempfile
41import random
ChetanGaonkerfc7b0302016-11-10 08:45:56 -080042import Queue
ChetanGaonker3441faf2016-10-27 12:15:21 -070043import threading
44from IGMP import *
45from McastTraffic import *
46from Stats import Stats
47from OnosCtrl import OnosCtrl
48from OltConfig import OltConfig
49from Channels import IgmpChannel
50from EapTLS import TLSAuthTest
51from scapy_ssl_tls.ssl_tls import *
52from scapy_ssl_tls.ssl_tls_crypto import *
ChetanGaonker3441faf2016-10-27 12:15:21 -070053from EapolAAA import *
A R Karthick74d00312017-04-18 14:26:01 -070054from Enum import *
ChetanGaonker3441faf2016-10-27 12:15:21 -070055import noseTlsAuthHolder as tlsAuthHolder
56from tls_cert import Key
57from socket import *
58from CordTestServer import cord_test_radius_restart
59import struct
60import scapy
61from CordTestBase import CordTester
62from CordContainer import *
A R Karthick9313b762016-11-07 13:14:35 -080063from CordLogger import CordLogger
A R Karthick76a497a2017-04-12 10:59:39 -070064from CordTestUtils import log_test
ChetanGaonker3441faf2016-10-27 12:15:21 -070065import re
66from random import randint
67from time import sleep
ChetanGaonker3441faf2016-10-27 12:15:21 -070068import json
69from OnosFlowCtrl import OnosFlowCtrl
70from OltConfig import OltConfig
71from threading import current_thread
72import collections
A R Karthick76a497a2017-04-12 10:59:39 -070073log_test.setLevel('INFO')
ChetanGaonker3441faf2016-10-27 12:15:21 -070074
75class IGMPTestState:
76
77 def __init__(self, groups = [], df = None, state = 0):
78 self.df = df
79 self.state = state
80 self.counter = 0
81 self.groups = groups
82 self.group_map = {} ##create a send/recv count map
83 for g in groups:
84 self.group_map[g] = (Stats(), Stats())
85
86 def update(self, group, tx = 0, rx = 0, t = 0):
87 self.counter += 1
88 index = 0 if rx == 0 else 1
89 v = tx if rx == 0 else rx
90 if self.group_map.has_key(group):
91 self.group_map[group][index].update(packets = v, t = t)
92
93 def update_state(self):
94 self.state = self.state ^ 1
95
A R Karthick9313b762016-11-07 13:14:35 -080096class netCondition_exchange(CordLogger):
ChetanGaonker3441faf2016-10-27 12:15:21 -070097
98 V_INF1 = 'veth0'
99 V_INF2 = 'veth1'
100 MGROUP1 = '239.1.2.3'
101 MGROUP2 = '239.2.2.3'
102 MINVALIDGROUP1 = '255.255.255.255'
103 MINVALIDGROUP2 = '239.255.255.255'
104 MMACGROUP1 = "01:00:5e:01:02:03"
105 MMACGROUP2 = "01:00:5e:02:02:03"
106 IGMP_DST_MAC = "01:00:5e:00:00:16"
107 IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1"
108 IP_SRC = '1.2.3.4'
109 IP_DST = '224.0.0.22'
110 NEGATIVE_TRAFFIC_STATUS = 1
111 igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP)
112 igmp_ip = IP(dst = IP_DST)
113 IGMP_TEST_TIMEOUT = 5
114 IGMP_QUERY_TIMEOUT = 60
115 MCAST_TRAFFIC_TIMEOUT = 10
116 TEST_TIMEOUT_DELAY = 340
117 PORT_TX_DEFAULT = 2
118 PORT_RX_DEFAULT = 1
119 max_packets = 100
120 app_igmp = 'org.opencord.igmp'
A.R Karthick5968e0d2017-05-16 14:50:46 -0700121 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 -0700122 ROVER_TEST_TIMEOUT = 10 #3600*86
123 ROVER_TIMEOUT = (ROVER_TEST_TIMEOUT - 100)
124 ROVER_JOIN_TIMEOUT = 60
125
126 app_tls = 'org.opencord.aaa'
127 TLS_TIMEOUT = 20
128 CLIENT_CERT_INVALID = '''-----BEGIN CERTIFICATE-----
129MIIEyTCCA7GgAwIBAgIJAM6l2jUG56pLMA0GCSqGSIb3DQEBCwUAMIGLMQswCQYD
130VQQGEwJVUzELMAkGA1UECBMCQ0ExEjAQBgNVBAcTCVNvbWV3aGVyZTETMBEGA1UE
131ChMKQ2llbmEgSW5jLjEeMBwGCSqGSIb3DQEJARYPYWRtaW5AY2llbmEuY29tMSYw
132JAYDVQQDEx1FeGFtcGxlIENlcnRpZmljYXRlIEF1dGhvcml0eTAeFw0xNjAzMTEx
133ODUzMzVaFw0xNzAzMDYxODUzMzVaMIGLMQswCQYDVQQGEwJVUzELMAkGA1UECBMC
134Q0ExEjAQBgNVBAcTCVNvbWV3aGVyZTETMBEGA1UEChMKQ2llbmEgSW5jLjEeMBwG
135CSqGSIb3DQEJARYPYWRtaW5AY2llbmEuY29tMSYwJAYDVQQDEx1FeGFtcGxlIENl
136cnRpZmljYXRlIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
137ggEBAL9Jv54TkqycL3U2Fdd/y5NXdnPVXwAVV3m6I3eIffVCv8eS+mwlbl9dnbjo
138qqlGEgA3sEg5HtnKoW81l3PSyV/YaqzUzbcpDlgWlbNkFQ3nVxh61gSU34Fc4h/W
139plSvCkwGSbV5udLtEe6S9IflP2Fu/eXa9vmUtoPqDk66p9U/nWVf2H1GJy7XanWg
140wke+HpQvbzoSfPJS0e5Rm9KErrzaIkJpqt7soW+OjVJitUax7h45RYY1HHHlbMQ0
141ndWW8UDsCxFQO6d7nsijCzY69Y8HarH4mbVtqhg3KJevxD9UMRy6gdtPMDZLah1c
142LHRu14ucOK4aF8oICOgtcD06auUCAwEAAaOCASwwggEoMB0GA1UdDgQWBBQwEs0m
143c8HARTVp21wtiwgav5biqjCBwAYDVR0jBIG4MIG1gBQwEs0mc8HARTVp21wtiwga
144v5biqqGBkaSBjjCBizELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRIwEAYDVQQH
145EwlTb21ld2hlcmUxEzARBgNVBAoTCkNpZW5hIEluYy4xHjAcBgkqhkiG9w0BCQEW
146D2FkbWluQGNpZW5hLmNvbTEmMCQGA1UEAxMdRXhhbXBsZSBDZXJ0aWZpY2F0ZSBB
147dXRob3JpdHmCCQDOpdo1BueqSzAMBgNVHRMEBTADAQH/MDYGA1UdHwQvMC0wK6Ap
148oCeGJWh0dHA6Ly93d3cuZXhhbXBsZS5jb20vZXhhbXBsZV9jYS5jcmwwDQYJKoZI
149hvcNAQELBQADggEBAK+fyAFO8CbH35P5mOX+5wf7+AeC+5pwaFcoCV0zlfwniANp
150jISgcIX9rcetLxeYRAO5com3+qLdd9dGVNL0kwufH4QhlSPErG7OLHHAs4JWVhUo
151bH3lK9lgFVlnCDBtQhslzqScR64SCicWcQEjv3ZMZsJwYLvl8unSaKz4+LVPeJ2L
152opCpmZw/V/S2NhBbe3QjTiRPmDev2gbaO4GCfi/6sCDU7UO3o8KryrkeeMIiFIej
153gfwn9fovmpeqCEyupy2JNNUTJibEuFknwx7JAX+htPL27nEgwV1FYtwI3qLiZqkM
154729wo9cFSslJNZBu+GsBP5LszQSuvNTDWytV+qY=
155-----END CERTIFICATE-----'''
156
157 def onos_aaa_config(self):
A.R Karthicka6c88fd2017-03-13 09:29:41 -0700158 aaa_dict = {'apps' : { 'org.opencord.aaa' : { 'AAA' : { 'radiusSecret': 'radius_password',
159 'radiusIp': '172.17.0.2' } } } }
ChetanGaonker3441faf2016-10-27 12:15:21 -0700160 radius_ip = os.getenv('ONOS_AAA_IP') or '172.17.0.2'
A.R Karthicka6c88fd2017-03-13 09:29:41 -0700161 aaa_dict['apps']['org.opencord.aaa']['AAA']['radiusIp'] = radius_ip
ChetanGaonker3441faf2016-10-27 12:15:21 -0700162 self.onos_ctrl.activate()
163 time.sleep(2)
164 self.onos_load_tls_config(aaa_dict)
165
166 def onos_load_tls_config(self, config):
167 status, code = OnosCtrl.config(config)
168 if status is False:
A R Karthick76a497a2017-04-12 10:59:39 -0700169 log_test.info('Configure request for AAA returned status %d' %code)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700170 assert_equal(status, True)
171 time.sleep(3)
172
173 @classmethod
174 def setUpClass(cls):
175 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
176 cls.port_map, _ = cls.olt.olt_port_map()
A R Karthick0f6b6842016-12-06 17:17:44 -0800177 OnosCtrl.cord_olt_config(cls.olt)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700178 cls.device_id = OnosCtrl.get_device_id()
179
180 @classmethod
181 def tearDownClass(cls): pass
182
183 def setUp_igmp(self):
184 ''' Activate the igmp app'''
185 apps = self.app_igmp
186 self.onos_ctrl = OnosCtrl(apps)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700187 self.onos_aaa_config()
188 self.onos_ctrl.activate()
189 self.igmp_channel = IgmpChannel()
190
191 def setUp_tls(self):
Thangavelu K Sef6f0a52016-12-14 19:57:05 +0000192 ''' Activate the aaa app'''
ChetanGaonker3441faf2016-10-27 12:15:21 -0700193 apps = self.app_tls
194 self.onos_ctrl = OnosCtrl(apps)
195 self.onos_aaa_config()
196
197 def tearDown(self):
198 '''Deactivate the dhcp app'''
199 apps = [self.app_igmp, self.app_tls]
200 for app in apps:
201 onos_ctrl = OnosCtrl(app)
202 onos_ctrl.deactivate()
ChetanGaonker3441faf2016-10-27 12:15:21 -0700203
204 def onos_load_igmp_config(self, config):
A R Karthick76a497a2017-04-12 10:59:39 -0700205 log_test.info('onos load config is %s'%config)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700206 status, code = OnosCtrl.config(config)
207 if status is False:
A R Karthick76a497a2017-04-12 10:59:39 -0700208 log_test.info('JSON request returned status %d' %code)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700209 assert_equal(status, True)
210 time.sleep(2)
211
212 def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False):
213 ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
214 ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
215 if flag: #to maintain seperate group-source pair.
216 for i in range(len(groups)):
217 d = {}
218 d['source'] = src_list[i] or '0.0.0.0'
219 d['group'] = groups[i]
220 ssm_xlate_list.append(d)
221 else:
222 for g in groups:
223 for s in src_list:
224 d = {}
225 d['source'] = s or '0.0.0.0'
226 d['group'] = g
227 ssm_xlate_list.append(d)
228 self.onos_load_igmp_config(ssm_dict)
229 cord_port_map = {}
230 for g in groups:
231 cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT)
232 self.igmp_channel.cord_port_table_load(cord_port_map)
233 time.sleep(2)
234
235 def mcast_ip_range(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
236 start = list(map(int, start_ip.split(".")))
237 end = list(map(int, end_ip.split(".")))
238 temp = start
239 ip_range = []
240 ip_range.append(start_ip)
241 while temp != end:
242 start[3] += 1
243 for i in (3, 2, 1):
244 if temp[i] == 255:
245 temp[i] = 0
246 temp[i-1] += 1
247 ip_range.append(".".join(map(str, temp)))
248 return ip_range
249
250 def random_mcast_ip(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
251 start = list(map(int, start_ip.split(".")))
252 end = list(map(int, end_ip.split(".")))
253 temp = start
254 ip_range = []
255 ip_range.append(start_ip)
256 while temp != end:
257 start[3] += 1
258 for i in (3, 2, 1):
259 if temp[i] == 255:
260 temp[i] = 0
261 temp[i-1] += 1
262 ip_range.append(".".join(map(str, temp)))
263 return random.choice(ip_range)
264
265 def source_ip_range(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
266 start = list(map(int, start_ip.split(".")))
267 end = list(map(int, end_ip.split(".")))
268 temp = start
269 ip_range = []
270 ip_range.append(start_ip)
271 while temp != end:
272 start[3] += 1
273 for i in (3, 2, 1):
274 if temp[i] == 255:
275 temp[i] = 0
276 temp[i-1] += 1
277 ip_range.append(".".join(map(str, temp)))
278 return ip_range
279
280 def randomsourceip(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
281 start = list(map(int, start_ip.split(".")))
282 end = list(map(int, end_ip.split(".")))
283 temp = start
284 ip_range = []
285 ip_range.append(start_ip)
286 while temp != end:
287 start[3] += 1
288 for i in (3, 2, 1):
289 if temp[i] == 255:
290 temp[i] = 0
291 temp[i-1] += 1
292 ip_range.append(".".join(map(str, temp)))
293 return random.choice(ip_range)
294
295 def get_igmp_intf(self):
296 inst = os.getenv('TEST_INSTANCE', None)
297 if not inst:
298 return 'veth0'
299 inst = int(inst) + 1
300 if inst >= self.port_map['uplink']:
301 inst += 1
302 if self.port_map.has_key(inst):
303 return self.port_map[inst]
304 return 'veth0'
305
306 def igmp_verify_join(self, igmpStateList):
307 sendState, recvState = igmpStateList
308 ## check if the send is received for the groups
309 for g in sendState.groups:
310 tx_stats = sendState.group_map[g][0]
311 tx = tx_stats.count
312 assert_greater(tx, 0)
313 rx_stats = recvState.group_map[g][1]
314 rx = rx_stats.count
315 assert_greater(rx, 0)
A R Karthick76a497a2017-04-12 10:59:39 -0700316 log_test.info('Receive stats %s for group %s' %(rx_stats, g))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700317
A R Karthick76a497a2017-04-12 10:59:39 -0700318 log_test.info('IGMP test verification success')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700319
320 def igmp_verify_leave(self, igmpStateList, leave_groups):
321 sendState, recvState = igmpStateList[0], igmpStateList[1]
322 ## check if the send is received for the groups
323 for g in sendState.groups:
324 tx_stats = sendState.group_map[g][0]
325 rx_stats = recvState.group_map[g][1]
326 tx = tx_stats.count
327 rx = rx_stats.count
328 assert_greater(tx, 0)
329 if g not in leave_groups:
A R Karthick76a497a2017-04-12 10:59:39 -0700330 log_test.info('Received %d packets for group %s' %(rx, g))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700331 for g in leave_groups:
332 rx = recvState.group_map[g][1].count
333 assert_equal(rx, 0)
334
A R Karthick76a497a2017-04-12 10:59:39 -0700335 log_test.info('IGMP test verification success')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700336
337 def mcast_traffic_timer(self):
338 self.mcastTraffic.stopReceives()
339
340 def send_mcast_cb(self, send_state):
341 for g in send_state.groups:
342 send_state.update(g, tx = 1)
343 return 0
344
345 ##Runs in the context of twisted reactor thread
346 def igmp_recv(self, igmpState, iface = 'veth0'):
347 p = self.recv_socket.recv()
348 try:
349 send_time = float(p.payload.load)
350 recv_time = monotonic.monotonic()
351 except:
A R Karthick76a497a2017-04-12 10:59:39 -0700352 log_test.info('Unexpected Payload received: %s' %p.payload.load)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700353 return 0
A R Karthick76a497a2017-04-12 10:59:39 -0700354 #log_test.info( 'Recv in %.6f secs' %(recv_time - send_time))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700355 igmpState.update(p.dst, rx = 1, t = recv_time - send_time)
356 return 0
357
358 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 +0000359 ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1, ip_src = None):
ChetanGaonker3441faf2016-10-27 12:15:21 -0700360 if ssm_load is True:
361 self.onos_ssm_table_load(groups, src_list)
362 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
363 gaddr=self.IP_DST)
364 for g in groups:
365 gr = IGMPv3gr(rtype= record_type, mcaddr=g)
366 gr.sources = src_list
367 igmp.grps.append(gr)
368 if ip_pkt is None:
Thangavelu K Sef6f0a52016-12-14 19:57:05 +0000369 if ip_src is None:
370 ip_pkt = self.igmp_eth/self.igmp_ip
371 else:
372 igmp_ip_src = IP(dst = self.IP_DST, src = ip_src)
373 ip_pkt = self.igmp_eth/igmp_ip_src
ChetanGaonker3441faf2016-10-27 12:15:21 -0700374 pkt = ip_pkt/igmp
375 IGMPv3.fixup(pkt)
376 sendp(pkt, iface=iface)
377 if delay != 0:
378 time.sleep(delay)
379
ChetanGaonkerfc7b0302016-11-10 08:45:56 -0800380
381 def send_igmp_join_negative(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE,
382 ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1, ip_src = None, invalid_igmp_join = None ):
383 if ssm_load is True:
384 self.onos_ssm_table_load(groups, src_list)
385 if invalid_igmp_join == 'igmp_type':
386 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT_NEGATIVE, max_resp_code=30,
387 gaddr=self.IP_DST)
388 else:
389 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
390 gaddr=self.IP_DST)
391 if invalid_igmp_join == 'record_type':
392 record_type = IGMP_V3_GR_TYPE_INCLUDE_NEGATIVE
393
394 for g in groups:
395 gr = IGMPv3gr(rtype= record_type, mcaddr=g)
396 gr.sources = src_list
397 igmp.grps.append(gr)
398 if ip_pkt is None:
399 if ip_src is None:
400 ip_pkt = self.igmp_eth/self.igmp_ip
401 else:
402 igmp_ip_src = IP(dst = self.IP_DST, src = ip_src)
403 ip_pkt = self.igmp_eth/igmp_ip_src
404 pkt = ip_pkt/igmp
405 if invalid_igmp_join == 'ttl':
406 set_ttl = 10
407 IGMPv3.fixup(pkt,invalid_ttl = set_ttl)
408 else:
409 IGMPv3.fixup(pkt)
410 sendp(pkt, iface=iface)
411 if delay != 0:
412 time.sleep(delay)
413
ChetanGaonker3441faf2016-10-27 12:15:21 -0700414 def send_igmp_join_recvQuery(self, groups, rec_queryCount = None, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
415 self.onos_ssm_table_load(groups, src_list)
416 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
417 gaddr=self.IP_DST)
418 for g in groups:
419 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g)
420 gr.sources = src_list
421 gr.sources = src_list
422 igmp.grps.append(gr)
423 if ip_pkt is None:
424 ip_pkt = self.igmp_eth/self.igmp_ip
425 pkt = ip_pkt/igmp
426 IGMPv3.fixup(pkt)
427 if rec_queryCount == None:
A R Karthick76a497a2017-04-12 10:59:39 -0700428 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 -0700429 resp = srp1(pkt, iface=iface)
430 else:
A R Karthick76a497a2017-04-12 10:59:39 -0700431 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 -0700432 resp = srp1(pkt, iface=iface)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700433 resp[0].summary()
A R Karthick76a497a2017-04-12 10:59:39 -0700434 log_test.info('Sent IGMP join for group %s and received a query packet and printing packet' %groups)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700435 if delay != 0:
436 time.sleep(delay)
437
438 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 -0700439 log_test.info('entering into igmp leave function')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700440 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
441 gaddr=self.IP_DST)
442 for g in groups:
443 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
444 gr.sources = src_list
445 igmp.grps.append(gr)
446 if ip_pkt is None:
447 ip_pkt = self.igmp_eth/self.igmp_ip
448 pkt = ip_pkt/igmp
449 IGMPv3.fixup(pkt)
450 sendp(pkt, iface = iface)
451 if delay != 0:
452 time.sleep(delay)
453
454 def send_igmp_leave_listening_group_specific_query(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
455 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
456 gaddr=self.IP_DST)
457 for g in groups:
458 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
459 gr.sources = src_list
460 igmp.grps.append(gr)
461 if ip_pkt is None:
462 ip_pkt = self.igmp_eth/self.igmp_ip
463 pkt = ip_pkt/igmp
464 IGMPv3.fixup(pkt)
A R Karthick76a497a2017-04-12 10:59:39 -0700465 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 -0700466 resp = srp1(pkt, iface=iface)
467 resp[0].summary()
A R Karthick76a497a2017-04-12 10:59:39 -0700468 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 -0700469 if delay != 0:
470 time.sleep(delay)
471
472 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+390)
473 def test_netCondition_with_delay_between_igmp_join_and_data_recv(self):
474 self.setUp_igmp()
475 randomDelay = randint(10,300)
476 groups = ['224.0.1.1', '225.0.0.1']
477 self.onos_ssm_table_load(groups)
478 df = defer.Deferred()
479 igmpState = IGMPTestState(groups = groups, df = df)
480 igmpStateRecv = IGMPTestState(groups = groups, df = df)
481 igmpStateList = (igmpState, igmpStateRecv)
482 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, arg = igmpState)
483 self.df = df
484 self.mcastTraffic = mcastTraffic
485 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
486
487 def mcast_traffic_delay_start():
488 mcastTraffic.start()
489
490 def igmp_srp_task(stateList):
491 igmpSendState, igmpRecvState = stateList
492 if not mcastTraffic.isRecvStopped():
493 result = self.igmp_recv(igmpRecvState)
494 reactor.callLater(0, igmp_srp_task, stateList)
495 else:
496 self.mcastTraffic.stop()
497 self.recv_socket.close()
498 self.igmp_verify_join(stateList)
499 self.df.callback(0)
500
501 self.send_igmp_join(groups)
A R Karthick76a497a2017-04-12 10:59:39 -0700502 log_test.info('Holding multicast data for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700503 t = Timer(randomDelay, mcast_traffic_delay_start)
504 t.start()
505
506 self.test_timer = reactor.callLater(randomDelay+30, self.mcast_traffic_timer)
507 reactor.callLater(randomDelay+10, igmp_srp_task, igmpStateList)
508 return df
509
510 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+390)
511 def test_netCondition_with_delay_between_data_recv_and_igmp_join(self):
512 self.setUp_igmp()
513 randomDelay = randint(10,300)
514 groups = ['224.0.1.1', '225.0.0.1']
515 self.onos_ssm_table_load(groups)
516 df = defer.Deferred()
517 igmpState = IGMPTestState(groups = groups, df = df)
518 igmpStateRecv = IGMPTestState(groups = groups, df = df)
519 igmpStateList = (igmpState, igmpStateRecv)
520 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, arg = igmpState)
521 self.df = df
522 self.mcastTraffic = mcastTraffic
523 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
524
525 def mcast_join_delay_start():
A R Karthick76a497a2017-04-12 10:59:39 -0700526 log_test.info('Holding channel join for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700527 self.send_igmp_join(groups)
528
529 def igmp_srp_task(stateList):
530 igmpSendState, igmpRecvState = stateList
531 if not mcastTraffic.isRecvStopped():
532 result = self.igmp_recv(igmpRecvState)
533 reactor.callLater(0, igmp_srp_task, stateList)
534 else:
535 self.mcastTraffic.stop()
536 self.recv_socket.close()
537 self.igmp_verify_join(stateList)
538 self.df.callback(0)
539
540 mcastTraffic.start()
541 t = Timer(randomDelay, mcast_join_delay_start)
542 t.start()
543
544 self.test_timer = reactor.callLater(randomDelay+30, self.mcast_traffic_timer)
545 reactor.callLater(randomDelay+10, igmp_srp_task, igmpStateList)
546 return df
547
548
549 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+340)
550 def test_netCondition_with_delay_between_igmp_leave_and_data(self):
551 self.setUp_igmp()
552 randomDelay = randint(10,300)
553 groups = ['224.0.1.10', '225.0.0.10']
554 leave_groups = ['224.0.1.10']
555 self.onos_ssm_table_load(groups)
556 df = defer.Deferred()
557 igmpState = IGMPTestState(groups = groups, df = df)
558 igmpStateRecv = IGMPTestState(groups = groups, df = df)
559 igmpStateList = (igmpState, igmpStateRecv)
560 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
561 arg = igmpState)
562 self.df = df
563 self.mcastTraffic = mcastTraffic
564 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
565
566 def mcast_leave_delay_start():
567 self.send_igmp_leave(leave_groups, delay = 3)
568 join_state = IGMPTestState(groups = leave_groups)
569 status = self.igmp_not_recv_task(self.V_INF1,leave_groups, join_state)
A R Karthick76a497a2017-04-12 10:59:39 -0700570 log_test.info('Verified status for igmp recv task %s'%status)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700571 assert status == 1 , 'EXPECTED RESULT'
572 self.df.callback(0)
573
574 mcastTraffic.start()
575 self.send_igmp_join(groups)
A R Karthick76a497a2017-04-12 10:59:39 -0700576 log_test.info('Holding multicast leave packet for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700577 t = Timer(randomDelay+10, mcast_leave_delay_start)
578 t.start()
579 return df
580
581 def igmp_not_recv_task(self, intf, groups, join_state):
A R Karthick76a497a2017-04-12 10:59:39 -0700582 log_test.info('Entering igmp not recv task loop')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700583 recv_socket = L2Socket(iface = intf, type = ETH_P_IP)
584 group_map = {}
585 for g in groups:
586 group_map[g] = [0,0]
587
A R Karthick76a497a2017-04-12 10:59:39 -0700588 log_test.info('Verifying join interface should not receive any multicast data')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700589 self.NEGATIVE_TRAFFIC_STATUS = 1
590 def igmp_recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700591 log_test.info('Multicast packet %s received for left groups %s' %(pkt[IP].dst, groups))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700592 self.NEGATIVE_TRAFFIC_STATUS = 2
593 sniff(prn = igmp_recv_cb, count = 1, lfilter = lambda p: IP in p and p[IP].dst in groups,
594 timeout = 3, opened_socket = recv_socket)
595 recv_socket.close()
596 return self.NEGATIVE_TRAFFIC_STATUS
597
598 ## Its sample test case based on this test case we had added all below scenarios.
599 @deferred(TEST_TIMEOUT_DELAY+50)
600 def test_netCondition_in_eap_tls_with_delay_between_positive_IdReq_and_tlsHelloReq(self):
601 self.setUp_tls()
602 randomDelay = randint(10,300)
603 df = defer.Deferred()
604 tls = TLSAuthTest()
605 def eap_tls_eapTlsHelloReq_pkt_delay():
606 tls._eapTlsHelloReq()
607 tls._eapTlsCertReq()
608 tls._eapTlsChangeCipherSpec()
609 tls._eapTlsFinished()
610 df.callback(0)
611 def eap_tls_verify(df):
612 tls._eapSetup()
613 tls.tlsEventTable.EVT_EAP_SETUP
614 tls._eapStart()
615 tls.tlsEventTable.EVT_EAP_START
616 tls._eapIdReq()
617 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -0700618 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700619 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
620 t.start()
621 reactor.callLater(0, eap_tls_verify, df)
622 return df
623
624 @deferred(TEST_TIMEOUT_DELAY+50)
625 def test_netCondition_in_eap_tls_with_delay_between_IdReq_and_tlsHelloReq(self):
626 self.setUp_tls()
627 randomDelay = randint(10,300)
628 df = defer.Deferred()
629 tls = TLSAuthTest()
630 def eap_tls_eapTlsHelloReq_pkt_delay():
A R Karthick76a497a2017-04-12 10:59:39 -0700631 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700632 tls._eapTlsHelloReq()
633 tls._eapTlsCertReq()
634 tls._eapTlsChangeCipherSpec()
635 tls._eapTlsFinished()
636 df.callback(0)
637 def eap_tls_verify(df):
638 tls._eapSetup()
639 tls.tlsEventTable.EVT_EAP_SETUP
640 tls._eapStart()
641 tls.tlsEventTable.EVT_EAP_START
642 tls._eapIdReq()
643 tls.tlsEventTable.EVT_EAP_ID_REQ
644 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
645 t.start()
646 reactor.callLater(0, eap_tls_verify, df)
647 return df
648
649 @deferred(TEST_TIMEOUT_DELAY+100)
650 def test_netCondition_in_eap_tls_with_delay_between_tlsHelloReq_and_eapTlsCertReq(self):
651 self.setUp_tls()
652 randomDelay = randint(10,300)
653 df = defer.Deferred()
654 tls = TLSAuthTest()
655 def eap_tls_eapTlsCertReq_pkt_delay():
A R Karthick76a497a2017-04-12 10:59:39 -0700656 log_test.info('Holding eapTlsCertReq packet for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700657 tls._eapTlsCertReq_delay()
658 tls._eapTlsChangeCipherSpec()
659 tls._eapTlsFinished()
660 df.callback(0)
661 def eap_tls_verify(df):
662 tls._eapSetup()
663 tls.tlsEventTable.EVT_EAP_SETUP
664 tls._eapStart()
665 tls.tlsEventTable.EVT_EAP_START
666 tls._eapIdReq()
667 tls.tlsEventTable.EVT_EAP_ID_REQ
668 tls._eapTlsHelloReq()
669 while tls.server_hello_done_received == False:
670 r = tls.eapol_scapy_recv(cb = tls.eapol_server_hello_cb,
671 lfilter =
672 lambda pkt: EAP in pkt and pkt[EAP].type == EAP_TYPE_TLS and \
673 pkt[EAP].code == EAP.REQUEST)
674 if len(r) == 0:
675 tls.tlsFail()
676 t = Timer(randomDelay, eap_tls_eapTlsCertReq_pkt_delay)
677 t.start()
678 reactor.callLater(0, eap_tls_verify, df)
679 return df
680
681 @deferred(TEST_TIMEOUT_DELAY+50)
682 def test_netCondition_in_eap_tls_with_delay_between_TlsCertReq_and_TlsChangeCipherSpec(self):
683 self.setUp_tls()
684 randomDelay = randint(10,300)
685 df = defer.Deferred()
686 tls = TLSAuthTest()
687 def eap_tls_TlsChangeCipherSpec_pkt_delay():
A R Karthick76a497a2017-04-12 10:59:39 -0700688 log_test.info('Holding TlsChangeCipherSpec packet for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700689 tls._eapTlsChangeCipherSpec()
690 tls._eapTlsFinished()
691 df.callback(0)
692 def eap_tls_verify(df):
693 tls._eapSetup()
694 tls.tlsEventTable.EVT_EAP_SETUP
695 tls._eapStart()
696 tls.tlsEventTable.EVT_EAP_START
697 tls._eapIdReq()
698 tls.tlsEventTable.EVT_EAP_ID_REQ
699 tls._eapTlsHelloReq()
700 tls._eapTlsCertReq()
701 t = Timer(randomDelay, eap_tls_TlsChangeCipherSpec_pkt_delay)
702 t.start()
703 reactor.callLater(0, eap_tls_verify, df)
704 return df
705
706 @deferred(TEST_TIMEOUT_DELAY+50)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -0800707 def test_netCondition_in_eap_tls_with_no_cert_and_delay_between_IdReq_and_HelloReq(self):
ChetanGaonker3441faf2016-10-27 12:15:21 -0700708 self.setUp_tls()
709 randomDelay = randint(10,300)
710 df = defer.Deferred()
711 def tls_no_cert_cb():
A R Karthick76a497a2017-04-12 10:59:39 -0700712 log_test.info('TLS authentication failed with no certificate')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700713 tls = TLSAuthTest(fail_cb = tls_no_cert_cb, client_cert = '')
714 def eap_tls_eapTlsHelloReq_pkt_delay():
A R Karthick76a497a2017-04-12 10:59:39 -0700715 log_test.info('Holding HelloReq packet with no cert for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700716 tls._eapTlsHelloReq()
717 tls._eapTlsCertReq()
718 assert_equal(tls.failTest, True)
719 tls._eapTlsChangeCipherSpec()
720 tls._eapTlsFinished()
721 df.callback(0)
722 def eap_tls_no_cert(df):
723 tls._eapSetup()
724 tls.tlsEventTable.EVT_EAP_SETUP
725 tls._eapStart()
726 tls.tlsEventTable.EVT_EAP_START
727 tls._eapIdReq()
728 tls.tlsEventTable.EVT_EAP_ID_REQ
729 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
730 t.start()
731 reactor.callLater(0, eap_tls_no_cert, df)
732 return df
733
734 @deferred(TEST_TIMEOUT_DELAY+100)
735 def test_netCondition_in_eap_tls_with_delay_and_no_cert_between_tlsHelloReq_and_eapTlsCertReq(self):
736 self.setUp_tls()
737 randomDelay = randint(10,300)
738 df = defer.Deferred()
739 def tls_no_cert_cb():
A R Karthick76a497a2017-04-12 10:59:39 -0700740 log_test.info('TLS authentication failed with no certificate')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700741 tls = TLSAuthTest(fail_cb = tls_no_cert_cb, client_cert = '')
742 def eap_tls_eapTlsHelloReq_pkt_delay():
A R Karthick76a497a2017-04-12 10:59:39 -0700743 log_test.info('Holding eapTlsCertReq packet with no cert for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700744 tls._eapTlsCertReq_delay()
745 assert_equal(tls.failTest, True)
746 tls._eapTlsChangeCipherSpec()
747 assert_equal(tls.failTest, True)
748 tls._eapTlsFinished()
749 df.callback(0)
750 def eap_tls_no_cert(df):
751 tls._eapSetup()
752 tls.tlsEventTable.EVT_EAP_SETUP
753 tls._eapStart()
754 tls.tlsEventTable.EVT_EAP_START
755 tls._eapIdReq()
756 tls.tlsEventTable.EVT_EAP_ID_REQ
757 tls._eapTlsHelloReq()
758 while tls.server_hello_done_received == False:
759 r = tls.eapol_scapy_recv(cb = tls.eapol_server_hello_cb,
760 lfilter =
761 lambda pkt: EAP in pkt and pkt[EAP].type == EAP_TYPE_TLS and \
762 pkt[EAP].code == EAP.REQUEST)
763 if len(r) == 0:
764 tls.tlsFail()
765 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
766 t.start()
767 reactor.callLater(0, eap_tls_no_cert, df)
768 return df
769
770
771 @deferred(TEST_TIMEOUT_DELAY+50)
772 def test_netCondition_in_eap_tls_with_delay_and_no_cert_between_TlsCertReq_and_TlsChangeCipherSpec(self):
773 self.setUp_tls()
774 randomDelay = randint(10,300)
775 df = defer.Deferred()
776 def tls_no_cert_cb():
A R Karthick76a497a2017-04-12 10:59:39 -0700777 log_test.info('TLS authentication failed with no certificate')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700778 tls = TLSAuthTest(fail_cb = tls_no_cert_cb, client_cert = '')
779 def eap_tls_TlsChangeCipherSpec_pkt_delay():
780 tls._eapTlsChangeCipherSpec()
781 assert_equal(tls.failTest, True)
782 tls._eapTlsFinished()
783 df.callback(0)
784 def eap_tls_no_cert(df):
785 tls._eapSetup()
786 tls.tlsEventTable.EVT_EAP_SETUP
787 tls._eapStart()
788 tls._eapIdReq()
789 tls.tlsEventTable.EVT_EAP_ID_REQ
790 tls._eapTlsHelloReq()
791 tls._eapTlsCertReq()
A R Karthick76a497a2017-04-12 10:59:39 -0700792 log_test.info('Holding TlsChangeCipherSpec packet with no cert for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700793 t = Timer(randomDelay, eap_tls_TlsChangeCipherSpec_pkt_delay)
794 t.start()
795 reactor.callLater(0, eap_tls_no_cert, df)
796 return df
797
798 @deferred(TEST_TIMEOUT_DELAY+50)
799 def test_netCondition_in_eap_tls_with_invalid_cert_and_delay_between_IdReq_and_HelloReq(self):
800 self.setUp_tls()
801 randomDelay = randint(10,300)
802 df = defer.Deferred()
803 def tls_invalid_cert_cb():
A R Karthick76a497a2017-04-12 10:59:39 -0700804 log_test.info('TLS authentication failed with invalid certificate')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700805 tls = TLSAuthTest(fail_cb = tls_invalid_cert_cb, client_cert = self.CLIENT_CERT_INVALID)
806 def eap_tls_eapTlsHelloReq_pkt_delay():
807 tls._eapTlsHelloReq()
808 tls._eapTlsCertReq()
809 assert_equal(tls.failTest, True)
810 tls._eapTlsChangeCipherSpec()
811 tls._eapTlsFinished()
812 df.callback(0)
813 def eap_tls_invalid_cert(df):
814 tls._eapSetup()
815 tls.tlsEventTable.EVT_EAP_SETUP
816 tls._eapStart()
817 tls.tlsEventTable.EVT_EAP_START
818 tls._eapIdReq()
819 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -0700820 log_test.info('Holding HelloReq packet with invalid cert for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700821 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
822 t.start()
823 reactor.callLater(0, eap_tls_invalid_cert, df)
824 return df
825
826 @deferred(TEST_TIMEOUT_DELAY+100)
827 def test_netCondition_in_eap_tls_with_invalid_cert_and_delay_between_tlsHelloReq_and_eapTlsCertReq(self):
828 self.setUp_tls()
829 randomDelay = randint(10,300)
830 df = defer.Deferred()
831 def tls_invalid_cert_cb():
A R Karthick76a497a2017-04-12 10:59:39 -0700832 log_test.info('TLS authentication failed with invalid certificate')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700833 tls = TLSAuthTest(fail_cb = tls_invalid_cert_cb, client_cert = self.CLIENT_CERT_INVALID)
834 def eap_tls_eapTlsHelloReq_pkt_delay():
A R Karthick76a497a2017-04-12 10:59:39 -0700835 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 -0700836 tls._eapTlsCertReq_delay()
837 tls._eapTlsChangeCipherSpec()
838 assert_equal(tls.failTest, True)
839 tls._eapTlsFinished()
840 df.callback(0)
841 def eap_tls_invalid_cert(df):
842 tls._eapSetup()
843 tls.tlsEventTable.EVT_EAP_SETUP
844 tls._eapStart()
845 tls.tlsEventTable.EVT_EAP_START
846 tls._eapIdReq()
847 tls.tlsEventTable.EVT_EAP_ID_REQ
848 tls._eapTlsHelloReq()
849 while tls.server_hello_done_received == False:
850 r = tls.eapol_scapy_recv(cb = tls.eapol_server_hello_cb,
851 lfilter =
852 lambda pkt: EAP in pkt and pkt[EAP].type == EAP_TYPE_TLS and \
853 pkt[EAP].code == EAP.REQUEST)
854 if len(r) == 0:
855 tls.tlsFail()
856
A R Karthick76a497a2017-04-12 10:59:39 -0700857 log_test.info('Holding eapTlsCertReq packet with invalid cert for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700858 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
859 t.start()
860 reactor.callLater(0, eap_tls_invalid_cert, df)
861 return df
862
863
864 @deferred(TEST_TIMEOUT_DELAY+50)
865 def test_netCondition_in_eap_tls_with_invalid_cert_delay_between_TlsCertReq_and_TlsChangeCipherSpec(self):
866 self.setUp_tls()
867 randomDelay = randint(10,300)
868 df = defer.Deferred()
869 def tls_invalid_cert_cb():
A R Karthick76a497a2017-04-12 10:59:39 -0700870 log_test.info('TLS authentication failed with invalid certificate')
ChetanGaonker3441faf2016-10-27 12:15:21 -0700871 tls = TLSAuthTest(fail_cb = tls_invalid_cert_cb, client_cert = self.CLIENT_CERT_INVALID)
872 def eap_tls_TlsChangeCipherSpec_pkt_delay():
873 tls._eapTlsChangeCipherSpec()
874 assert_equal(tls.failTest, True)
875 tls._eapTlsFinished()
876 df.callback(0)
877 def eap_tls_invalid_cert(df):
878 tls._eapSetup()
879 tls.tlsEventTable.EVT_EAP_SETUP
880 tls._eapStart()
881 tls.tlsEventTable.EVT_EAP_START
882 tls._eapIdReq()
883 tls.tlsEventTable.EVT_EAP_ID_REQ
884 tls._eapTlsHelloReq()
885 tls._eapTlsCertReq()
A R Karthick76a497a2017-04-12 10:59:39 -0700886 log_test.info('Holding TlsChangeCipherSpec packet with invalid cert for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700887 t = Timer(randomDelay, eap_tls_TlsChangeCipherSpec_pkt_delay)
888 t.start()
889 reactor.callLater(0, eap_tls_invalid_cert, df)
890 return df
891
892 @deferred(TEST_TIMEOUT_DELAY+50)
893 def test_netCondition_in_multiple_eap_tls_requests_with_delay_between_IdReq_and_HelloReq(self):
894 self.setUp_tls()
895 df = defer.Deferred()
896 threads = []
897 clients = 10
898 def eap_tls_eapTlsHelloReq_pkt_delay(df):
899 def multiple_tls_random_delay():
900 randomDelay = randint(10,300)
901 tls = TLSAuthTest(src_mac = 'random')
902 tls._eapSetup()
903 tls.tlsEventTable.EVT_EAP_SETUP
904 tls._eapStart()
905 tls.tlsEventTable.EVT_EAP_START
906 tls._eapIdReq()
907 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -0700908 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -0700909 time.sleep(randomDelay)
910 tls._eapTlsHelloReq()
911 tls._eapTlsCertReq()
912 tls._eapTlsChangeCipherSpec()
913 tls._eapTlsFinished()
A R Karthick76a497a2017-04-12 10:59:39 -0700914 log_test.info('Authentication successful for user %d'%i)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700915 # Sending multiple tls clients and making random delay in between client and server packets.
916 for i in xrange(clients):
917 thread = threading.Thread(target = multiple_tls_random_delay)
918 time.sleep(randint(1,2))
919 thread.start()
920 threads.append(thread)
921 time.sleep(300)
922 for thread in threads:
923 thread.join()
ChetanGaonker3441faf2016-10-27 12:15:21 -0700924 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
925 return df
926
927 @deferred(TEST_TIMEOUT_DELAY+450)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -0800928 def test_netCondition_with_multiple_authentication_and_delay_between_complete_authentication(self):
ChetanGaonker3441faf2016-10-27 12:15:21 -0700929 self.setUp_tls()
930 df = defer.Deferred()
931 threads = []
932 clients = 100
933 def eap_tls_eapTlsHelloReq_pkt_delay(df):
934 def multiple_tls_random_delay():
935 randomDelay = randint(10,300)
936 tls = TLSAuthTest(src_mac = 'random')
937 tls._eapSetup()
938 tls.tlsEventTable.EVT_EAP_SETUP
939 tls._eapStart()
940 tls.tlsEventTable.EVT_EAP_START
941 tls._eapIdReq()
942 tls.tlsEventTable.EVT_EAP_ID_REQ
943 tls._eapTlsHelloReq()
944 tls._eapTlsCertReq()
945 tls._eapTlsChangeCipherSpec()
946 tls._eapTlsFinished()
A R Karthick76a497a2017-04-12 10:59:39 -0700947 log_test.info('Authentication successful for user %d'%i)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700948 # Client authendicating multiple times one after other and making random delay in between authendication.
949 for i in xrange(clients):
ChetanGaonker3441faf2016-10-27 12:15:21 -0700950 multiple_tls_random_delay()
951 time.sleep(randomDelay)
952 df.callback(0)
953 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
954 return df
955
956 @deferred(TEST_TIMEOUT_DELAY+450)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -0800957 def test_netCondition_with_multiple_authentication_and_delay_between_every_100_tls_burst(self):
ChetanGaonker3441faf2016-10-27 12:15:21 -0700958 self.setUp_tls()
959 randomDelay = randint(10,300)
960 df = defer.Deferred()
961 threads = []
962 tls = []
963 clients = 10
964 def eap_tls_eapTlsHelloReq_pkt_delay(df):
965 def multiple_tls_random_delay():
ChetanGaonker3441faf2016-10-27 12:15:21 -0700966 for x in xrange(clients):
967 tls.append(TLSAuthTest(src_mac = 'random'))
968 for x in xrange(clients):
969 tls[x]._eapSetup()
970 tls[x].tlsEventTable.EVT_EAP_SETUP
971 for x in xrange(clients):
972 tls[x]._eapStart()
973 tls[x].tlsEventTable.EVT_EAP_START
974 for x in xrange(clients):
975 tls[x]._eapIdReq()
976 tls[x].tlsEventTable.EVT_EAP_ID_REQ
977 for x in xrange(clients):
978 tls[x]._eapTlsHelloReq()
979 for x in xrange(clients):
980 tls[x]._eapTlsCertReq()
981 for x in xrange(clients):
982 tls[x]._eapTlsChangeCipherSpec()
983 for x in xrange(clients):
984 tls[x]._eapTlsFinished()
985 for x in xrange(clients):
A R Karthick76a497a2017-04-12 10:59:39 -0700986 log_test.info('Authentication successful for user %d'%i)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700987 # Client authendicating multiple times one after other and making random delay in between authendication.
988 for i in xrange(2):
989 multiple_tls_random_delay()
990 time.sleep(randomDelay)
991 df.callback(0)
992 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
993 return df
994
995 @deferred(TEST_TIMEOUT_DELAY+90)
996 def test_netCondition_with_delay_between_mac_flow_and_traffic(self):
997 df = defer.Deferred()
998 randomDelay = randint(10,300)
ChetanGaonker3441faf2016-10-27 12:15:21 -0700999 egress = 1
1000 ingress = 2
1001 egress_mac = '00:00:00:00:00:01'
1002 ingress_mac = '00:00:00:00:00:02'
1003 pkt = Ether(src = ingress_mac, dst = egress_mac)/IP()
1004 self.success = False
1005
1006 def mac_recv_task():
1007 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001008 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonker3441faf2016-10-27 12:15:21 -07001009 self.success = True
1010 sniff(count=2, timeout=randomDelay+50, lfilter = lambda p: p.src == ingress_mac,
1011 prn = recv_cb, iface = self.port_map[egress])
1012
1013 thread = threading.Thread(target = mac_recv_task)
1014
1015 def send_flow_pkt_delay():
1016 sendp(pkt, count=50, iface = self.port_map[ingress])
1017 thread.join()
1018 assert_equal(self.success, True)
1019 df.callback(0)
1020
1021 def creating_mac_flow(df):
1022
1023 flow = OnosFlowCtrl(deviceId = self.device_id,
1024 egressPort = egress,
1025 ingressPort = ingress,
1026 ethSrc = ingress_mac,
1027 ethDst = egress_mac)
1028 result = flow.addFlow()
1029 assert_equal(result, True)
1030 ##wait for flows to be added to ONOS
1031 time.sleep(1)
1032 thread.start()
A R Karthick76a497a2017-04-12 10:59:39 -07001033 log_test.info('Holding a packet to verify if flows are active after {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -07001034 t = Timer(randomDelay, send_flow_pkt_delay)
1035 t.start()
1036 reactor.callLater(0, creating_mac_flow, df)
1037 return df
1038
1039
1040 @deferred(TEST_TIMEOUT_DELAY+90)
1041 def test_netCondition_with_delay_between_ip_flow_and_traffic(self):
1042 df = defer.Deferred()
1043 randomDelay = randint(10,300)
1044 egress = 1
1045 ingress = 2
1046 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
1047 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
1048 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
1049 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
1050 pkt = L2/L3
1051
1052 def mac_recv_task():
1053 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001054 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
ChetanGaonker3441faf2016-10-27 12:15:21 -07001055 self.success = True
1056 sniff(count=2, timeout= randomDelay + 30,
1057 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip'],
1058 prn = recv_cb, iface = self.port_map[egress])
1059
1060 thread = threading.Thread(target = mac_recv_task)
1061
1062 def send_flow_ip_pkt_delay():
1063 sendp(pkt, count=50, iface = self.port_map[ingress])
1064 thread.join()
1065 assert_equal(self.success, True)
1066 df.callback(0)
1067
1068 def creating_ip_flow(df):
1069 flow = OnosFlowCtrl(deviceId = self.device_id,
1070 egressPort = egress,
1071 ingressPort = ingress,
1072 ethType = '0x0800',
1073 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/32'),
1074 ipDst = ('IPV4_DST', egress_map['ip']+'/32')
1075 )
1076 result = flow.addFlow()
1077 assert_equal(result, True)
1078 ##wait for flows to be added to ONOS
1079 time.sleep(1)
1080 self.success = False
1081 ##wait for flows to be added to ONOS
1082 time.sleep(1)
1083 thread.start()
A R Karthick76a497a2017-04-12 10:59:39 -07001084 log_test.info('Holding a packet to verify if flows are active after {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -07001085 t = Timer(randomDelay, send_flow_ip_pkt_delay)
1086 t.start()
1087 reactor.callLater(0, creating_ip_flow, df)
1088 return df
1089
1090 @deferred(TEST_TIMEOUT_DELAY+90)
1091 def test_netCondition_with_delay_between_tcp_port_flow_and_traffic(self):
1092 df = defer.Deferred()
1093 egress = 1
1094 ingress = 2
1095 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 9500 }
1096 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 9000 }
1097 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
1098 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
1099 L4 = TCP(sport = ingress_map['tcp_port'], dport = egress_map['tcp_port'])
1100 pkt = L2/L3/L4
1101
1102 def mac_recv_task():
1103 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001104 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 -07001105 self.success = True
1106 sniff(count=2, timeout= randomDelay+30, lfilter = lambda p: TCP in p and p[TCP].dport == egress_map['tcp_port']
1107 and p[TCP].sport == ingress_map['tcp_port'], prn = recv_cb, iface = self.port_map[egress])
1108
1109 thread = threading.Thread(target = mac_recv_task)
1110
1111 def send_flow_tcp_pkt_delay():
1112 sendp(pkt, count=50, iface = self.port_map[ingress])
1113 thread.join()
1114 assert_equal(self.success, True)
ChetanGaonker3441faf2016-10-27 12:15:21 -07001115
1116 def creating_tcp_flow(df):
1117 flow = OnosFlowCtrl(deviceId = self.device_id,
1118 egressPort = egress,
1119 ingressPort = ingress,
1120 tcpSrc = ingress_map['tcp_port'],
1121 tcpDst = egress_map['tcp_port']
1122 )
1123 result = flow.addFlow()
1124 assert_equal(result, True)
1125 ##wait for flows to be added to ONOS
1126 time.sleep(1)
1127 self.success = False
1128 thread.start()
A R Karthick76a497a2017-04-12 10:59:39 -07001129 log_test.info('Holding a packet to verify if flows are active after {} sec, delay'.format(randomDelay))
ChetanGaonker12f9f422016-11-10 23:21:21 -08001130 t = Timer(randomDelay, send_flow_tcp_pkt_delay)
ChetanGaonker3441faf2016-10-27 12:15:21 -07001131 t.start()
1132 df.callback(0)
1133 reactor.callLater(0, creating_tcp_flow, df)
1134 return df
1135
1136 @deferred(TEST_TIMEOUT_DELAY+90)
1137 def test_netCondition_with_delay_between_udp_port_flow_and_traffic(self):
1138 df = defer.Deferred()
1139 randomDelay = randint(10,300)
1140 egress = 1
1141 ingress = 2
1142 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 9500 }
1143 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 9000 }
1144 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
1145 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
1146 L4 = UDP(sport = ingress_map['udp_port'], dport = egress_map['udp_port'])
1147 pkt = L2/L3/L4
1148
1149 def mac_recv_task():
1150 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001151 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 -07001152 self.success = True
1153 sniff(count=2, timeout=randomDelay + 30,
1154 lfilter = lambda p: UDP in p and p[UDP].dport == egress_map['udp_port']
1155 and p[UDP].sport == ingress_map['udp_port'], prn = recv_cb, iface = self.port_map[egress])
1156
1157 thread = threading.Thread(target = mac_recv_task)
1158
1159 def send_flow_udp_pkt_delay():
1160 sendp(pkt, count=50, iface = self.port_map[ingress])
1161 thread.join()
1162 assert_equal(self.success, True)
1163 df.callback(0)
1164
1165 def creating_udp_flow(df):
1166 flow = OnosFlowCtrl(deviceId = self.device_id,
1167 egressPort = egress,
1168 ingressPort = ingress,
1169 udpSrc = ingress_map['udp_port'],
1170 udpDst = egress_map['udp_port']
1171 )
1172 result = flow.addFlow()
1173 assert_equal(result, True)
1174 ##wait for flows to be added to ONOS
1175 time.sleep(1)
1176 self.success = False
1177 thread.start()
A R Karthick76a497a2017-04-12 10:59:39 -07001178 log_test.info('Holding a packet to verify if flows are active after {} secs'.format(randomDelay))
ChetanGaonker3441faf2016-10-27 12:15:21 -07001179 t = Timer(randomDelay, send_flow_udp_pkt_delay)
1180 t.start()
1181
1182 df.callback(0)
1183 reactor.callLater(0, creating_udp_flow, df)
1184 return df
1185
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001186 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):
1187 self.setUp_igmp()
ChetanGaonker12f9f422016-11-10 23:21:21 -08001188 randomDelay = []
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001189 groups = []
1190 sources = []
1191 subscribers_src_ip = []
1192 status = []
1193 join_threads = []
1194 delay_threads = []
1195 data_threads = []
1196 threads = []
1197 subscriber = users
1198 count = 1
1199 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = group_end_ip)
1200 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = source_list_end_ip)
1201 subscriber_sourceips = self.source_ip_range(start_ip = '20.20.0.1',end_ip = user_src_end_ip)
1202 while count<=subscriber:
1203 group = random.choice(mcastips)
1204 source = random.choice(sourceips)
1205 subscriber_sourceip = random.choice(subscriber_sourceips)
1206 if group in groups:
1207 pass
1208 else:
A R Karthick76a497a2017-04-12 10:59:39 -07001209 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 -08001210 groups.append(group)
1211 sources.append(source)
1212 subscribers_src_ip.append(subscriber_sourceip)
1213 count += 1
1214 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1215
1216 def multiple_joins_send_in_threads(group, source, subscriber_src_ip,data_pkt = data_pkt):
1217 self.send_igmp_join(groups = [group], src_list = [source],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1218 iface = self.V_INF1, ip_src = [subscriber_src_ip])
ChetanGaonker12f9f422016-11-10 23:21:21 -08001219 randomDelay_in_thread = randint(10,30)
A R Karthick76a497a2017-04-12 10:59:39 -07001220 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 -08001221 time.sleep(randomDelay_in_thread)
A R Karthick76a497a2017-04-12 10:59:39 -07001222 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 -08001223 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 -07001224 log_test.info('Data received for group %s from source %s and status is %s '%(group,source,status))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001225 self.igmp_threads_result.append(status)
1226
1227 for i in range(subscriber):
1228 thread = threading.Thread(target = multiple_joins_send_in_threads, args = (groups[i], sources[i], subscribers_src_ip[i]))
1229 time.sleep(randint(1,2))
1230 thread.start()
1231 threads.append(thread)
1232
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001233 for thread in threads:
1234 thread.join()
1235
1236 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 -07001237 log_test.info('Verifying multicast traffic for group %s from source %s'%(group,source))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001238 self.success = False
1239 def recv_task():
1240 def igmp_recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001241 #log_test.info('received multicast data packet is %s'%pkt.show())
1242 log_test.info('Multicast data received for group %s from source %s'%(group,source))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001243 self.success = True
1244 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')
1245 t = threading.Thread(target = recv_task)
1246 t.start()
1247 self.send_multicast_data_traffic_from_thread(group,source=source, data_pkt=data_pkt)
1248 t.join()
1249 if (negative is None) and self.success is True:
1250 return self.success
1251 elif (negative is not None) and self.success is True:
A R Karthick76a497a2017-04-12 10:59:39 -07001252 log_test.info('Multicast traffic should not received because this is negative scenario, but it is received')
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001253 self.success = False
1254 elif (negative is not None) and self.success is False:
A R Karthick76a497a2017-04-12 10:59:39 -07001255 log_test.info('Multicast traffic should is not received because this is negative scenario, hence status is True')
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001256 self.success = True
1257 return self.success
1258
1259 def send_multicast_data_traffic_from_thread(self, group, intf= 'veth2',source = '1.2.3.4', data_pkt = 50):
1260 dst_mac = self.iptomac_convert(group)
1261 eth = Ether(dst= dst_mac)
1262 ip = IP(dst=group,src=source)
1263 data = repr(monotonic.monotonic())
A R Karthick76a497a2017-04-12 10:59:39 -07001264 log_test.info('Sending %s number of multicast packet to the multicast group %s'%(data_pkt, group))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001265 sendp(eth/ip/data,count=data_pkt, iface = intf)
1266 pkt = (eth/ip/data)
A R Karthick76a497a2017-04-12 10:59:39 -07001267 #log_test.info('multicast traffic packet %s'%pkt.show())
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001268
1269 def iptomac_convert(self, mcast_ip):
1270 mcast_mac = '01:00:5e:'
1271 octets = mcast_ip.split('.')
1272 second_oct = int(octets[1]) & 127
1273 third_oct = int(octets[2])
1274 fourth_oct = int(octets[3])
1275 mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x')
1276 return mcast_mac
1277
1278 @deferred(TEST_TIMEOUT_DELAY+50)
1279 def test_netCondition_with_delay_between_multiple_igmp_joins_and_data_for_multiple_subscribers(self):
1280 self.setUp_tls()
1281 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001282 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001283 def netCondition_multiple_igmp_joins_and_data(df):
1284 ### 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
1285 no_users = 10
1286 group_end_ip = '229.0.30.254'
1287 source_list_end_ip = '10.10.30.254'
1288 subscriber_src_end_ip = '20.20.20.254'
1289 self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip,
1290 source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip )
A R Karthick76a497a2017-04-12 10:59:39 -07001291 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001292 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001293 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 -08001294 if assert_equal(self.igmp_threads_result[i], True) is True:
1295 df.callback(0)
1296 df.callback(0)
1297 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1298 return df
1299
1300 @deferred(TEST_TIMEOUT_DELAY+50)
1301 def test_netCondition_with_delay_between_multiple_igmp_joins_and_data_from_multiple_subscribers_with_low_multicast_data_rate(self):
1302 self.setUp_tls()
1303 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001304 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001305 def netCondition_multiple_igmp_joins_and_data(df):
1306 ### 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
1307 no_users = 10
1308 group_end_ip = '229.0.30.254'
1309 source_list_end_ip = '10.10.30.254'
1310 subscriber_src_end_ip = '20.20.20.254'
1311 self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip,
1312 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 -07001313 log_test.info('IGMP Thread status after running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001314 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001315 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 -08001316 if assert_equal(self.igmp_threads_result[i], True) is True:
1317 df.callback(0)
1318 df.callback(0)
1319 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1320 return df
1321
1322 @deferred(TEST_TIMEOUT_DELAY+50)
1323 def test_netCondition_with_delay_between_multiple_igmp_joins_and_data_for_same_subscriber(self):
1324 self.setUp_tls()
1325 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001326 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001327 def netCondition_multiple_igmp_joins_and_data(df):
1328 ### 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
1329 no_users = 5
1330 group_end_ip = '229.0.30.254'
1331 source_list_end_ip = '10.10.30.254'
1332 subscriber_src_end_ip = '20.20.0.1'
1333 self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip,
1334 source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip )
A R Karthick76a497a2017-04-12 10:59:39 -07001335 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001336 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001337 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 -08001338 if assert_equal(self.igmp_threads_result[i], True) is True:
1339 df.callback(0)
1340 df.callback(0)
1341 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1342 return df
1343
1344
1345 @deferred(TEST_TIMEOUT_DELAY+50)
1346 def test_netCondition_with_delay_between_same_igmp_joins_and_data_from_multiple_subscriber(self):
1347 self.setUp_tls()
1348 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001349 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001350 def netCondition_multiple_igmp_joins_and_data(df):
1351 ### 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
1352 no_users = 100
1353 group_end_ip = '229.0.0.1'
1354 source_list_end_ip = '10.10.30.254'
1355 subscriber_src_end_ip = '20.20.20.254'
1356 self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip,
1357 source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip )
A R Karthick76a497a2017-04-12 10:59:39 -07001358 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001359 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001360 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 -08001361 if assert_equal(self.igmp_threads_result[i], True) is True:
1362 df.callback(0)
1363 df.callback(0)
1364 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1365 return df
1366
1367 @deferred(TEST_TIMEOUT_DELAY+50)
1368 def test_netCondition_with_delay_between_multiple_igmp_joins_and_data_from_same_sourcelist_for_multiple_subscriber(self):
1369 self.setUp_tls()
1370 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001371 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001372 def netCondition_multiple_igmp_joins_and_data(df):
1373 ### 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
1374 no_users = 20
1375 group_end_ip = '229.0.30.254'
1376 source_list_end_ip = '10.10.0.1'
1377 subscriber_src_end_ip = '20.20.20.254'
1378 self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip,
1379 source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip )
A R Karthick76a497a2017-04-12 10:59:39 -07001380 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001381 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001382 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 -08001383 if assert_equal(self.igmp_threads_result[i], True) is True:
1384 df.callback(0)
1385 df.callback(0)
1386 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1387 return df
1388
1389
1390 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):
1391 self.setUp_igmp()
ChetanGaonker12f9f422016-11-10 23:21:21 -08001392 randomDelay = []
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001393 groups = []
1394 sources = []
1395 subscribers_src_ip = []
1396 status = []
1397 join_threads = []
1398 delay_threads = []
1399 data_threads = []
1400 threads = []
1401 subscriber = users
1402 count = 1
1403 j = 1
1404 negative_traffic = None
1405 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = group_end_ip)
1406 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = source_list_end_ip)
1407 subscriber_sourceips = self.source_ip_range(start_ip = '20.20.0.1',end_ip = user_src_end_ip)
1408 while count<=subscriber:
1409 group = random.choice(mcastips)
1410 source = random.choice(sourceips)
1411 subscriber_sourceip = random.choice(subscriber_sourceips)
1412 if group in groups:
1413 pass
1414 else:
A R Karthick76a497a2017-04-12 10:59:39 -07001415 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 -08001416 groups.append(group)
1417 sources.append(source)
1418 subscribers_src_ip.append(subscriber_sourceip)
1419 count += 1
1420 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001421 def multiple_joins_send_in_threads(group, source, subscriber_src_ip,invalid_igmp_join,data_pkt = data_pkt):
1422 if invalid_igmp_join is None:
1423 self.send_igmp_join(groups = [group], src_list = [source],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1424 iface = self.V_INF1, ip_src = [subscriber_src_ip])
1425 else:
1426 negative_traffic = True
1427 self.send_igmp_join_negative(groups = [group], src_list = [source],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1428 iface = self.V_INF1, ip_src = [subscriber_src_ip], invalid_igmp_join = invalid_igmp_join)
ChetanGaonker12f9f422016-11-10 23:21:21 -08001429 randomDelay_in_thread = randint(10,30)
A R Karthick76a497a2017-04-12 10:59:39 -07001430 log_test.info('This is running in thread with igmp join sent and delay {}'.format(randomDelay_in_thread))
ChetanGaonker12f9f422016-11-10 23:21:21 -08001431 time.sleep(randomDelay_in_thread)
A R Karthick76a497a2017-04-12 10:59:39 -07001432 log_test.info('This is running in thread with igmp join sent and delay {}'.format(randomDelay_in_thread))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001433 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 -07001434 log_test.info('data received for group %s from source %s and status is %s '%(group,source,status))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001435 self.igmp_threads_result.append(status)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001436 for i in range(subscriber):
1437 thread = threading.Thread(target = multiple_joins_send_in_threads, args = (groups[i], sources[i], subscribers_src_ip[i], invalid_joins))
1438 if bunch_traffic == 'yes':
1439 if j == 10:
A R Karthick76a497a2017-04-12 10:59:39 -07001440 log_test.info('Here we are throttle traffic for 100 sec of delay and agian creating igmp threads')
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001441 time.sleep(randint(100,110))
1442 j = 1
1443 else:
1444 j = j+ 1
1445 time.sleep(randint(1,2))
1446 thread.start()
1447 threads.append(thread)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001448 for thread in threads:
1449 thread.join()
1450
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001451 @deferred(TEST_TIMEOUT_DELAY+50)
1452 def test_netCondition_with_throttle_between_multiple_igmp_joins_and_data_from_multiple_subscribers(self):
1453 self.setUp_tls()
1454 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001455 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001456 def netCondition_multiple_igmp_joins_and_data(df):
1457 ### 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
1458 batch_traffic_run = 'yes'
1459 no_users = 11
1460 group_end_ip = '229.0.30.254'
1461 source_list_end_ip = '10.10.30.254'
1462 subscriber_src_end_ip = '20.20.20.254'
1463 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 -07001464 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001465 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001466 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 -08001467 if assert_equal(self.igmp_threads_result[i], True) is True:
1468 df.callback(0)
1469 df.callback(0)
1470 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1471 return df
1472
1473 @deferred(TEST_TIMEOUT_DELAY+50)
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001474 def test_netCondition_with_invalid_igmp_type_multiple_igmp_joins_and_data_from_multiple_subscribers(self):
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001475 self.setUp_tls()
1476 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001477 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001478 def netCondition_multiple_igmp_joins_and_data(df):
1479 ### 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
1480 batch_traffic_run = 'no'
1481 invalid_igmp_join = 'igmp_type'
1482 no_users = 11
1483 group_end_ip = '229.0.30.254'
1484 source_list_end_ip = '10.10.30.254'
1485 subscriber_src_end_ip = '20.20.20.254'
1486 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 -07001487 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001488 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001489 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 -08001490 if assert_equal(self.igmp_threads_result[i], True) is True:
1491 df.callback(0)
1492 df.callback(0)
1493 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1494 return df
1495
1496 @deferred(TEST_TIMEOUT_DELAY+50)
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001497 def test_netCondition_with_invalid_record_type_multiple_igmp_joins_and_data_from_multiple_subscribers(self):
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001498 self.setUp_tls()
1499 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001500 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001501 def netCondition_multiple_igmp_joins_and_data(df):
1502 ### 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
1503 batch_traffic_run = 'no'
1504 invalid_igmp_join = 'record_type'
1505 no_users = 11
1506 group_end_ip = '229.0.30.254'
1507 source_list_end_ip = '10.10.30.254'
1508 subscriber_src_end_ip = '20.20.20.254'
1509 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 -07001510 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001511 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001512 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 -08001513 if assert_equal(self.igmp_threads_result[i], True) is True:
1514 df.callback(0)
1515 df.callback(0)
1516 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1517 return df
1518
1519
1520 @deferred(TEST_TIMEOUT_DELAY+50)
1521 def test_netCondition_with_invalid_ttl_and_multiple_igmp_joins_and_data_from_multiple_subscribers(self):
1522 self.setUp_tls()
1523 df = defer.Deferred()
A R Karthick76a497a2017-04-12 10:59:39 -07001524 log_test.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001525 def netCondition_multiple_igmp_joins_and_data(df):
1526 ### 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
1527 batch_traffic_run = 'no'
1528 invalid_igmp_join = 'ttl_type'
1529 no_users = 11
1530 group_end_ip = '229.0.30.254'
1531 source_list_end_ip = '10.10.30.254'
1532 subscriber_src_end_ip = '20.20.20.254'
1533 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 -07001534 log_test.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result))
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001535 for i in xrange(no_users):
A R Karthick76a497a2017-04-12 10:59:39 -07001536 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 -08001537 if assert_equal(self.igmp_threads_result[i], True) is True:
1538 df.callback(0)
1539 df.callback(0)
1540 reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df)
1541 return df
1542
1543
1544 @deferred(TEST_TIMEOUT_DELAY-250)
1545 def test_netCondition_in_multiple_eap_tls_sessions_with_out_of_order_exchanges_between_serverHello_and_client_packet(self):
1546 self.setUp_tls()
1547 df = defer.Deferred()
1548 threads = []
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001549 clients = 100
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001550 def eap_tls_eapTlsHelloReq_pkt_delay(df):
1551 def multiple_tls_random_delay():
ChetanGaonker12f9f422016-11-10 23:21:21 -08001552 randomDelay = randint(10,300)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001553 tls = TLSAuthTest(src_mac = 'random')
1554 tls._eapSetup()
1555 tls.tlsEventTable.EVT_EAP_SETUP
1556 tls._eapStart()
1557 tls.tlsEventTable.EVT_EAP_START
1558 tls._eapIdReq()
1559 tls.tlsEventTable.EVT_EAP_ID_REQ
1560 tls._eapTlsCertReq()
1561 assert_equal(tls.failTest, True)
1562 tls._eapTlsHelloReq()
1563 assert_equal(tls.failTest, True)
1564 tls._eapTlsChangeCipherSpec()
1565 assert_equal(tls.failTest, True)
1566 tls._eapTlsFinished()
1567 assert_equal(tls.failTest, True)
A R Karthick76a497a2017-04-12 10:59:39 -07001568 log_test.info('Authentication successful for user %d'%i)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001569 # Sending multiple tls clients and making random delay in between client and server packets.
1570 for i in xrange(clients):
1571 thread = threading.Thread(target = multiple_tls_random_delay)
1572 time.sleep(randint(1,2))
1573 thread.start()
1574 threads.append(thread)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001575 for thread in threads:
1576 thread.join()
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001577 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
1578 return df
1579
1580 @deferred(TEST_TIMEOUT_DELAY-250)
1581 def test_netCondition_in_multiple_eap_tls_session_with_out_of_order_exchanges_in_eapTlsCertReq_packets(self):
1582 self.setUp_tls()
1583 df = defer.Deferred()
1584 threads = []
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001585 clients = 100
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001586 def eap_tls_eapTlsHelloReq_pkt_delay(df):
1587 def multiple_tls_random_delay():
ChetanGaonker12f9f422016-11-10 23:21:21 -08001588 randomDelay = randint(10,300)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001589 tls = TLSAuthTest(src_mac = 'random')
1590 tls._eapSetup()
1591 tls.tlsEventTable.EVT_EAP_SETUP
1592 tls._eapStart()
1593 tls.tlsEventTable.EVT_EAP_START
1594 tls._eapTlsCertReq()
1595 assert_equal(tls.failTest, True)
1596 tls._eapIdReq()
1597 tls.tlsEventTable.EVT_EAP_ID_REQ
1598 assert_equal(tls.failTest, True)
1599 tls._eapTlsCertReq()
1600 assert_equal(tls.failTest, True)
1601 tls._eapTlsHelloReq()
1602 assert_equal(tls.failTest, True)
1603 tls._eapTlsChangeCipherSpec()
1604 assert_equal(tls.failTest, True)
1605 tls._eapTlsFinished()
1606 assert_equal(tls.failTest, True)
A R Karthick76a497a2017-04-12 10:59:39 -07001607 log_test.info('Authentication successful for user %d'%i)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001608 # Sending multiple tls clients and making random delay in between client and server packets.
1609 for i in xrange(clients):
1610 thread = threading.Thread(target = multiple_tls_random_delay)
1611 time.sleep(randint(1,2))
1612 thread.start()
1613 threads.append(thread)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001614 for thread in threads:
1615 thread.join()
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001616 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
1617 return df
1618
1619 @deferred(TEST_TIMEOUT_DELAY-250)
1620 def test_netCondition_in_multiple_eap_tls_sessions_with_out_of_order_eapTlsChangeCipherSpec_packets(self):
1621 self.setUp_tls()
1622 df = defer.Deferred()
1623 threads = []
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001624 clients = 100
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001625 def eap_tls_eapTlsHelloReq_pkt_delay(df):
1626 def multiple_tls_random_delay():
ChetanGaonker12f9f422016-11-10 23:21:21 -08001627 randomDelay = randint(10,300)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001628 tls = TLSAuthTest(src_mac = 'random')
1629 tls._eapSetup()
1630 tls.tlsEventTable.EVT_EAP_SETUP
1631 tls._eapStart()
1632 tls.tlsEventTable.EVT_EAP_START
1633 tls._eapTlsChangeCipherSpec()
1634 tls.failTest = False
1635 tls._eapIdReq()
1636 tls.tlsEventTable.EVT_EAP_ID_REQ
1637 assert_equal(tls.failTest, True)
1638 tls._eapTlsHelloReq()
1639 assert_equal(tls.failTest, True)
1640 tls._eapTlsCertReq()
1641 assert_equal(tls.failTest, True)
1642 tls._eapTlsChangeCipherSpec()
1643 assert_equal(tls.failTest, True)
1644 tls._eapTlsFinished()
1645 assert_equal(tls.failTest, True)
A R Karthick76a497a2017-04-12 10:59:39 -07001646 log_test.info('Authentication successful for user %d'%i)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001647 # Sending multiple tls clients and making random delay in between client and server packets.
1648 for i in xrange(clients):
1649 thread = threading.Thread(target = multiple_tls_random_delay)
1650 time.sleep(randint(1,2))
1651 thread.start()
1652 threads.append(thread)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001653 for thread in threads:
1654 thread.join()
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001655 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
1656 return df
1657
1658 @deferred(TEST_TIMEOUT_DELAY-250)
1659 def test_netCondition_in_multiple_eap_tls_sessions_dropping_eapTlsHelloReq_packets(self):
1660 self.setUp_tls()
1661 df = defer.Deferred()
1662 threads = []
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001663 clients = 100
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001664 def eap_tls_eapTlsHelloReq_pkt_delay(df):
1665 def multiple_tls_random_delay():
ChetanGaonker12f9f422016-11-10 23:21:21 -08001666 randomDelay = randint(10,300)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001667 tls = TLSAuthTest(src_mac = 'random')
1668 tls._eapSetup()
1669 tls.tlsEventTable.EVT_EAP_SETUP
1670 tls._eapStart()
1671 tls.tlsEventTable.EVT_EAP_START
1672 tls._eapIdReq()
1673 tls.tlsEventTable.EVT_EAP_ID_REQ
1674 #tls._eapTlsHelloReq()
1675 tls._eapTlsCertReq()
1676 tls._eapTlsChangeCipherSpec()
1677 assert_equal(tls.failTest, True)
1678 tls._eapTlsFinished()
A R Karthick76a497a2017-04-12 10:59:39 -07001679 log_test.info('Authentication successful for user %d'%i)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001680 # Sending multiple tls clients and making random delay in between client and server packets.
1681 for i in xrange(clients):
1682 thread = threading.Thread(target = multiple_tls_random_delay)
1683 time.sleep(randint(1,2))
1684 thread.start()
1685 threads.append(thread)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001686 for thread in threads:
1687 thread.join()
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001688 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
1689 return df
1690
1691 @deferred(TEST_TIMEOUT_DELAY-250)
1692 def test_netCondition_in_multiple_eap_tls_sessions_dropping_eapTlsChangeCipherSpec_packets(self):
1693 self.setUp_tls()
1694 df = defer.Deferred()
1695 threads = []
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001696 clients = 100
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001697 def eap_tls_eapTlsHelloReq_pkt_delay(df):
1698 def multiple_tls_random_delay():
ChetanGaonker12f9f422016-11-10 23:21:21 -08001699 randomDelay = randint(10,300)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001700 tls = TLSAuthTest(src_mac = 'random')
1701 tls._eapSetup()
1702 tls.tlsEventTable.EVT_EAP_SETUP
1703 tls._eapStart()
1704 tls.tlsEventTable.EVT_EAP_START
1705 tls._eapIdReq()
1706 tls.tlsEventTable.EVT_EAP_ID_REQ
1707 tls._eapTlsHelloReq()
1708 tls._eapTlsCertReq()
1709 #tls._eapTlsChangeCipherSpec()
1710 assert_equal(tls.failTest, True)
1711 tls._eapTlsFinished()
A R Karthick76a497a2017-04-12 10:59:39 -07001712 log_test.info('Authentication successful for user %d'%i)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001713 # Sending multiple tls clients and making random delay in between client and server packets.
1714 for i in xrange(clients):
1715 thread = threading.Thread(target = multiple_tls_random_delay)
1716 time.sleep(randint(1,2))
1717 thread.start()
1718 threads.append(thread)
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001719 for thread in threads:
1720 thread.join()
ChetanGaonkerfc7b0302016-11-10 08:45:56 -08001721 reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df)
1722 return df
1723
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001724 @deferred(TEST_TIMEOUT_DELAY+50)
1725 def test_netCondition_in_eapol_tls_with_invalid_eapol_version_field_in_client_auth_packet(self):
1726 self.setUp_tls()
1727 randomDelay = randint(10,300)
1728 df = defer.Deferred()
1729 tls = TLSAuthTest()
1730 def eap_tls_eapTlsHelloReq_pkt_delay():
1731 tls._eapTlsHelloReq()
1732 tls._eapTlsCertReq()
1733 tls._eapTlsChangeCipherSpec()
1734 tls._eapTlsFinished()
1735 EapolPacket.eap_tls_packets_field_value_replace(invalid_field_name= 'eapolTlsVersion')
1736 df.callback(0)
1737 def eap_tls_verify(df):
1738 tls._eapSetup()
1739 tls.tlsEventTable.EVT_EAP_SETUP
1740 tls._eapStart()
1741 EapolPacket.eap_invalid_tls_packets_info(invalid_field_name= 'eapolTlsVersion', invalid_field_value= 20)
1742 tls.tlsEventTable.EVT_EAP_START
1743 tls._eapIdReq()
1744 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001745 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001746 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1747 t.start()
1748 reactor.callLater(0, eap_tls_verify, df)
1749 return df
1750
1751 @deferred(TEST_TIMEOUT_DELAY-150)
1752 def test_netCondition_in_eapol_tls_with_invalid_eapol_tls_type_field_in_client_auth_packet(self):
1753 self.setUp_tls()
1754 randomDelay = randint(10,300)
1755 df = defer.Deferred()
1756 tls = TLSAuthTest()
1757 def eap_tls_eapTlsHelloReq_pkt_delay():
1758 tls._eapTlsHelloReq()
1759 tls._eapTlsCertReq()
1760 tls._eapTlsChangeCipherSpec()
1761 tls._eapTlsFinished()
1762 EapolPacket.eap_tls_packets_field_value_replace(invalid_field_name= 'eapolTlsType')
1763 df.callback(0)
1764 def eap_tls_verify(df):
1765 tls._eapSetup()
1766 tls.tlsEventTable.EVT_EAP_SETUP
1767 tls._eapStart()
1768 EapolPacket.eap_invalid_tls_packets_info(invalid_field_name= 'eapolTlsType', invalid_field_value= 20)
1769 tls.tlsEventTable.EVT_EAP_START
1770 tls._eapIdReq()
1771 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001772 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001773 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1774 t.start()
1775 reactor.callLater(0, eap_tls_verify, df)
1776 return df
1777
1778 @deferred(TEST_TIMEOUT_DELAY-150)
1779 def test_netCondition_in_eapol_tls_with_invalid_eapol_type_ID_field_in_client_auth_packet(self):
1780 self.setUp_tls()
1781 randomDelay = randint(10,300)
1782 df = defer.Deferred()
1783 tls = TLSAuthTest()
1784 def eap_tls_eapTlsHelloReq_pkt_delay():
1785 tls._eapTlsHelloReq()
1786 tls._eapTlsCertReq()
1787 tls._eapTlsChangeCipherSpec()
1788 tls._eapTlsFinished()
1789 EapolPacket.eap_tls_packets_field_value_replace(invalid_field_name= 'eapolTypeID')
1790 df.callback(0)
1791 def eap_tls_verify(df):
1792 tls._eapSetup()
1793 tls.tlsEventTable.EVT_EAP_SETUP
1794 tls._eapStart()
1795 EapolPacket.eap_invalid_tls_packets_info(invalid_field_name= 'eapolTypeID', invalid_field_value= 20)
1796 tls.tlsEventTable.EVT_EAP_START
1797 tls._eapIdReq()
1798 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001799 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001800 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1801 t.start()
1802 reactor.callLater(0, eap_tls_verify, df)
1803 return df
1804
1805 @deferred(TEST_TIMEOUT_DELAY-150)
1806 def test_netCondition_in_eapol_tls_with_invalid_eapol_response_field_in_client_auth_packet(self):
1807 self.setUp_tls()
1808 randomDelay = randint(10,300)
1809 df = defer.Deferred()
1810 tls = TLSAuthTest()
1811 def eap_tls_eapTlsHelloReq_pkt_delay():
1812 tls._eapTlsHelloReq()
1813 tls._eapTlsCertReq()
1814 tls._eapTlsChangeCipherSpec()
1815 tls._eapTlsFinished()
1816 EapolPacket.eap_tls_packets_field_value_replace(invalid_field_name= 'eapolResponse')
1817 df.callback(0)
1818 def eap_tls_verify(df):
1819 tls._eapSetup()
1820 tls.tlsEventTable.EVT_EAP_SETUP
1821 tls._eapStart()
1822 EapolPacket.eap_invalid_tls_packets_info(invalid_field_name= 'eapolResponse', invalid_field_value= 20)
1823 tls.tlsEventTable.EVT_EAP_START
1824 tls._eapIdReq()
1825 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001826 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001827 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1828 t.start()
1829 reactor.callLater(0, eap_tls_verify, df)
1830 return df
1831
1832 @deferred(TEST_TIMEOUT_DELAY-150)
1833 def test_netCondition_in_eap_tls_with_invalid_eap_content_type_field_in_client_auth_packet(self):
1834 self.setUp_tls()
1835 randomDelay = randint(10,300)
1836 df = defer.Deferred()
1837 def tls_invalid_content_type_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07001838 log_test.info('TLS authentication failed with invalid content type in TLSContentType packet')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001839 tls = TLSAuthTest(fail_cb = tls_invalid_content_type_cb, invalid_content_type = 44)
1840 def eap_tls_eapTlsHelloReq_pkt_delay():
1841 tls._eapTlsHelloReq()
1842 tls._eapTlsCertReq()
1843 tls._eapTlsChangeCipherSpec()
1844 tls._eapTlsFinished()
1845 df.callback(0)
1846 def eap_tls_verify(df):
1847 tls._eapSetup()
1848 tls.tlsEventTable.EVT_EAP_SETUP
1849 tls._eapStart()
1850 tls.tlsEventTable.EVT_EAP_START
1851 tls._eapIdReq()
1852 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001853 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001854 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1855 t.start()
1856 reactor.callLater(0, eap_tls_verify, df)
1857 return df
1858
1859 @deferred(TEST_TIMEOUT_DELAY-250)
1860 def test_netCondition_in_eap_tls_with_invalid_tls_version_field_in_client_auth_packet(self):
1861 self.setUp_tls()
1862 randomDelay = randint(10,300)
1863 df = defer.Deferred()
1864 def tls_invalid_eap_tls_version_in_client_auth_packet():
A R Karthick76a497a2017-04-12 10:59:39 -07001865 log_test.info('TLS authentication failed with invalid tls version field in the packet')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001866 tls = TLSAuthTest(fail_cb = tls_invalid_eap_tls_version_in_client_auth_packet, version = 'TLS_2_1')
1867 def eap_tls_eapTlsHelloReq_pkt_delay():
1868 tls._eapTlsHelloReq()
1869 tls._eapTlsCertReq()
1870 tls._eapTlsChangeCipherSpec()
1871 tls._eapTlsFinished()
1872 df.callback(0)
1873 def eap_tls_verify(df):
1874 tls._eapSetup()
1875 tls.tlsEventTable.EVT_EAP_SETUP
1876 tls._eapStart()
1877 tls.tlsEventTable.EVT_EAP_START
1878 tls._eapIdReq()
1879 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001880 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001881 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1882 t.start()
1883 reactor.callLater(0, eap_tls_verify, df)
1884 return df
1885
1886 @deferred(TEST_TIMEOUT_DELAY-250)
1887 def test_netCondition_in_eap_tls_with_invalid_tls_cipher_suite_field_in_client_auth_packet(self):
1888 self.setUp_tls()
1889 randomDelay = randint(10,300)
1890 df = defer.Deferred()
1891 def tls_with_invalid_tls_cipher_suite_field_in_client_auth_packet_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07001892 log_test.info('TLS authentication failed with invalid tls cipher suite field in the packet')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001893 tls = TLSAuthTest(fail_cb = tls_with_invalid_tls_cipher_suite_field_in_client_auth_packet_cb, cipher_suite = 'RSA_WITH_AES_512_CBC_SHA')
1894 def eap_tls_eapTlsHelloReq_pkt_delay():
1895 tls._eapTlsHelloReq()
1896 tls._eapTlsCertReq()
1897 tls._eapTlsChangeCipherSpec()
1898 tls._eapTlsFinished()
1899 df.callback(0)
1900 def eap_tls_verify(df):
1901 tls._eapSetup()
1902 tls.tlsEventTable.EVT_EAP_SETUP
1903 tls._eapStart()
1904 tls.tlsEventTable.EVT_EAP_START
1905 tls._eapIdReq()
1906 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001907 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001908 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1909 t.start()
1910 reactor.callLater(0, eap_tls_verify, df)
1911 return df
1912
1913 @deferred(TEST_TIMEOUT_DELAY-150)
1914 def test_netCondition_in_eap_tls_with_id_mismatch_in_identifier_field_in_client_auth_packet(self):
1915 self.setUp_tls()
1916 randomDelay = randint(10,300)
1917 df = defer.Deferred()
1918 def tls_with_invalid_id_in_identifier_response_packet_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07001919 log_test.info('TLS authentication failed with invalid id in identifier packet')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001920 tls = TLSAuthTest(fail_cb = tls_with_invalid_id_in_identifier_response_packet_cb,
1921 id_mismatch_in_identifier_response_packet = True)
1922 def eap_tls_eapTlsHelloReq_pkt_delay():
1923 tls._eapTlsHelloReq()
1924 tls._eapTlsCertReq()
1925 tls._eapTlsChangeCipherSpec()
1926 tls._eapTlsFinished()
1927 df.callback(0)
1928 def eap_tls_verify(df):
1929 tls._eapSetup()
1930 tls.tlsEventTable.EVT_EAP_SETUP
1931 tls._eapStart()
1932 tls.tlsEventTable.EVT_EAP_START
1933 tls._eapIdReq()
1934 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001935 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001936 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1937 t.start()
1938 reactor.callLater(0, eap_tls_verify, df)
1939 return df
1940
1941 @deferred(TEST_TIMEOUT_DELAY-150)
1942 def test_netCondition_in_eap_tls_with_id_mismatch_in_client_hello_auth_packet(self):
1943 self.setUp_tls()
1944 randomDelay = randint(10,300)
1945 df = defer.Deferred()
1946 def tls_with_invalid_id_in_client_hello_packet_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07001947 log_test.info('TLS authentication failed with invalid id in client hello packet')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001948 tls = TLSAuthTest(fail_cb = tls_with_invalid_id_in_client_hello_packet_cb,
1949 id_mismatch_in_client_hello_packet = True)
1950
1951 def eap_tls_eapTlsHelloReq_pkt_delay():
1952 tls._eapTlsHelloReq()
1953 tls._eapTlsCertReq()
1954 tls._eapTlsChangeCipherSpec()
1955 tls._eapTlsFinished()
1956 df.callback(0)
1957 def eap_tls_verify(df):
1958 tls._eapSetup()
1959 tls.tlsEventTable.EVT_EAP_SETUP
1960 tls._eapStart()
1961 tls.tlsEventTable.EVT_EAP_START
1962 tls._eapIdReq()
1963 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001964 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001965 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1966 t.start()
1967 reactor.callLater(0, eap_tls_verify, df)
1968 return df
1969
1970 @deferred(TEST_TIMEOUT_DELAY-150)
1971 def test_netCondition_in_eap_tls_with_invalid_client_hello_handshake_type_auth_packet(self):
1972 self.setUp_tls()
1973 randomDelay = randint(10,300)
1974 df = defer.Deferred()
1975 def tls_incorrect_handshake_type_client_hello_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07001976 log_test.info('TLS authentication failed with incorrect handshake type in client hello packet')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001977 tls = TLSAuthTest(fail_cb = tls_incorrect_handshake_type_client_hello_cb, invalid_client_hello_handshake_type=True)
1978 def eap_tls_eapTlsHelloReq_pkt_delay():
1979 tls._eapTlsHelloReq()
1980 tls._eapTlsCertReq()
1981 tls._eapTlsChangeCipherSpec()
1982 tls._eapTlsFinished()
1983 df.callback(0)
1984 def eap_tls_verify(df):
1985 tls._eapSetup()
1986 tls.tlsEventTable.EVT_EAP_SETUP
1987 tls._eapStart()
1988 tls.tlsEventTable.EVT_EAP_START
1989 tls._eapIdReq()
1990 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07001991 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00001992 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
1993 t.start()
1994 reactor.callLater(0, eap_tls_verify, df)
1995 return df
1996
1997 @deferred(TEST_TIMEOUT_DELAY-150)
1998 def test_netCondition_in_eap_tls_with_invalid_client_cert_req_handshake_auth_packet(self):
1999 self.setUp_tls()
2000 randomDelay = randint(10,300)
2001 df = defer.Deferred()
2002 def tls_incorrect_handshake_type_certificate_request_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07002003 log_test.info('TLS authentication failed with incorrect handshake type in client certificate request packet')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002004 tls = TLSAuthTest(fail_cb = tls_incorrect_handshake_type_certificate_request_cb, invalid_cert_req_handshake = True)
2005 def eap_tls_eapTlsHelloReq_pkt_delay():
2006 tls._eapTlsHelloReq()
2007 tls._eapTlsCertReq()
2008 tls._eapTlsChangeCipherSpec()
2009 tls._eapTlsFinished()
2010 df.callback(0)
2011 def eap_tls_verify(df):
2012 tls._eapSetup()
2013 tls.tlsEventTable.EVT_EAP_SETUP
2014 tls._eapStart()
2015 tls.tlsEventTable.EVT_EAP_START
2016 tls._eapIdReq()
2017 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07002018 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002019 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
2020 t.start()
2021 reactor.callLater(0, eap_tls_verify, df)
2022 return df
2023
2024 @deferred(TEST_TIMEOUT_DELAY-150)
2025 def test_netCondition_in_eap_tls_with_invalid_client_key_ex_replacing_server_key_ex(self):
2026 self.setUp_tls()
2027 randomDelay = randint(10,300)
2028 df = defer.Deferred()
2029 def tls_clientkeyex_replace_with_serverkeyex_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07002030 log_test.info('TLS authentication failed with client key exchange replaced with server key exchange')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002031 tls = TLSAuthTest(fail_cb = tls_clientkeyex_replace_with_serverkeyex_cb,clientkeyex_replace_with_serverkeyex=True)
2032 def eap_tls_eapTlsHelloReq_pkt_delay():
2033 tls._eapTlsHelloReq()
2034 tls._eapTlsCertReq()
2035 tls._eapTlsChangeCipherSpec()
2036 tls._eapTlsFinished()
2037 df.callback(0)
2038 def eap_tls_verify(df):
2039 tls._eapSetup()
2040 tls.tlsEventTable.EVT_EAP_SETUP
2041 tls._eapStart()
2042 tls.tlsEventTable.EVT_EAP_START
2043 tls._eapIdReq()
2044 tls.tlsEventTable.EVT_EAP_ID_REQ
A R Karthick76a497a2017-04-12 10:59:39 -07002045 log_test.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002046 t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay)
2047 t.start()
2048 reactor.callLater(0, eap_tls_verify, df)
2049 return df
2050
2051 def tcpreplay_radius_server_packets_from_pcap_file(self, pcap_file_path =None, error_pkt = None):
2052 #default radius server packets in path in test/netCondition/xxx.pcap file
2053 if pcap_file_path and (error_pkt == None):
2054 pcap_file_path = pcap_file_path
2055 elif error_pkt == None:
2056 pcap_file_path = "/root/test/src/test/netCondition/tls_auth_exhange_packets_Radius_server_packets_only.pcap"
2057 elif error_pkt:
2058 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 -07002059 log_test.info('Started replaying pcap file packets on docker0 interface using tcprelay linux command')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002060 time.sleep(0.4)
2061 sendp(rdpcap(pcap_file_path), iface="eth0", loop=0, inter=1)
2062 time.sleep(5)
A R Karthick76a497a2017-04-12 10:59:39 -07002063 log_test.info('Replayed pcap file packets on docker0 interface')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002064
2065 def tcpreplay_radius_server_error_packets_from_pcap_file(self, pcap_file_path =None, error_pkt = None):
2066 #default radius server packets in path in test/netCondition/xxx.pcap file
2067 if pcap_file_path:
2068 pcap_file_path = pcap_file_path
2069 else:
2070 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 -07002071 log_test.info('Started replaying pcap file error packets on docker0 interface using tcprelay linux command')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002072 time.sleep(0.4)
2073 sendp(rdpcap(pcap_file_path), iface="eth0", loop=0, inter=1)
2074 time.sleep(5)
2075 return 'success'
2076
2077 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):
2078 #default radius server packets in path in test/netCondition/xxx.pcap file
2079 random_port = 1222
2080 if pcap_file_path:
2081 pcap_file_path = pcap_file_path
2082 else:
2083 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 -07002084 log_test.info('Started corrupting tls server packet no = {}'.format(pkt_no))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002085 radius_server_pkts = rdpcap(pcap_file_path)
2086 error_server_pkt = radius_server_pkts[pkt_no]
2087 if pkt_no == 0:
2088 if L4:
2089 error_server_pkt[UDP].sport = random_port
2090 error_server_pkt[UDP].dport = random_port
2091
2092 if no_of_radius_attribute:
2093 error_server_pkt[3][2].value = '\n\xd8\xf0\xbbW\xd6$;\xd2s\xd5\xc5Ck\xd5\x01'
2094 error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2095 if pkt_no == 1:
2096 if L4:
2097 error_server_pkt[UDP].sport = random_port
2098 error_server_pkt[UDP].dport = random_port
2099
2100 if no_of_radius_attribute:
2101 error_server_pkt[3][2].type = 79
2102 error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2103
2104 if pkt_no == 2:
2105 if L4:
2106 error_server_pkt[UDP].sport = random_port
2107 error_server_pkt[UDP].dport = random_port
2108
2109 if no_of_radius_attribute:
2110 error_server_pkt[3][1].type = 79
2111 error_server_pkt[3][2].len = 18
2112 error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2113 error_server_pkt[3][3].len = 18
2114 error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9'
2115
2116 if pkt_no == 3:
2117 if L4:
2118 error_server_pkt[UDP].sport = random_port
2119 error_server_pkt[UDP].dport = random_port
2120
2121 if no_of_radius_attribute:
2122 error_server_pkt[3][1].type = 79
2123 error_server_pkt[3][2].len = 18
2124 error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2125 error_server_pkt[3][3].len = 18
2126 error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9'
2127
2128 if pkt_no == 4:
2129 if L4:
2130 error_server_pkt[UDP].sport = random_port
2131 error_server_pkt[UDP].dport = random_port
2132
2133 if no_of_radius_attribute:
2134 error_server_pkt[3][1].type = 79
2135 error_server_pkt[3][2].len = 18
2136 error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2137 error_server_pkt[3][3].len = 18
2138 error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9'
2139
2140 if pkt_no == 5:
2141 if L4:
2142 error_server_pkt[UDP].sport = random_port
2143 error_server_pkt[UDP].dport = random_port
2144
2145 if no_of_radius_attribute:
2146 error_server_pkt[3][1].type = 79
2147 error_server_pkt[3][2].len = 18
2148 error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2149 error_server_pkt[3][3].len = 18
2150 error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9'
2151
2152 if pkt_no == 6:
2153 if L4:
2154 error_server_pkt[UDP].sport = random_port
2155 error_server_pkt[UDP].dport = random_port
2156
2157 if no_of_radius_attribute:
2158 error_server_pkt[3][1].type = 79
2159 error_server_pkt[3][2].len = 18
2160 error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2161 error_server_pkt[3][3].len = 18
2162 error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9'
2163 error_server_pkt[3][5].len = 18
2164 error_server_pkt[3][5].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9'
2165
2166
2167 error_server_pkt.show()
2168 radius_server_pkts[pkt_no] = error_server_pkt
2169 wrpcap("/root/test/src/test/netCondition/error_tls_auth_exhange_packets_Radius_server_packets_only.pcap", radius_server_pkts)
2170 pcap_file_path = "/root/test/src/test/netCondition/error_tls_auth_exhange_packets_Radius_server_packets_only.pcap"
2171
A R Karthick76a497a2017-04-12 10:59:39 -07002172 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 +00002173 return pcap_file_path
2174
2175 @deferred(TEST_TIMEOUT_DELAY-50)
2176 def test_netCondition_in_eap_tls_with_valid_client_and_emulating_server_packets_without_radius_server_container(self):
2177 self.setUp_tls()
2178 df = defer.Deferred()
2179 threads = []
2180 threads_status = []
2181 clients = 1
A R Karthickf7a613b2017-02-24 09:36:44 -08002182 radius_image = 'cordtest/radius:candidate'
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002183 delay = 20
2184 que = Queue.Queue()
2185 def eap_tls_emulating_server_pkts(df):
2186 def tls_client_packets(start):
2187 time.sleep(0.2)
2188 randomDelay = randint(10,300)
2189 tls = TLSAuthTest(src_mac = 'random')
2190 tls._eapSetup()
2191 tls.tlsEventTable.EVT_EAP_SETUP
2192 tls._eapStart()
2193 tls.tlsEventTable.EVT_EAP_START
2194 tls._eapIdReq()
2195 tls.tlsEventTable.EVT_EAP_ID_REQ
2196 tls._eapTlsHelloReq()
2197 tls._eapTlsCertReq()
2198 tls._eapTlsChangeCipherSpec()
2199 tls._eapTlsFinished()
2200 if tls.failTest == False:
A R Karthick76a497a2017-04-12 10:59:39 -07002201 log_test.info('Authentication successful for user')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002202 return 'success'
2203 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002204 log_test.info('Authentication not successful for user')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002205 return 'failed'
2206 thread_client = threading.Thread(target=lambda q, arg1: q.put(tls_client_packets(arg1)), args=(que, 'start'))
2207 thread_radius = threading.Thread(target = Container.pause_container, args = (radius_image,delay))
2208 thread_tcpreplay = threading.Thread(target = self.tcpreplay_radius_server_packets_from_pcap_file)
2209 threads.append(thread_radius)
2210 threads.append(thread_client)
2211 threads.append(thread_tcpreplay)
2212 for thread in threads:
2213 thread.start()
2214 for thread in threads:
2215 thread.join()
2216 while not que.empty():
2217 threads_status = que.get()
2218 assert_equal(threads_status, 'success')
2219 df.callback(0)
2220 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2221 return df
2222
2223
2224 def eap_tls_emulating_server_pkts_negative_testing(df,msg):
2225 threads = []
2226 threads_status = []
2227 clients = 1
A R Karthickf7a613b2017-02-24 09:36:44 -08002228 radius_image = 'cordtest/radius:candidate'
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002229 delay = 20
2230 que = Queue.Queue()
2231 def tls_client_packets(start):
2232 time.sleep(0.2)
2233 randomDelay = randint(10,300)
2234 def tls_invalid_server_packets_scenario_cb():
A R Karthick76a497a2017-04-12 10:59:39 -07002235 log_test.info('TLS authentication failed with {}'.format(msg))
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002236 tls = TLSAuthTest(fail_cb = tls_invalid_server_packets_scenario_cb, src_mac = 'random')
2237 tls._eapSetup()
2238 tls.tlsEventTable.EVT_EAP_SETUP
2239 tls._eapStart()
2240 tls.tlsEventTable.EVT_EAP_START
2241 tls._eapIdReq()
2242 tls.tlsEventTable.EVT_EAP_ID_REQ
2243 tls._eapTlsHelloReq()
2244 tls._eapTlsCertReq()
2245 tls._eapTlsChangeCipherSpec()
2246 tls._eapTlsFinished()
2247 if tls.failTest == True:
A R Karthick76a497a2017-04-12 10:59:39 -07002248 log_test.info('Authentication not successful for user')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002249 return 'failed'
2250 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002251 log_test.info('Authentication successful for user')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002252 return 'success'
2253 def tcpreplay_radius_server_error_packets_from_pcap_file(pcap_file_path =None, error_pkt = None):
2254 #default radius server packets in path in test/netCondition/xxx.pcap file
2255 if pcap_file_path:
2256 pcap_file_path = pcap_file_path
2257 else:
2258 pcap_file_path = "/root/test/src/test/netCondition/error_tls_auth_exhange_packets_Radius_server_packets_only.pcap"
2259
A R Karthick76a497a2017-04-12 10:59:39 -07002260 log_test.info('Started replaying pcap file error packets on docker0 interface using tcprelay linux command')
Thangavelu K Sef6f0a52016-12-14 19:57:05 +00002261 time.sleep(0.4)
2262 sendp(rdpcap(pcap_file_path), iface="eth0", loop=0, inter=1)
2263 time.sleep(5)
2264 return 'success'
2265 thread_client = threading.Thread(target=lambda q, arg1: q.put(tls_client_packets(arg1)), args=(que, 'start'))
2266 thread_radius = threading.Thread(target = Container.pause_container, args = (radius_image,delay))
2267 thread_tcpreplay = threading.Thread(target = tcpreplay_radius_server_error_packets_from_pcap_file)
2268 threads.append(thread_radius)
2269 threads.append(thread_client)
2270 threads.append(thread_tcpreplay)
2271 for thread in threads:
2272 thread.start()
2273 for thread in threads:
2274 thread.join()
2275 while not que.empty():
2276 threads_status = que.get()
2277 assert_equal(threads_status, 'failed')
2278
2279
2280 @deferred(TEST_TIMEOUT_DELAY-250)
2281 def test_netCondition_in_eap_tls_with_valid_client_and_dropped_server_eapid_response_packet(self):
2282 self.setUp_tls()
2283 df = defer.Deferred()
2284 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 0, L4 = True)
2285 def eap_tls_emulating_server_pkts(df):
2286 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping server eapId response')
2287 df.callback(0)
2288 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2289 return df
2290
2291 @deferred(TEST_TIMEOUT_DELAY-50)
2292 def test_netCondition_in_eap_tls_with_valid_client_and_invalid_server_eapid_response_packet(self):
2293 self.setUp_tls()
2294 df = defer.Deferred()
2295 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 0, no_of_radius_attribute = 1)
2296 def eap_tls_emulating_server_pkts(df):
2297 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid server eapId response')
2298 df.callback(0)
2299 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2300 return df
2301 @deferred(TEST_TIMEOUT_DELAY-50)
2302 def test_netCondition_in_eap_tls_with_valid_client_and_dropped_server_hello_packet(self):
2303 self.setUp_tls()
2304 df = defer.Deferred()
2305 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 1, L4 = True)
2306 def eap_tls_emulating_server_pkts(df):
2307 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping server hello packet')
2308 df.callback(0)
2309 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2310 return df
2311
2312 @deferred(TEST_TIMEOUT_DELAY-50)
2313 def test_netCondition_in_eap_tls_with_valid_client_and_invalid_server_hello_packet(self):
2314 self.setUp_tls()
2315 df = defer.Deferred()
2316 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 1, no_of_radius_attribute = 1)
2317 def eap_tls_emulating_server_pkts(df):
2318 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid server hello packet')
2319 df.callback(0)
2320 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2321 return df
2322
2323 @deferred(TEST_TIMEOUT_DELAY-50)
2324 def test_netCondition_in_eap_tls_with_valid_client_and_dropped_client_certficate_access_challenge_server_packet(self):
2325 self.setUp_tls()
2326 df = defer.Deferred()
2327 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 2, L4 = True)
2328 def eap_tls_emulating_server_pkts(df):
2329 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping client certificate access challenge packet')
2330 df.callback(0)
2331 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2332 return df
2333
2334 @deferred(TEST_TIMEOUT_DELAY-50)
2335 def test_netCondition_in_eap_tls_with_valid_client_and_invalid_client_certficate_access_challenge_server_packet(self):
2336 self.setUp_tls()
2337 df = defer.Deferred()
2338 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 2, no_of_radius_attribute = 1)
2339 def eap_tls_emulating_server_pkts(df):
2340 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid client certificate access challenge packet')
2341 df.callback(0)
2342 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2343 return df
2344
2345 @deferred(TEST_TIMEOUT_DELAY-50)
2346 def test_netCondition_in_eap_tls_with_valid_client_and_dropped_client_certficate_with_2nd_fragment_access_challenge_server_packet(self):
2347 self.setUp_tls()
2348 df = defer.Deferred()
2349 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 3, L4 = True)
2350 def eap_tls_emulating_server_pkts(df):
2351 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping client certificate with 2nd fragment access challenge packet')
2352 df.callback(0)
2353 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2354 return df
2355
2356 @deferred(TEST_TIMEOUT_DELAY-50)
2357 def test_netCondition_in_eap_tls_with_valid_client_and_invalid_client_certficate_with_2nd_fragment_access_challenge_server_packet(self):
2358 self.setUp_tls()
2359 df = defer.Deferred()
2360 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 3, no_of_radius_attribute = 1)
2361 def eap_tls_emulating_server_pkts(df):
2362 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid client certificate for 2nd fragment access challenge packet')
2363 df.callback(0)
2364 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2365 return df
2366
2367 @deferred(TEST_TIMEOUT_DELAY-50)
2368 def test_netCondition_in_eap_tls_with_valid_client_and_dropped_client_certficate_with_3rd_fragment_access_challenge_server_packet(self):
2369 self.setUp_tls()
2370 df = defer.Deferred()
2371 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 4, L4 = True)
2372 def eap_tls_emulating_server_pkts(df):
2373 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping client certificate for 3rd fragment access challenge packet')
2374 df.callback(0)
2375 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2376 return df
2377
2378 @deferred(TEST_TIMEOUT_DELAY-50)
2379 def test_netCondition_in_eap_tls_with_valid_client_and_invalid_client_certficate_with_3rd_fragment_access_challenge_server_packet(self):
2380 self.setUp_tls()
2381 df = defer.Deferred()
2382 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 4, no_of_radius_attribute = 1)
2383 def eap_tls_emulating_server_pkts(df):
2384 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid client certificate for 3rd fragment access challenge packet')
2385 df.callback(0)
2386 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2387 return df
2388
2389 @deferred(TEST_TIMEOUT_DELAY-50)
2390 def test_netCondition_in_eap_tls_with_valid_client_and_dropped_cipher_suite_request_server_packet(self):
2391 self.setUp_tls()
2392 df = defer.Deferred()
2393 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 5, L4 = True)
2394 def eap_tls_emulating_server_pkts(df):
2395 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping cipher suite request server packet')
2396 df.callback(0)
2397 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2398 return df
2399
2400 @deferred(TEST_TIMEOUT_DELAY-50)
2401 def test_netCondition_in_eap_tls_with_valid_client_and_invalid_cipher_suite_request_server_packet(self):
2402 self.setUp_tls()
2403 df = defer.Deferred()
2404 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 5, no_of_radius_attribute = 1)
2405 def eap_tls_emulating_server_pkts(df):
2406 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid cipher suite request server packet')
2407 df.callback(0)
2408 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2409 return df
2410
2411 @deferred(TEST_TIMEOUT_DELAY-50)
2412 def test_netCondition_in_eap_tls_with_valid_client_and_dropped_access_accept_server_packet(self):
2413 self.setUp_tls()
2414 df = defer.Deferred()
2415 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 6, L4 = True)
2416 def eap_tls_emulating_server_pkts(df):
2417 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping access accept server packet ')
2418 df.callback(0)
2419 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2420 return df
2421
2422 @deferred(TEST_TIMEOUT_DELAY-50)
2423 def test_netCondition_in_eap_tls_with_valid_client_and_invalid_access_accept_server_packet(self):
2424 self.setUp_tls()
2425 df = defer.Deferred()
2426 self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 6, no_of_radius_attribute = 1)
2427 def eap_tls_emulating_server_pkts(df):
2428 self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid access accept server packet ')
2429 df.callback(0)
2430 reactor.callLater(0, eap_tls_emulating_server_pkts, df)
2431 return df