ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2016-present Ciena Corporation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | import unittest |
| 17 | from threading import Timer |
| 18 | from nose.tools import * |
| 19 | from nose.twistedtools import reactor, deferred |
| 20 | from twisted.internet import defer |
| 21 | from scapy.all import * |
| 22 | import time, monotonic |
| 23 | import os, sys |
| 24 | import tempfile |
| 25 | import random |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 26 | import Queue |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 27 | import threading |
| 28 | from IGMP import * |
| 29 | from McastTraffic import * |
| 30 | from Stats import Stats |
| 31 | from OnosCtrl import OnosCtrl |
| 32 | from OltConfig import OltConfig |
| 33 | from Channels import IgmpChannel |
| 34 | from EapTLS import TLSAuthTest |
| 35 | from scapy_ssl_tls.ssl_tls import * |
| 36 | from scapy_ssl_tls.ssl_tls_crypto import * |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 37 | from EapolAAA import * |
| 38 | from enum import * |
| 39 | import noseTlsAuthHolder as tlsAuthHolder |
| 40 | from tls_cert import Key |
| 41 | from socket import * |
| 42 | from CordTestServer import cord_test_radius_restart |
| 43 | import struct |
| 44 | import scapy |
| 45 | from CordTestBase import CordTester |
| 46 | from CordContainer import * |
A R Karthick | 9313b76 | 2016-11-07 13:14:35 -0800 | [diff] [blame] | 47 | from CordLogger import CordLogger |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 48 | import re |
| 49 | from random import randint |
| 50 | from time import sleep |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 51 | import json |
| 52 | from OnosFlowCtrl import OnosFlowCtrl |
| 53 | from OltConfig import OltConfig |
| 54 | from threading import current_thread |
| 55 | import collections |
Thangavelu K S | ef6f0a5 | 2016-12-14 19:57:05 +0000 | [diff] [blame] | 56 | log.setLevel('INFO') |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 57 | |
| 58 | class IGMPTestState: |
| 59 | |
| 60 | def __init__(self, groups = [], df = None, state = 0): |
| 61 | self.df = df |
| 62 | self.state = state |
| 63 | self.counter = 0 |
| 64 | self.groups = groups |
| 65 | self.group_map = {} ##create a send/recv count map |
| 66 | for g in groups: |
| 67 | self.group_map[g] = (Stats(), Stats()) |
| 68 | |
| 69 | def update(self, group, tx = 0, rx = 0, t = 0): |
| 70 | self.counter += 1 |
| 71 | index = 0 if rx == 0 else 1 |
| 72 | v = tx if rx == 0 else rx |
| 73 | if self.group_map.has_key(group): |
| 74 | self.group_map[group][index].update(packets = v, t = t) |
| 75 | |
| 76 | def update_state(self): |
| 77 | self.state = self.state ^ 1 |
| 78 | |
A R Karthick | 9313b76 | 2016-11-07 13:14:35 -0800 | [diff] [blame] | 79 | class netCondition_exchange(CordLogger): |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 80 | |
| 81 | V_INF1 = 'veth0' |
| 82 | V_INF2 = 'veth1' |
| 83 | MGROUP1 = '239.1.2.3' |
| 84 | MGROUP2 = '239.2.2.3' |
| 85 | MINVALIDGROUP1 = '255.255.255.255' |
| 86 | MINVALIDGROUP2 = '239.255.255.255' |
| 87 | MMACGROUP1 = "01:00:5e:01:02:03" |
| 88 | MMACGROUP2 = "01:00:5e:02:02:03" |
| 89 | IGMP_DST_MAC = "01:00:5e:00:00:16" |
| 90 | IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1" |
| 91 | IP_SRC = '1.2.3.4' |
| 92 | IP_DST = '224.0.0.22' |
| 93 | NEGATIVE_TRAFFIC_STATUS = 1 |
| 94 | igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP) |
| 95 | igmp_ip = IP(dst = IP_DST) |
| 96 | IGMP_TEST_TIMEOUT = 5 |
| 97 | IGMP_QUERY_TIMEOUT = 60 |
| 98 | MCAST_TRAFFIC_TIMEOUT = 10 |
| 99 | TEST_TIMEOUT_DELAY = 340 |
| 100 | PORT_TX_DEFAULT = 2 |
| 101 | PORT_RX_DEFAULT = 1 |
| 102 | max_packets = 100 |
| 103 | app_igmp = 'org.opencord.igmp' |
| 104 | olt_conf_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../setup/olt_config.json') |
| 105 | ROVER_TEST_TIMEOUT = 10 #3600*86 |
| 106 | ROVER_TIMEOUT = (ROVER_TEST_TIMEOUT - 100) |
| 107 | ROVER_JOIN_TIMEOUT = 60 |
| 108 | |
| 109 | app_tls = 'org.opencord.aaa' |
| 110 | TLS_TIMEOUT = 20 |
| 111 | CLIENT_CERT_INVALID = '''-----BEGIN CERTIFICATE----- |
| 112 | MIIEyTCCA7GgAwIBAgIJAM6l2jUG56pLMA0GCSqGSIb3DQEBCwUAMIGLMQswCQYD |
| 113 | VQQGEwJVUzELMAkGA1UECBMCQ0ExEjAQBgNVBAcTCVNvbWV3aGVyZTETMBEGA1UE |
| 114 | ChMKQ2llbmEgSW5jLjEeMBwGCSqGSIb3DQEJARYPYWRtaW5AY2llbmEuY29tMSYw |
| 115 | JAYDVQQDEx1FeGFtcGxlIENlcnRpZmljYXRlIEF1dGhvcml0eTAeFw0xNjAzMTEx |
| 116 | ODUzMzVaFw0xNzAzMDYxODUzMzVaMIGLMQswCQYDVQQGEwJVUzELMAkGA1UECBMC |
| 117 | Q0ExEjAQBgNVBAcTCVNvbWV3aGVyZTETMBEGA1UEChMKQ2llbmEgSW5jLjEeMBwG |
| 118 | CSqGSIb3DQEJARYPYWRtaW5AY2llbmEuY29tMSYwJAYDVQQDEx1FeGFtcGxlIENl |
| 119 | cnRpZmljYXRlIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC |
| 120 | ggEBAL9Jv54TkqycL3U2Fdd/y5NXdnPVXwAVV3m6I3eIffVCv8eS+mwlbl9dnbjo |
| 121 | qqlGEgA3sEg5HtnKoW81l3PSyV/YaqzUzbcpDlgWlbNkFQ3nVxh61gSU34Fc4h/W |
| 122 | plSvCkwGSbV5udLtEe6S9IflP2Fu/eXa9vmUtoPqDk66p9U/nWVf2H1GJy7XanWg |
| 123 | wke+HpQvbzoSfPJS0e5Rm9KErrzaIkJpqt7soW+OjVJitUax7h45RYY1HHHlbMQ0 |
| 124 | ndWW8UDsCxFQO6d7nsijCzY69Y8HarH4mbVtqhg3KJevxD9UMRy6gdtPMDZLah1c |
| 125 | LHRu14ucOK4aF8oICOgtcD06auUCAwEAAaOCASwwggEoMB0GA1UdDgQWBBQwEs0m |
| 126 | c8HARTVp21wtiwgav5biqjCBwAYDVR0jBIG4MIG1gBQwEs0mc8HARTVp21wtiwga |
| 127 | v5biqqGBkaSBjjCBizELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRIwEAYDVQQH |
| 128 | EwlTb21ld2hlcmUxEzARBgNVBAoTCkNpZW5hIEluYy4xHjAcBgkqhkiG9w0BCQEW |
| 129 | D2FkbWluQGNpZW5hLmNvbTEmMCQGA1UEAxMdRXhhbXBsZSBDZXJ0aWZpY2F0ZSBB |
| 130 | dXRob3JpdHmCCQDOpdo1BueqSzAMBgNVHRMEBTADAQH/MDYGA1UdHwQvMC0wK6Ap |
| 131 | oCeGJWh0dHA6Ly93d3cuZXhhbXBsZS5jb20vZXhhbXBsZV9jYS5jcmwwDQYJKoZI |
| 132 | hvcNAQELBQADggEBAK+fyAFO8CbH35P5mOX+5wf7+AeC+5pwaFcoCV0zlfwniANp |
| 133 | jISgcIX9rcetLxeYRAO5com3+qLdd9dGVNL0kwufH4QhlSPErG7OLHHAs4JWVhUo |
| 134 | bH3lK9lgFVlnCDBtQhslzqScR64SCicWcQEjv3ZMZsJwYLvl8unSaKz4+LVPeJ2L |
| 135 | opCpmZw/V/S2NhBbe3QjTiRPmDev2gbaO4GCfi/6sCDU7UO3o8KryrkeeMIiFIej |
| 136 | gfwn9fovmpeqCEyupy2JNNUTJibEuFknwx7JAX+htPL27nEgwV1FYtwI3qLiZqkM |
| 137 | 729wo9cFSslJNZBu+GsBP5LszQSuvNTDWytV+qY= |
| 138 | -----END CERTIFICATE-----''' |
| 139 | |
| 140 | def onos_aaa_config(self): |
| 141 | aaa_dict = {'apps' : { 'org.onosproject.aaa' : { 'AAA' : { 'radiusSecret': 'radius_password', |
| 142 | 'radiusIp': '172.17.0.2' } } } } |
| 143 | radius_ip = os.getenv('ONOS_AAA_IP') or '172.17.0.2' |
| 144 | aaa_dict['apps']['org.onosproject.aaa']['AAA']['radiusIp'] = radius_ip |
| 145 | self.onos_ctrl.activate() |
| 146 | time.sleep(2) |
| 147 | self.onos_load_tls_config(aaa_dict) |
| 148 | |
| 149 | def onos_load_tls_config(self, config): |
| 150 | status, code = OnosCtrl.config(config) |
| 151 | if status is False: |
| 152 | log.info('Configure request for AAA returned status %d' %code) |
| 153 | assert_equal(status, True) |
| 154 | time.sleep(3) |
| 155 | |
| 156 | @classmethod |
| 157 | def setUpClass(cls): |
| 158 | cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file) |
| 159 | cls.port_map, _ = cls.olt.olt_port_map() |
A R Karthick | 0f6b684 | 2016-12-06 17:17:44 -0800 | [diff] [blame] | 160 | OnosCtrl.cord_olt_config(cls.olt) |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 161 | cls.device_id = OnosCtrl.get_device_id() |
| 162 | |
| 163 | @classmethod |
| 164 | def tearDownClass(cls): pass |
| 165 | |
| 166 | def setUp_igmp(self): |
| 167 | ''' Activate the igmp app''' |
| 168 | apps = self.app_igmp |
| 169 | self.onos_ctrl = OnosCtrl(apps) |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 170 | self.onos_aaa_config() |
| 171 | self.onos_ctrl.activate() |
| 172 | self.igmp_channel = IgmpChannel() |
| 173 | |
| 174 | def setUp_tls(self): |
Thangavelu K S | ef6f0a5 | 2016-12-14 19:57:05 +0000 | [diff] [blame] | 175 | ''' Activate the aaa app''' |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 176 | apps = self.app_tls |
| 177 | self.onos_ctrl = OnosCtrl(apps) |
| 178 | self.onos_aaa_config() |
| 179 | |
| 180 | def tearDown(self): |
| 181 | '''Deactivate the dhcp app''' |
| 182 | apps = [self.app_igmp, self.app_tls] |
| 183 | for app in apps: |
| 184 | onos_ctrl = OnosCtrl(app) |
| 185 | onos_ctrl.deactivate() |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 186 | |
| 187 | def onos_load_igmp_config(self, config): |
| 188 | log.info('onos load config is %s'%config) |
| 189 | status, code = OnosCtrl.config(config) |
| 190 | if status is False: |
| 191 | log.info('JSON request returned status %d' %code) |
| 192 | assert_equal(status, True) |
| 193 | time.sleep(2) |
| 194 | |
| 195 | def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False): |
| 196 | ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } } |
| 197 | ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate'] |
| 198 | if flag: #to maintain seperate group-source pair. |
| 199 | for i in range(len(groups)): |
| 200 | d = {} |
| 201 | d['source'] = src_list[i] or '0.0.0.0' |
| 202 | d['group'] = groups[i] |
| 203 | ssm_xlate_list.append(d) |
| 204 | else: |
| 205 | for g in groups: |
| 206 | for s in src_list: |
| 207 | d = {} |
| 208 | d['source'] = s or '0.0.0.0' |
| 209 | d['group'] = g |
| 210 | ssm_xlate_list.append(d) |
| 211 | self.onos_load_igmp_config(ssm_dict) |
| 212 | cord_port_map = {} |
| 213 | for g in groups: |
| 214 | cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT) |
| 215 | self.igmp_channel.cord_port_table_load(cord_port_map) |
| 216 | time.sleep(2) |
| 217 | |
| 218 | def mcast_ip_range(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'): |
| 219 | start = list(map(int, start_ip.split("."))) |
| 220 | end = list(map(int, end_ip.split("."))) |
| 221 | temp = start |
| 222 | ip_range = [] |
| 223 | ip_range.append(start_ip) |
| 224 | while temp != end: |
| 225 | start[3] += 1 |
| 226 | for i in (3, 2, 1): |
| 227 | if temp[i] == 255: |
| 228 | temp[i] = 0 |
| 229 | temp[i-1] += 1 |
| 230 | ip_range.append(".".join(map(str, temp))) |
| 231 | return ip_range |
| 232 | |
| 233 | def random_mcast_ip(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'): |
| 234 | start = list(map(int, start_ip.split("."))) |
| 235 | end = list(map(int, end_ip.split("."))) |
| 236 | temp = start |
| 237 | ip_range = [] |
| 238 | ip_range.append(start_ip) |
| 239 | while temp != end: |
| 240 | start[3] += 1 |
| 241 | for i in (3, 2, 1): |
| 242 | if temp[i] == 255: |
| 243 | temp[i] = 0 |
| 244 | temp[i-1] += 1 |
| 245 | ip_range.append(".".join(map(str, temp))) |
| 246 | return random.choice(ip_range) |
| 247 | |
| 248 | def source_ip_range(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'): |
| 249 | start = list(map(int, start_ip.split("."))) |
| 250 | end = list(map(int, end_ip.split("."))) |
| 251 | temp = start |
| 252 | ip_range = [] |
| 253 | ip_range.append(start_ip) |
| 254 | while temp != end: |
| 255 | start[3] += 1 |
| 256 | for i in (3, 2, 1): |
| 257 | if temp[i] == 255: |
| 258 | temp[i] = 0 |
| 259 | temp[i-1] += 1 |
| 260 | ip_range.append(".".join(map(str, temp))) |
| 261 | return ip_range |
| 262 | |
| 263 | def randomsourceip(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'): |
| 264 | start = list(map(int, start_ip.split("."))) |
| 265 | end = list(map(int, end_ip.split("."))) |
| 266 | temp = start |
| 267 | ip_range = [] |
| 268 | ip_range.append(start_ip) |
| 269 | while temp != end: |
| 270 | start[3] += 1 |
| 271 | for i in (3, 2, 1): |
| 272 | if temp[i] == 255: |
| 273 | temp[i] = 0 |
| 274 | temp[i-1] += 1 |
| 275 | ip_range.append(".".join(map(str, temp))) |
| 276 | return random.choice(ip_range) |
| 277 | |
| 278 | def get_igmp_intf(self): |
| 279 | inst = os.getenv('TEST_INSTANCE', None) |
| 280 | if not inst: |
| 281 | return 'veth0' |
| 282 | inst = int(inst) + 1 |
| 283 | if inst >= self.port_map['uplink']: |
| 284 | inst += 1 |
| 285 | if self.port_map.has_key(inst): |
| 286 | return self.port_map[inst] |
| 287 | return 'veth0' |
| 288 | |
| 289 | def igmp_verify_join(self, igmpStateList): |
| 290 | sendState, recvState = igmpStateList |
| 291 | ## check if the send is received for the groups |
| 292 | for g in sendState.groups: |
| 293 | tx_stats = sendState.group_map[g][0] |
| 294 | tx = tx_stats.count |
| 295 | assert_greater(tx, 0) |
| 296 | rx_stats = recvState.group_map[g][1] |
| 297 | rx = rx_stats.count |
| 298 | assert_greater(rx, 0) |
| 299 | log.info('Receive stats %s for group %s' %(rx_stats, g)) |
| 300 | |
| 301 | log.info('IGMP test verification success') |
| 302 | |
| 303 | def igmp_verify_leave(self, igmpStateList, leave_groups): |
| 304 | sendState, recvState = igmpStateList[0], igmpStateList[1] |
| 305 | ## check if the send is received for the groups |
| 306 | for g in sendState.groups: |
| 307 | tx_stats = sendState.group_map[g][0] |
| 308 | rx_stats = recvState.group_map[g][1] |
| 309 | tx = tx_stats.count |
| 310 | rx = rx_stats.count |
| 311 | assert_greater(tx, 0) |
| 312 | if g not in leave_groups: |
| 313 | log.info('Received %d packets for group %s' %(rx, g)) |
| 314 | for g in leave_groups: |
| 315 | rx = recvState.group_map[g][1].count |
| 316 | assert_equal(rx, 0) |
| 317 | |
| 318 | log.info('IGMP test verification success') |
| 319 | |
| 320 | def mcast_traffic_timer(self): |
| 321 | self.mcastTraffic.stopReceives() |
| 322 | |
| 323 | def send_mcast_cb(self, send_state): |
| 324 | for g in send_state.groups: |
| 325 | send_state.update(g, tx = 1) |
| 326 | return 0 |
| 327 | |
| 328 | ##Runs in the context of twisted reactor thread |
| 329 | def igmp_recv(self, igmpState, iface = 'veth0'): |
| 330 | p = self.recv_socket.recv() |
| 331 | try: |
| 332 | send_time = float(p.payload.load) |
| 333 | recv_time = monotonic.monotonic() |
| 334 | except: |
| 335 | log.info('Unexpected Payload received: %s' %p.payload.load) |
| 336 | return 0 |
| 337 | #log.info( 'Recv in %.6f secs' %(recv_time - send_time)) |
| 338 | igmpState.update(p.dst, rx = 1, t = recv_time - send_time) |
| 339 | return 0 |
| 340 | |
| 341 | def send_igmp_join(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE, |
Thangavelu K S | ef6f0a5 | 2016-12-14 19:57:05 +0000 | [diff] [blame] | 342 | ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1, ip_src = None): |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 343 | if ssm_load is True: |
| 344 | self.onos_ssm_table_load(groups, src_list) |
| 345 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
| 346 | gaddr=self.IP_DST) |
| 347 | for g in groups: |
| 348 | gr = IGMPv3gr(rtype= record_type, mcaddr=g) |
| 349 | gr.sources = src_list |
| 350 | igmp.grps.append(gr) |
| 351 | if ip_pkt is None: |
Thangavelu K S | ef6f0a5 | 2016-12-14 19:57:05 +0000 | [diff] [blame] | 352 | if ip_src is None: |
| 353 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 354 | else: |
| 355 | igmp_ip_src = IP(dst = self.IP_DST, src = ip_src) |
| 356 | ip_pkt = self.igmp_eth/igmp_ip_src |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 357 | pkt = ip_pkt/igmp |
| 358 | IGMPv3.fixup(pkt) |
| 359 | sendp(pkt, iface=iface) |
| 360 | if delay != 0: |
| 361 | time.sleep(delay) |
| 362 | |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 363 | |
| 364 | def send_igmp_join_negative(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE, |
| 365 | ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1, ip_src = None, invalid_igmp_join = None ): |
| 366 | if ssm_load is True: |
| 367 | self.onos_ssm_table_load(groups, src_list) |
| 368 | if invalid_igmp_join == 'igmp_type': |
| 369 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT_NEGATIVE, max_resp_code=30, |
| 370 | gaddr=self.IP_DST) |
| 371 | else: |
| 372 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
| 373 | gaddr=self.IP_DST) |
| 374 | if invalid_igmp_join == 'record_type': |
| 375 | record_type = IGMP_V3_GR_TYPE_INCLUDE_NEGATIVE |
| 376 | |
| 377 | for g in groups: |
| 378 | gr = IGMPv3gr(rtype= record_type, mcaddr=g) |
| 379 | gr.sources = src_list |
| 380 | igmp.grps.append(gr) |
| 381 | if ip_pkt is None: |
| 382 | if ip_src is None: |
| 383 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 384 | else: |
| 385 | igmp_ip_src = IP(dst = self.IP_DST, src = ip_src) |
| 386 | ip_pkt = self.igmp_eth/igmp_ip_src |
| 387 | pkt = ip_pkt/igmp |
| 388 | if invalid_igmp_join == 'ttl': |
| 389 | set_ttl = 10 |
| 390 | IGMPv3.fixup(pkt,invalid_ttl = set_ttl) |
| 391 | else: |
| 392 | IGMPv3.fixup(pkt) |
| 393 | sendp(pkt, iface=iface) |
| 394 | if delay != 0: |
| 395 | time.sleep(delay) |
| 396 | |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 397 | def send_igmp_join_recvQuery(self, groups, rec_queryCount = None, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2): |
| 398 | self.onos_ssm_table_load(groups, src_list) |
| 399 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
| 400 | gaddr=self.IP_DST) |
| 401 | for g in groups: |
| 402 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g) |
| 403 | gr.sources = src_list |
| 404 | gr.sources = src_list |
| 405 | igmp.grps.append(gr) |
| 406 | if ip_pkt is None: |
| 407 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 408 | pkt = ip_pkt/igmp |
| 409 | IGMPv3.fixup(pkt) |
| 410 | if rec_queryCount == None: |
| 411 | log.info('Sending IGMP join for group %s and waiting for one query packet and printing the packet' %groups) |
| 412 | resp = srp1(pkt, iface=iface) |
| 413 | else: |
| 414 | log.info('Sending IGMP join for group %s and waiting for periodic query packets and printing one packet' %groups) |
| 415 | resp = srp1(pkt, iface=iface) |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 416 | resp[0].summary() |
| 417 | log.info('Sent IGMP join for group %s and received a query packet and printing packet' %groups) |
| 418 | if delay != 0: |
| 419 | time.sleep(delay) |
| 420 | |
| 421 | def send_igmp_leave(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2): |
| 422 | log.info('entering into igmp leave function') |
| 423 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
| 424 | gaddr=self.IP_DST) |
| 425 | for g in groups: |
| 426 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g) |
| 427 | gr.sources = src_list |
| 428 | igmp.grps.append(gr) |
| 429 | if ip_pkt is None: |
| 430 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 431 | pkt = ip_pkt/igmp |
| 432 | IGMPv3.fixup(pkt) |
| 433 | sendp(pkt, iface = iface) |
| 434 | if delay != 0: |
| 435 | time.sleep(delay) |
| 436 | |
| 437 | def send_igmp_leave_listening_group_specific_query(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2): |
| 438 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
| 439 | gaddr=self.IP_DST) |
| 440 | for g in groups: |
| 441 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g) |
| 442 | gr.sources = src_list |
| 443 | igmp.grps.append(gr) |
| 444 | if ip_pkt is None: |
| 445 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 446 | pkt = ip_pkt/igmp |
| 447 | IGMPv3.fixup(pkt) |
| 448 | log.info('Sending IGMP leave for group %s and waiting for one group specific query packet and printing the packet' %groups) |
| 449 | resp = srp1(pkt, iface=iface) |
| 450 | resp[0].summary() |
| 451 | log.info('Sent IGMP leave for group %s and received a group specific query packet and printing packet' %groups) |
| 452 | if delay != 0: |
| 453 | time.sleep(delay) |
| 454 | |
| 455 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+390) |
| 456 | def test_netCondition_with_delay_between_igmp_join_and_data_recv(self): |
| 457 | self.setUp_igmp() |
| 458 | randomDelay = randint(10,300) |
| 459 | groups = ['224.0.1.1', '225.0.0.1'] |
| 460 | self.onos_ssm_table_load(groups) |
| 461 | df = defer.Deferred() |
| 462 | igmpState = IGMPTestState(groups = groups, df = df) |
| 463 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 464 | igmpStateList = (igmpState, igmpStateRecv) |
| 465 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, arg = igmpState) |
| 466 | self.df = df |
| 467 | self.mcastTraffic = mcastTraffic |
| 468 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 469 | |
| 470 | def mcast_traffic_delay_start(): |
| 471 | mcastTraffic.start() |
| 472 | |
| 473 | def igmp_srp_task(stateList): |
| 474 | igmpSendState, igmpRecvState = stateList |
| 475 | if not mcastTraffic.isRecvStopped(): |
| 476 | result = self.igmp_recv(igmpRecvState) |
| 477 | reactor.callLater(0, igmp_srp_task, stateList) |
| 478 | else: |
| 479 | self.mcastTraffic.stop() |
| 480 | self.recv_socket.close() |
| 481 | self.igmp_verify_join(stateList) |
| 482 | self.df.callback(0) |
| 483 | |
| 484 | self.send_igmp_join(groups) |
| 485 | log.info('Holding multicast data for a period of random delay = {} secs'.format(randomDelay)) |
| 486 | t = Timer(randomDelay, mcast_traffic_delay_start) |
| 487 | t.start() |
| 488 | |
| 489 | self.test_timer = reactor.callLater(randomDelay+30, self.mcast_traffic_timer) |
| 490 | reactor.callLater(randomDelay+10, igmp_srp_task, igmpStateList) |
| 491 | return df |
| 492 | |
| 493 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+390) |
| 494 | def test_netCondition_with_delay_between_data_recv_and_igmp_join(self): |
| 495 | self.setUp_igmp() |
| 496 | randomDelay = randint(10,300) |
| 497 | groups = ['224.0.1.1', '225.0.0.1'] |
| 498 | self.onos_ssm_table_load(groups) |
| 499 | df = defer.Deferred() |
| 500 | igmpState = IGMPTestState(groups = groups, df = df) |
| 501 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 502 | igmpStateList = (igmpState, igmpStateRecv) |
| 503 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, arg = igmpState) |
| 504 | self.df = df |
| 505 | self.mcastTraffic = mcastTraffic |
| 506 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 507 | |
| 508 | def mcast_join_delay_start(): |
| 509 | log.info('Holding channel join for a period of random delay = {} secs'.format(randomDelay)) |
| 510 | self.send_igmp_join(groups) |
| 511 | |
| 512 | def igmp_srp_task(stateList): |
| 513 | igmpSendState, igmpRecvState = stateList |
| 514 | if not mcastTraffic.isRecvStopped(): |
| 515 | result = self.igmp_recv(igmpRecvState) |
| 516 | reactor.callLater(0, igmp_srp_task, stateList) |
| 517 | else: |
| 518 | self.mcastTraffic.stop() |
| 519 | self.recv_socket.close() |
| 520 | self.igmp_verify_join(stateList) |
| 521 | self.df.callback(0) |
| 522 | |
| 523 | mcastTraffic.start() |
| 524 | t = Timer(randomDelay, mcast_join_delay_start) |
| 525 | t.start() |
| 526 | |
| 527 | self.test_timer = reactor.callLater(randomDelay+30, self.mcast_traffic_timer) |
| 528 | reactor.callLater(randomDelay+10, igmp_srp_task, igmpStateList) |
| 529 | return df |
| 530 | |
| 531 | |
| 532 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+340) |
| 533 | def test_netCondition_with_delay_between_igmp_leave_and_data(self): |
| 534 | self.setUp_igmp() |
| 535 | randomDelay = randint(10,300) |
| 536 | groups = ['224.0.1.10', '225.0.0.10'] |
| 537 | leave_groups = ['224.0.1.10'] |
| 538 | self.onos_ssm_table_load(groups) |
| 539 | df = defer.Deferred() |
| 540 | igmpState = IGMPTestState(groups = groups, df = df) |
| 541 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 542 | igmpStateList = (igmpState, igmpStateRecv) |
| 543 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
| 544 | arg = igmpState) |
| 545 | self.df = df |
| 546 | self.mcastTraffic = mcastTraffic |
| 547 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 548 | |
| 549 | def mcast_leave_delay_start(): |
| 550 | self.send_igmp_leave(leave_groups, delay = 3) |
| 551 | join_state = IGMPTestState(groups = leave_groups) |
| 552 | status = self.igmp_not_recv_task(self.V_INF1,leave_groups, join_state) |
| 553 | log.info('Verified status for igmp recv task %s'%status) |
| 554 | assert status == 1 , 'EXPECTED RESULT' |
| 555 | self.df.callback(0) |
| 556 | |
| 557 | mcastTraffic.start() |
| 558 | self.send_igmp_join(groups) |
| 559 | log.info('Holding multicast leave packet for a period of random delay = {} secs'.format(randomDelay)) |
| 560 | t = Timer(randomDelay+10, mcast_leave_delay_start) |
| 561 | t.start() |
| 562 | return df |
| 563 | |
| 564 | def igmp_not_recv_task(self, intf, groups, join_state): |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 565 | log.info('Entering igmp not recv task loop') |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 566 | recv_socket = L2Socket(iface = intf, type = ETH_P_IP) |
| 567 | group_map = {} |
| 568 | for g in groups: |
| 569 | group_map[g] = [0,0] |
| 570 | |
| 571 | log.info('Verifying join interface should not receive any multicast data') |
| 572 | self.NEGATIVE_TRAFFIC_STATUS = 1 |
| 573 | def igmp_recv_cb(pkt): |
| 574 | log.info('Multicast packet %s received for left groups %s' %(pkt[IP].dst, groups)) |
| 575 | self.NEGATIVE_TRAFFIC_STATUS = 2 |
| 576 | sniff(prn = igmp_recv_cb, count = 1, lfilter = lambda p: IP in p and p[IP].dst in groups, |
| 577 | timeout = 3, opened_socket = recv_socket) |
| 578 | recv_socket.close() |
| 579 | return self.NEGATIVE_TRAFFIC_STATUS |
| 580 | |
| 581 | ## Its sample test case based on this test case we had added all below scenarios. |
| 582 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 583 | def test_netCondition_in_eap_tls_with_delay_between_positive_IdReq_and_tlsHelloReq(self): |
| 584 | self.setUp_tls() |
| 585 | randomDelay = randint(10,300) |
| 586 | df = defer.Deferred() |
| 587 | tls = TLSAuthTest() |
| 588 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 589 | tls._eapTlsHelloReq() |
| 590 | tls._eapTlsCertReq() |
| 591 | tls._eapTlsChangeCipherSpec() |
| 592 | tls._eapTlsFinished() |
| 593 | df.callback(0) |
| 594 | def eap_tls_verify(df): |
| 595 | tls._eapSetup() |
| 596 | tls.tlsEventTable.EVT_EAP_SETUP |
| 597 | tls._eapStart() |
| 598 | tls.tlsEventTable.EVT_EAP_START |
| 599 | tls._eapIdReq() |
| 600 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 601 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 602 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 603 | t.start() |
| 604 | reactor.callLater(0, eap_tls_verify, df) |
| 605 | return df |
| 606 | |
| 607 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 608 | def test_netCondition_in_eap_tls_with_delay_between_IdReq_and_tlsHelloReq(self): |
| 609 | self.setUp_tls() |
| 610 | randomDelay = randint(10,300) |
| 611 | df = defer.Deferred() |
| 612 | tls = TLSAuthTest() |
| 613 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 614 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 615 | tls._eapTlsHelloReq() |
| 616 | tls._eapTlsCertReq() |
| 617 | tls._eapTlsChangeCipherSpec() |
| 618 | tls._eapTlsFinished() |
| 619 | df.callback(0) |
| 620 | def eap_tls_verify(df): |
| 621 | tls._eapSetup() |
| 622 | tls.tlsEventTable.EVT_EAP_SETUP |
| 623 | tls._eapStart() |
| 624 | tls.tlsEventTable.EVT_EAP_START |
| 625 | tls._eapIdReq() |
| 626 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 627 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 628 | t.start() |
| 629 | reactor.callLater(0, eap_tls_verify, df) |
| 630 | return df |
| 631 | |
| 632 | @deferred(TEST_TIMEOUT_DELAY+100) |
| 633 | def test_netCondition_in_eap_tls_with_delay_between_tlsHelloReq_and_eapTlsCertReq(self): |
| 634 | self.setUp_tls() |
| 635 | randomDelay = randint(10,300) |
| 636 | df = defer.Deferred() |
| 637 | tls = TLSAuthTest() |
| 638 | def eap_tls_eapTlsCertReq_pkt_delay(): |
| 639 | log.info('Holding eapTlsCertReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 640 | tls._eapTlsCertReq_delay() |
| 641 | tls._eapTlsChangeCipherSpec() |
| 642 | tls._eapTlsFinished() |
| 643 | df.callback(0) |
| 644 | def eap_tls_verify(df): |
| 645 | tls._eapSetup() |
| 646 | tls.tlsEventTable.EVT_EAP_SETUP |
| 647 | tls._eapStart() |
| 648 | tls.tlsEventTable.EVT_EAP_START |
| 649 | tls._eapIdReq() |
| 650 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 651 | tls._eapTlsHelloReq() |
| 652 | while tls.server_hello_done_received == False: |
| 653 | r = tls.eapol_scapy_recv(cb = tls.eapol_server_hello_cb, |
| 654 | lfilter = |
| 655 | lambda pkt: EAP in pkt and pkt[EAP].type == EAP_TYPE_TLS and \ |
| 656 | pkt[EAP].code == EAP.REQUEST) |
| 657 | if len(r) == 0: |
| 658 | tls.tlsFail() |
| 659 | t = Timer(randomDelay, eap_tls_eapTlsCertReq_pkt_delay) |
| 660 | t.start() |
| 661 | reactor.callLater(0, eap_tls_verify, df) |
| 662 | return df |
| 663 | |
| 664 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 665 | def test_netCondition_in_eap_tls_with_delay_between_TlsCertReq_and_TlsChangeCipherSpec(self): |
| 666 | self.setUp_tls() |
| 667 | randomDelay = randint(10,300) |
| 668 | df = defer.Deferred() |
| 669 | tls = TLSAuthTest() |
| 670 | def eap_tls_TlsChangeCipherSpec_pkt_delay(): |
| 671 | log.info('Holding TlsChangeCipherSpec packet for a period of random delay = {} secs'.format(randomDelay)) |
| 672 | tls._eapTlsChangeCipherSpec() |
| 673 | tls._eapTlsFinished() |
| 674 | df.callback(0) |
| 675 | def eap_tls_verify(df): |
| 676 | tls._eapSetup() |
| 677 | tls.tlsEventTable.EVT_EAP_SETUP |
| 678 | tls._eapStart() |
| 679 | tls.tlsEventTable.EVT_EAP_START |
| 680 | tls._eapIdReq() |
| 681 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 682 | tls._eapTlsHelloReq() |
| 683 | tls._eapTlsCertReq() |
| 684 | t = Timer(randomDelay, eap_tls_TlsChangeCipherSpec_pkt_delay) |
| 685 | t.start() |
| 686 | reactor.callLater(0, eap_tls_verify, df) |
| 687 | return df |
| 688 | |
| 689 | @deferred(TEST_TIMEOUT_DELAY+50) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 690 | def test_netCondition_in_eap_tls_with_no_cert_and_delay_between_IdReq_and_HelloReq(self): |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 691 | self.setUp_tls() |
| 692 | randomDelay = randint(10,300) |
| 693 | df = defer.Deferred() |
| 694 | def tls_no_cert_cb(): |
| 695 | log.info('TLS authentication failed with no certificate') |
| 696 | tls = TLSAuthTest(fail_cb = tls_no_cert_cb, client_cert = '') |
| 697 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 698 | log.info('Holding HelloReq packet with no cert for a period of random delay = {} secs'.format(randomDelay)) |
| 699 | tls._eapTlsHelloReq() |
| 700 | tls._eapTlsCertReq() |
| 701 | assert_equal(tls.failTest, True) |
| 702 | tls._eapTlsChangeCipherSpec() |
| 703 | tls._eapTlsFinished() |
| 704 | df.callback(0) |
| 705 | def eap_tls_no_cert(df): |
| 706 | tls._eapSetup() |
| 707 | tls.tlsEventTable.EVT_EAP_SETUP |
| 708 | tls._eapStart() |
| 709 | tls.tlsEventTable.EVT_EAP_START |
| 710 | tls._eapIdReq() |
| 711 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 712 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 713 | t.start() |
| 714 | reactor.callLater(0, eap_tls_no_cert, df) |
| 715 | return df |
| 716 | |
| 717 | @deferred(TEST_TIMEOUT_DELAY+100) |
| 718 | def test_netCondition_in_eap_tls_with_delay_and_no_cert_between_tlsHelloReq_and_eapTlsCertReq(self): |
| 719 | self.setUp_tls() |
| 720 | randomDelay = randint(10,300) |
| 721 | df = defer.Deferred() |
| 722 | def tls_no_cert_cb(): |
| 723 | log.info('TLS authentication failed with no certificate') |
| 724 | tls = TLSAuthTest(fail_cb = tls_no_cert_cb, client_cert = '') |
| 725 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 726 | log.info('Holding eapTlsCertReq packet with no cert for a period of random delay = {} secs'.format(randomDelay)) |
| 727 | tls._eapTlsCertReq_delay() |
| 728 | assert_equal(tls.failTest, True) |
| 729 | tls._eapTlsChangeCipherSpec() |
| 730 | assert_equal(tls.failTest, True) |
| 731 | tls._eapTlsFinished() |
| 732 | df.callback(0) |
| 733 | def eap_tls_no_cert(df): |
| 734 | tls._eapSetup() |
| 735 | tls.tlsEventTable.EVT_EAP_SETUP |
| 736 | tls._eapStart() |
| 737 | tls.tlsEventTable.EVT_EAP_START |
| 738 | tls._eapIdReq() |
| 739 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 740 | tls._eapTlsHelloReq() |
| 741 | while tls.server_hello_done_received == False: |
| 742 | r = tls.eapol_scapy_recv(cb = tls.eapol_server_hello_cb, |
| 743 | lfilter = |
| 744 | lambda pkt: EAP in pkt and pkt[EAP].type == EAP_TYPE_TLS and \ |
| 745 | pkt[EAP].code == EAP.REQUEST) |
| 746 | if len(r) == 0: |
| 747 | tls.tlsFail() |
| 748 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 749 | t.start() |
| 750 | reactor.callLater(0, eap_tls_no_cert, df) |
| 751 | return df |
| 752 | |
| 753 | |
| 754 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 755 | def test_netCondition_in_eap_tls_with_delay_and_no_cert_between_TlsCertReq_and_TlsChangeCipherSpec(self): |
| 756 | self.setUp_tls() |
| 757 | randomDelay = randint(10,300) |
| 758 | df = defer.Deferred() |
| 759 | def tls_no_cert_cb(): |
| 760 | log.info('TLS authentication failed with no certificate') |
| 761 | tls = TLSAuthTest(fail_cb = tls_no_cert_cb, client_cert = '') |
| 762 | def eap_tls_TlsChangeCipherSpec_pkt_delay(): |
| 763 | tls._eapTlsChangeCipherSpec() |
| 764 | assert_equal(tls.failTest, True) |
| 765 | tls._eapTlsFinished() |
| 766 | df.callback(0) |
| 767 | def eap_tls_no_cert(df): |
| 768 | tls._eapSetup() |
| 769 | tls.tlsEventTable.EVT_EAP_SETUP |
| 770 | tls._eapStart() |
| 771 | tls._eapIdReq() |
| 772 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 773 | tls._eapTlsHelloReq() |
| 774 | tls._eapTlsCertReq() |
| 775 | log.info('Holding TlsChangeCipherSpec packet with no cert for a period of random delay = {} secs'.format(randomDelay)) |
| 776 | t = Timer(randomDelay, eap_tls_TlsChangeCipherSpec_pkt_delay) |
| 777 | t.start() |
| 778 | reactor.callLater(0, eap_tls_no_cert, df) |
| 779 | return df |
| 780 | |
| 781 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 782 | def test_netCondition_in_eap_tls_with_invalid_cert_and_delay_between_IdReq_and_HelloReq(self): |
| 783 | self.setUp_tls() |
| 784 | randomDelay = randint(10,300) |
| 785 | df = defer.Deferred() |
| 786 | def tls_invalid_cert_cb(): |
| 787 | log.info('TLS authentication failed with invalid certificate') |
| 788 | tls = TLSAuthTest(fail_cb = tls_invalid_cert_cb, client_cert = self.CLIENT_CERT_INVALID) |
| 789 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 790 | tls._eapTlsHelloReq() |
| 791 | tls._eapTlsCertReq() |
| 792 | assert_equal(tls.failTest, True) |
| 793 | tls._eapTlsChangeCipherSpec() |
| 794 | tls._eapTlsFinished() |
| 795 | df.callback(0) |
| 796 | def eap_tls_invalid_cert(df): |
| 797 | tls._eapSetup() |
| 798 | tls.tlsEventTable.EVT_EAP_SETUP |
| 799 | tls._eapStart() |
| 800 | tls.tlsEventTable.EVT_EAP_START |
| 801 | tls._eapIdReq() |
| 802 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 803 | log.info('Holding HelloReq packet with invalid cert for a period of random delay = {} secs'.format(randomDelay)) |
| 804 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 805 | t.start() |
| 806 | reactor.callLater(0, eap_tls_invalid_cert, df) |
| 807 | return df |
| 808 | |
| 809 | @deferred(TEST_TIMEOUT_DELAY+100) |
| 810 | def test_netCondition_in_eap_tls_with_invalid_cert_and_delay_between_tlsHelloReq_and_eapTlsCertReq(self): |
| 811 | self.setUp_tls() |
| 812 | randomDelay = randint(10,300) |
| 813 | df = defer.Deferred() |
| 814 | def tls_invalid_cert_cb(): |
| 815 | log.info('TLS authentication failed with invalid certificate') |
| 816 | tls = TLSAuthTest(fail_cb = tls_invalid_cert_cb, client_cert = self.CLIENT_CERT_INVALID) |
| 817 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
ChetanGaonker | 12f9f42 | 2016-11-10 23:21:21 -0800 | [diff] [blame] | 818 | log.info('Holding eapTlsCertReq packet with invalid cert for a period of random delay = {} sec, delay'.format(randomDelay)) |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 819 | tls._eapTlsCertReq_delay() |
| 820 | tls._eapTlsChangeCipherSpec() |
| 821 | assert_equal(tls.failTest, True) |
| 822 | tls._eapTlsFinished() |
| 823 | df.callback(0) |
| 824 | def eap_tls_invalid_cert(df): |
| 825 | tls._eapSetup() |
| 826 | tls.tlsEventTable.EVT_EAP_SETUP |
| 827 | tls._eapStart() |
| 828 | tls.tlsEventTable.EVT_EAP_START |
| 829 | tls._eapIdReq() |
| 830 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 831 | tls._eapTlsHelloReq() |
| 832 | while tls.server_hello_done_received == False: |
| 833 | r = tls.eapol_scapy_recv(cb = tls.eapol_server_hello_cb, |
| 834 | lfilter = |
| 835 | lambda pkt: EAP in pkt and pkt[EAP].type == EAP_TYPE_TLS and \ |
| 836 | pkt[EAP].code == EAP.REQUEST) |
| 837 | if len(r) == 0: |
| 838 | tls.tlsFail() |
| 839 | |
| 840 | log.info('Holding eapTlsCertReq packet with invalid cert for a period of random delay = {} secs'.format(randomDelay)) |
| 841 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 842 | t.start() |
| 843 | reactor.callLater(0, eap_tls_invalid_cert, df) |
| 844 | return df |
| 845 | |
| 846 | |
| 847 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 848 | def test_netCondition_in_eap_tls_with_invalid_cert_delay_between_TlsCertReq_and_TlsChangeCipherSpec(self): |
| 849 | self.setUp_tls() |
| 850 | randomDelay = randint(10,300) |
| 851 | df = defer.Deferred() |
| 852 | def tls_invalid_cert_cb(): |
| 853 | log.info('TLS authentication failed with invalid certificate') |
| 854 | tls = TLSAuthTest(fail_cb = tls_invalid_cert_cb, client_cert = self.CLIENT_CERT_INVALID) |
| 855 | def eap_tls_TlsChangeCipherSpec_pkt_delay(): |
| 856 | tls._eapTlsChangeCipherSpec() |
| 857 | assert_equal(tls.failTest, True) |
| 858 | tls._eapTlsFinished() |
| 859 | df.callback(0) |
| 860 | def eap_tls_invalid_cert(df): |
| 861 | tls._eapSetup() |
| 862 | tls.tlsEventTable.EVT_EAP_SETUP |
| 863 | tls._eapStart() |
| 864 | tls.tlsEventTable.EVT_EAP_START |
| 865 | tls._eapIdReq() |
| 866 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 867 | tls._eapTlsHelloReq() |
| 868 | tls._eapTlsCertReq() |
| 869 | log.info('Holding TlsChangeCipherSpec packet with invalid cert for a period of random delay = {} secs'.format(randomDelay)) |
| 870 | t = Timer(randomDelay, eap_tls_TlsChangeCipherSpec_pkt_delay) |
| 871 | t.start() |
| 872 | reactor.callLater(0, eap_tls_invalid_cert, df) |
| 873 | return df |
| 874 | |
| 875 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 876 | def test_netCondition_in_multiple_eap_tls_requests_with_delay_between_IdReq_and_HelloReq(self): |
| 877 | self.setUp_tls() |
| 878 | df = defer.Deferred() |
| 879 | threads = [] |
| 880 | clients = 10 |
| 881 | def eap_tls_eapTlsHelloReq_pkt_delay(df): |
| 882 | def multiple_tls_random_delay(): |
| 883 | randomDelay = randint(10,300) |
| 884 | tls = TLSAuthTest(src_mac = 'random') |
| 885 | tls._eapSetup() |
| 886 | tls.tlsEventTable.EVT_EAP_SETUP |
| 887 | tls._eapStart() |
| 888 | tls.tlsEventTable.EVT_EAP_START |
| 889 | tls._eapIdReq() |
| 890 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 891 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 892 | time.sleep(randomDelay) |
| 893 | tls._eapTlsHelloReq() |
| 894 | tls._eapTlsCertReq() |
| 895 | tls._eapTlsChangeCipherSpec() |
| 896 | tls._eapTlsFinished() |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 897 | log.info('Authentication successful for user %d'%i) |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 898 | # Sending multiple tls clients and making random delay in between client and server packets. |
| 899 | for i in xrange(clients): |
| 900 | thread = threading.Thread(target = multiple_tls_random_delay) |
| 901 | time.sleep(randint(1,2)) |
| 902 | thread.start() |
| 903 | threads.append(thread) |
| 904 | time.sleep(300) |
| 905 | for thread in threads: |
| 906 | thread.join() |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 907 | reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df) |
| 908 | return df |
| 909 | |
| 910 | @deferred(TEST_TIMEOUT_DELAY+450) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 911 | def test_netCondition_with_multiple_authentication_and_delay_between_complete_authentication(self): |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 912 | self.setUp_tls() |
| 913 | df = defer.Deferred() |
| 914 | threads = [] |
| 915 | clients = 100 |
| 916 | def eap_tls_eapTlsHelloReq_pkt_delay(df): |
| 917 | def multiple_tls_random_delay(): |
| 918 | randomDelay = randint(10,300) |
| 919 | tls = TLSAuthTest(src_mac = 'random') |
| 920 | tls._eapSetup() |
| 921 | tls.tlsEventTable.EVT_EAP_SETUP |
| 922 | tls._eapStart() |
| 923 | tls.tlsEventTable.EVT_EAP_START |
| 924 | tls._eapIdReq() |
| 925 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 926 | tls._eapTlsHelloReq() |
| 927 | tls._eapTlsCertReq() |
| 928 | tls._eapTlsChangeCipherSpec() |
| 929 | tls._eapTlsFinished() |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 930 | log.info('Authentication successful for user %d'%i) |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 931 | # Client authendicating multiple times one after other and making random delay in between authendication. |
| 932 | for i in xrange(clients): |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 933 | multiple_tls_random_delay() |
| 934 | time.sleep(randomDelay) |
| 935 | df.callback(0) |
| 936 | reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df) |
| 937 | return df |
| 938 | |
| 939 | @deferred(TEST_TIMEOUT_DELAY+450) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 940 | def test_netCondition_with_multiple_authentication_and_delay_between_every_100_tls_burst(self): |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 941 | self.setUp_tls() |
| 942 | randomDelay = randint(10,300) |
| 943 | df = defer.Deferred() |
| 944 | threads = [] |
| 945 | tls = [] |
| 946 | clients = 10 |
| 947 | def eap_tls_eapTlsHelloReq_pkt_delay(df): |
| 948 | def multiple_tls_random_delay(): |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 949 | for x in xrange(clients): |
| 950 | tls.append(TLSAuthTest(src_mac = 'random')) |
| 951 | for x in xrange(clients): |
| 952 | tls[x]._eapSetup() |
| 953 | tls[x].tlsEventTable.EVT_EAP_SETUP |
| 954 | for x in xrange(clients): |
| 955 | tls[x]._eapStart() |
| 956 | tls[x].tlsEventTable.EVT_EAP_START |
| 957 | for x in xrange(clients): |
| 958 | tls[x]._eapIdReq() |
| 959 | tls[x].tlsEventTable.EVT_EAP_ID_REQ |
| 960 | for x in xrange(clients): |
| 961 | tls[x]._eapTlsHelloReq() |
| 962 | for x in xrange(clients): |
| 963 | tls[x]._eapTlsCertReq() |
| 964 | for x in xrange(clients): |
| 965 | tls[x]._eapTlsChangeCipherSpec() |
| 966 | for x in xrange(clients): |
| 967 | tls[x]._eapTlsFinished() |
| 968 | for x in xrange(clients): |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 969 | log.info('Authentication successful for user %d'%i) |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 970 | # Client authendicating multiple times one after other and making random delay in between authendication. |
| 971 | for i in xrange(2): |
| 972 | multiple_tls_random_delay() |
| 973 | time.sleep(randomDelay) |
| 974 | df.callback(0) |
| 975 | reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df) |
| 976 | return df |
| 977 | |
| 978 | @deferred(TEST_TIMEOUT_DELAY+90) |
| 979 | def test_netCondition_with_delay_between_mac_flow_and_traffic(self): |
| 980 | df = defer.Deferred() |
| 981 | randomDelay = randint(10,300) |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 982 | egress = 1 |
| 983 | ingress = 2 |
| 984 | egress_mac = '00:00:00:00:00:01' |
| 985 | ingress_mac = '00:00:00:00:00:02' |
| 986 | pkt = Ether(src = ingress_mac, dst = egress_mac)/IP() |
| 987 | self.success = False |
| 988 | |
| 989 | def mac_recv_task(): |
| 990 | def recv_cb(pkt): |
| 991 | log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst)) |
| 992 | self.success = True |
| 993 | sniff(count=2, timeout=randomDelay+50, lfilter = lambda p: p.src == ingress_mac, |
| 994 | prn = recv_cb, iface = self.port_map[egress]) |
| 995 | |
| 996 | thread = threading.Thread(target = mac_recv_task) |
| 997 | |
| 998 | def send_flow_pkt_delay(): |
| 999 | sendp(pkt, count=50, iface = self.port_map[ingress]) |
| 1000 | thread.join() |
| 1001 | assert_equal(self.success, True) |
| 1002 | df.callback(0) |
| 1003 | |
| 1004 | def creating_mac_flow(df): |
| 1005 | |
| 1006 | flow = OnosFlowCtrl(deviceId = self.device_id, |
| 1007 | egressPort = egress, |
| 1008 | ingressPort = ingress, |
| 1009 | ethSrc = ingress_mac, |
| 1010 | ethDst = egress_mac) |
| 1011 | result = flow.addFlow() |
| 1012 | assert_equal(result, True) |
| 1013 | ##wait for flows to be added to ONOS |
| 1014 | time.sleep(1) |
| 1015 | thread.start() |
| 1016 | log.info('Holding a packet to verify if flows are active after {} secs'.format(randomDelay)) |
| 1017 | t = Timer(randomDelay, send_flow_pkt_delay) |
| 1018 | t.start() |
| 1019 | reactor.callLater(0, creating_mac_flow, df) |
| 1020 | return df |
| 1021 | |
| 1022 | |
| 1023 | @deferred(TEST_TIMEOUT_DELAY+90) |
| 1024 | def test_netCondition_with_delay_between_ip_flow_and_traffic(self): |
| 1025 | df = defer.Deferred() |
| 1026 | randomDelay = randint(10,300) |
| 1027 | egress = 1 |
| 1028 | ingress = 2 |
| 1029 | egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' } |
| 1030 | ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' } |
| 1031 | L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether']) |
| 1032 | L3 = IP(src = ingress_map['ip'], dst = egress_map['ip']) |
| 1033 | pkt = L2/L3 |
| 1034 | |
| 1035 | def mac_recv_task(): |
| 1036 | def recv_cb(pkt): |
| 1037 | log.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst)) |
| 1038 | self.success = True |
| 1039 | sniff(count=2, timeout= randomDelay + 30, |
| 1040 | lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip'], |
| 1041 | prn = recv_cb, iface = self.port_map[egress]) |
| 1042 | |
| 1043 | thread = threading.Thread(target = mac_recv_task) |
| 1044 | |
| 1045 | def send_flow_ip_pkt_delay(): |
| 1046 | sendp(pkt, count=50, iface = self.port_map[ingress]) |
| 1047 | thread.join() |
| 1048 | assert_equal(self.success, True) |
| 1049 | df.callback(0) |
| 1050 | |
| 1051 | def creating_ip_flow(df): |
| 1052 | flow = OnosFlowCtrl(deviceId = self.device_id, |
| 1053 | egressPort = egress, |
| 1054 | ingressPort = ingress, |
| 1055 | ethType = '0x0800', |
| 1056 | ipSrc = ('IPV4_SRC', ingress_map['ip']+'/32'), |
| 1057 | ipDst = ('IPV4_DST', egress_map['ip']+'/32') |
| 1058 | ) |
| 1059 | result = flow.addFlow() |
| 1060 | assert_equal(result, True) |
| 1061 | ##wait for flows to be added to ONOS |
| 1062 | time.sleep(1) |
| 1063 | self.success = False |
| 1064 | ##wait for flows to be added to ONOS |
| 1065 | time.sleep(1) |
| 1066 | thread.start() |
| 1067 | log.info('Holding a packet to verify if flows are active after {} secs'.format(randomDelay)) |
| 1068 | t = Timer(randomDelay, send_flow_ip_pkt_delay) |
| 1069 | t.start() |
| 1070 | reactor.callLater(0, creating_ip_flow, df) |
| 1071 | return df |
| 1072 | |
| 1073 | @deferred(TEST_TIMEOUT_DELAY+90) |
| 1074 | def test_netCondition_with_delay_between_tcp_port_flow_and_traffic(self): |
| 1075 | df = defer.Deferred() |
| 1076 | egress = 1 |
| 1077 | ingress = 2 |
| 1078 | egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 9500 } |
| 1079 | ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 9000 } |
| 1080 | L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether']) |
| 1081 | L3 = IP(src = ingress_map['ip'], dst = egress_map['ip']) |
| 1082 | L4 = TCP(sport = ingress_map['tcp_port'], dport = egress_map['tcp_port']) |
| 1083 | pkt = L2/L3/L4 |
| 1084 | |
| 1085 | def mac_recv_task(): |
| 1086 | def recv_cb(pkt): |
| 1087 | log.info('Pkt seen with ingress TCP port %s, egress TCP port %s' %(pkt[TCP].sport, pkt[TCP].dport)) |
| 1088 | self.success = True |
| 1089 | sniff(count=2, timeout= randomDelay+30, lfilter = lambda p: TCP in p and p[TCP].dport == egress_map['tcp_port'] |
| 1090 | and p[TCP].sport == ingress_map['tcp_port'], prn = recv_cb, iface = self.port_map[egress]) |
| 1091 | |
| 1092 | thread = threading.Thread(target = mac_recv_task) |
| 1093 | |
| 1094 | def send_flow_tcp_pkt_delay(): |
| 1095 | sendp(pkt, count=50, iface = self.port_map[ingress]) |
| 1096 | thread.join() |
| 1097 | assert_equal(self.success, True) |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 1098 | |
| 1099 | def creating_tcp_flow(df): |
| 1100 | flow = OnosFlowCtrl(deviceId = self.device_id, |
| 1101 | egressPort = egress, |
| 1102 | ingressPort = ingress, |
| 1103 | tcpSrc = ingress_map['tcp_port'], |
| 1104 | tcpDst = egress_map['tcp_port'] |
| 1105 | ) |
| 1106 | result = flow.addFlow() |
| 1107 | assert_equal(result, True) |
| 1108 | ##wait for flows to be added to ONOS |
| 1109 | time.sleep(1) |
| 1110 | self.success = False |
| 1111 | thread.start() |
ChetanGaonker | 12f9f42 | 2016-11-10 23:21:21 -0800 | [diff] [blame] | 1112 | log.info('Holding a packet to verify if flows are active after {} sec, delay'.format(randomDelay)) |
| 1113 | t = Timer(randomDelay, send_flow_tcp_pkt_delay) |
ChetanGaonker | 3441faf | 2016-10-27 12:15:21 -0700 | [diff] [blame] | 1114 | t.start() |
| 1115 | df.callback(0) |
| 1116 | reactor.callLater(0, creating_tcp_flow, df) |
| 1117 | return df |
| 1118 | |
| 1119 | @deferred(TEST_TIMEOUT_DELAY+90) |
| 1120 | def test_netCondition_with_delay_between_udp_port_flow_and_traffic(self): |
| 1121 | df = defer.Deferred() |
| 1122 | randomDelay = randint(10,300) |
| 1123 | egress = 1 |
| 1124 | ingress = 2 |
| 1125 | egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 9500 } |
| 1126 | ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 9000 } |
| 1127 | L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether']) |
| 1128 | L3 = IP(src = ingress_map['ip'], dst = egress_map['ip']) |
| 1129 | L4 = UDP(sport = ingress_map['udp_port'], dport = egress_map['udp_port']) |
| 1130 | pkt = L2/L3/L4 |
| 1131 | |
| 1132 | def mac_recv_task(): |
| 1133 | def recv_cb(pkt): |
| 1134 | log.info('Pkt seen with ingress UDP port %s, egress UDP port %s' %(pkt[UDP].sport, pkt[UDP].dport)) |
| 1135 | self.success = True |
| 1136 | sniff(count=2, timeout=randomDelay + 30, |
| 1137 | lfilter = lambda p: UDP in p and p[UDP].dport == egress_map['udp_port'] |
| 1138 | and p[UDP].sport == ingress_map['udp_port'], prn = recv_cb, iface = self.port_map[egress]) |
| 1139 | |
| 1140 | thread = threading.Thread(target = mac_recv_task) |
| 1141 | |
| 1142 | def send_flow_udp_pkt_delay(): |
| 1143 | sendp(pkt, count=50, iface = self.port_map[ingress]) |
| 1144 | thread.join() |
| 1145 | assert_equal(self.success, True) |
| 1146 | df.callback(0) |
| 1147 | |
| 1148 | def creating_udp_flow(df): |
| 1149 | flow = OnosFlowCtrl(deviceId = self.device_id, |
| 1150 | egressPort = egress, |
| 1151 | ingressPort = ingress, |
| 1152 | udpSrc = ingress_map['udp_port'], |
| 1153 | udpDst = egress_map['udp_port'] |
| 1154 | ) |
| 1155 | result = flow.addFlow() |
| 1156 | assert_equal(result, True) |
| 1157 | ##wait for flows to be added to ONOS |
| 1158 | time.sleep(1) |
| 1159 | self.success = False |
| 1160 | thread.start() |
| 1161 | log.info('Holding a packet to verify if flows are active after {} secs'.format(randomDelay)) |
| 1162 | t = Timer(randomDelay, send_flow_udp_pkt_delay) |
| 1163 | t.start() |
| 1164 | |
| 1165 | df.callback(0) |
| 1166 | reactor.callLater(0, creating_udp_flow, df) |
| 1167 | return df |
| 1168 | |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1169 | 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): |
| 1170 | self.setUp_igmp() |
ChetanGaonker | 12f9f42 | 2016-11-10 23:21:21 -0800 | [diff] [blame] | 1171 | randomDelay = [] |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1172 | groups = [] |
| 1173 | sources = [] |
| 1174 | subscribers_src_ip = [] |
| 1175 | status = [] |
| 1176 | join_threads = [] |
| 1177 | delay_threads = [] |
| 1178 | data_threads = [] |
| 1179 | threads = [] |
| 1180 | subscriber = users |
| 1181 | count = 1 |
| 1182 | mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = group_end_ip) |
| 1183 | sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = source_list_end_ip) |
| 1184 | subscriber_sourceips = self.source_ip_range(start_ip = '20.20.0.1',end_ip = user_src_end_ip) |
| 1185 | while count<=subscriber: |
| 1186 | group = random.choice(mcastips) |
| 1187 | source = random.choice(sourceips) |
| 1188 | subscriber_sourceip = random.choice(subscriber_sourceips) |
| 1189 | if group in groups: |
| 1190 | pass |
| 1191 | else: |
| 1192 | log.info('group = %s source list = %s and subscriber source ip in join = %s'%(group,source, subscriber_sourceip)) |
| 1193 | groups.append(group) |
| 1194 | sources.append(source) |
| 1195 | subscribers_src_ip.append(subscriber_sourceip) |
| 1196 | count += 1 |
| 1197 | self.onos_ssm_table_load(groups,src_list=sources,flag=True) |
| 1198 | |
| 1199 | def multiple_joins_send_in_threads(group, source, subscriber_src_ip,data_pkt = data_pkt): |
| 1200 | self.send_igmp_join(groups = [group], src_list = [source],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1201 | iface = self.V_INF1, ip_src = [subscriber_src_ip]) |
ChetanGaonker | 12f9f42 | 2016-11-10 23:21:21 -0800 | [diff] [blame] | 1202 | randomDelay_in_thread = randint(10,30) |
| 1203 | log.info('This is running in a thread, with igmp join sent and delay {}'.format(randomDelay_in_thread)) |
| 1204 | time.sleep(randomDelay_in_thread) |
| 1205 | log.info('This is running in a thread, with igmp join sent and delay {}'.format(randomDelay_in_thread)) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1206 | status = self.verify_igmp_data_traffic_in_thread(group,intf=self.V_INF1,source=source, data_pkt = data_pkt) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1207 | log.info('Data received for group %s from source %s and status is %s '%(group,source,status)) |
| 1208 | self.igmp_threads_result.append(status) |
| 1209 | |
| 1210 | for i in range(subscriber): |
| 1211 | thread = threading.Thread(target = multiple_joins_send_in_threads, args = (groups[i], sources[i], subscribers_src_ip[i])) |
| 1212 | time.sleep(randint(1,2)) |
| 1213 | thread.start() |
| 1214 | threads.append(thread) |
| 1215 | |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1216 | for thread in threads: |
| 1217 | thread.join() |
| 1218 | |
| 1219 | def verify_igmp_data_traffic_in_thread(self, group, intf='veth0', source='1.2.3.4', data_pkt =50, negative = None): |
| 1220 | log.info('Verifying multicast traffic for group %s from source %s'%(group,source)) |
| 1221 | self.success = False |
| 1222 | def recv_task(): |
| 1223 | def igmp_recv_cb(pkt): |
| 1224 | #log.info('received multicast data packet is %s'%pkt.show()) |
| 1225 | log.info('Multicast data received for group %s from source %s'%(group,source)) |
| 1226 | self.success = True |
| 1227 | 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') |
| 1228 | t = threading.Thread(target = recv_task) |
| 1229 | t.start() |
| 1230 | self.send_multicast_data_traffic_from_thread(group,source=source, data_pkt=data_pkt) |
| 1231 | t.join() |
| 1232 | if (negative is None) and self.success is True: |
| 1233 | return self.success |
| 1234 | elif (negative is not None) and self.success is True: |
| 1235 | log.info('Multicast traffic should not received because this is negative scenario, but it is received') |
| 1236 | self.success = False |
| 1237 | elif (negative is not None) and self.success is False: |
| 1238 | log.info('Multicast traffic should is not received because this is negative scenario, hence status is True') |
| 1239 | self.success = True |
| 1240 | return self.success |
| 1241 | |
| 1242 | def send_multicast_data_traffic_from_thread(self, group, intf= 'veth2',source = '1.2.3.4', data_pkt = 50): |
| 1243 | dst_mac = self.iptomac_convert(group) |
| 1244 | eth = Ether(dst= dst_mac) |
| 1245 | ip = IP(dst=group,src=source) |
| 1246 | data = repr(monotonic.monotonic()) |
| 1247 | log.info('Sending %s number of multicast packet to the multicast group %s'%(data_pkt, group)) |
| 1248 | sendp(eth/ip/data,count=data_pkt, iface = intf) |
| 1249 | pkt = (eth/ip/data) |
| 1250 | #log.info('multicast traffic packet %s'%pkt.show()) |
| 1251 | |
| 1252 | def iptomac_convert(self, mcast_ip): |
| 1253 | mcast_mac = '01:00:5e:' |
| 1254 | octets = mcast_ip.split('.') |
| 1255 | second_oct = int(octets[1]) & 127 |
| 1256 | third_oct = int(octets[2]) |
| 1257 | fourth_oct = int(octets[3]) |
| 1258 | mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x') |
| 1259 | return mcast_mac |
| 1260 | |
| 1261 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 1262 | def test_netCondition_with_delay_between_multiple_igmp_joins_and_data_for_multiple_subscribers(self): |
| 1263 | self.setUp_tls() |
| 1264 | df = defer.Deferred() |
| 1265 | log.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result)) |
| 1266 | def netCondition_multiple_igmp_joins_and_data(df): |
| 1267 | ### 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 |
| 1268 | no_users = 10 |
| 1269 | group_end_ip = '229.0.30.254' |
| 1270 | source_list_end_ip = '10.10.30.254' |
| 1271 | subscriber_src_end_ip = '20.20.20.254' |
| 1272 | self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip, |
| 1273 | source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip ) |
| 1274 | log.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result)) |
| 1275 | for i in xrange(no_users): |
| 1276 | log.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i])) |
| 1277 | if assert_equal(self.igmp_threads_result[i], True) is True: |
| 1278 | df.callback(0) |
| 1279 | df.callback(0) |
| 1280 | reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df) |
| 1281 | return df |
| 1282 | |
| 1283 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 1284 | def test_netCondition_with_delay_between_multiple_igmp_joins_and_data_from_multiple_subscribers_with_low_multicast_data_rate(self): |
| 1285 | self.setUp_tls() |
| 1286 | df = defer.Deferred() |
| 1287 | log.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result)) |
| 1288 | def netCondition_multiple_igmp_joins_and_data(df): |
| 1289 | ### 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 |
| 1290 | no_users = 10 |
| 1291 | group_end_ip = '229.0.30.254' |
| 1292 | source_list_end_ip = '10.10.30.254' |
| 1293 | subscriber_src_end_ip = '20.20.20.254' |
| 1294 | self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip, |
| 1295 | source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip, data_pkt = 20) |
| 1296 | log.info('IGMP Thread status after running igmp thread %s '%(self.igmp_threads_result)) |
| 1297 | for i in xrange(no_users): |
| 1298 | log.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i])) |
| 1299 | if assert_equal(self.igmp_threads_result[i], True) is True: |
| 1300 | df.callback(0) |
| 1301 | df.callback(0) |
| 1302 | reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df) |
| 1303 | return df |
| 1304 | |
| 1305 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 1306 | def test_netCondition_with_delay_between_multiple_igmp_joins_and_data_for_same_subscriber(self): |
| 1307 | self.setUp_tls() |
| 1308 | df = defer.Deferred() |
| 1309 | log.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result)) |
| 1310 | def netCondition_multiple_igmp_joins_and_data(df): |
| 1311 | ### 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 |
| 1312 | no_users = 5 |
| 1313 | group_end_ip = '229.0.30.254' |
| 1314 | source_list_end_ip = '10.10.30.254' |
| 1315 | subscriber_src_end_ip = '20.20.0.1' |
| 1316 | self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip, |
| 1317 | source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip ) |
| 1318 | log.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result)) |
| 1319 | for i in xrange(no_users): |
| 1320 | log.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i])) |
| 1321 | if assert_equal(self.igmp_threads_result[i], True) is True: |
| 1322 | df.callback(0) |
| 1323 | df.callback(0) |
| 1324 | reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df) |
| 1325 | return df |
| 1326 | |
| 1327 | |
| 1328 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 1329 | def test_netCondition_with_delay_between_same_igmp_joins_and_data_from_multiple_subscriber(self): |
| 1330 | self.setUp_tls() |
| 1331 | df = defer.Deferred() |
| 1332 | log.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result)) |
| 1333 | def netCondition_multiple_igmp_joins_and_data(df): |
| 1334 | ### 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 |
| 1335 | no_users = 100 |
| 1336 | group_end_ip = '229.0.0.1' |
| 1337 | source_list_end_ip = '10.10.30.254' |
| 1338 | subscriber_src_end_ip = '20.20.20.254' |
| 1339 | self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip, |
| 1340 | source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip ) |
| 1341 | log.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result)) |
| 1342 | for i in xrange(no_users): |
| 1343 | log.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i])) |
| 1344 | if assert_equal(self.igmp_threads_result[i], True) is True: |
| 1345 | df.callback(0) |
| 1346 | df.callback(0) |
| 1347 | reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df) |
| 1348 | return df |
| 1349 | |
| 1350 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 1351 | def test_netCondition_with_delay_between_multiple_igmp_joins_and_data_from_same_sourcelist_for_multiple_subscriber(self): |
| 1352 | self.setUp_tls() |
| 1353 | df = defer.Deferred() |
| 1354 | log.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result)) |
| 1355 | def netCondition_multiple_igmp_joins_and_data(df): |
| 1356 | ### 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 |
| 1357 | no_users = 20 |
| 1358 | group_end_ip = '229.0.30.254' |
| 1359 | source_list_end_ip = '10.10.0.1' |
| 1360 | subscriber_src_end_ip = '20.20.20.254' |
| 1361 | self.netCondition_with_delay_between_multiple_igmp_joins_and_data(users = no_users, group_end_ip = group_end_ip, |
| 1362 | source_list_end_ip = source_list_end_ip, user_src_end_ip = subscriber_src_end_ip ) |
| 1363 | log.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result)) |
| 1364 | for i in xrange(no_users): |
| 1365 | log.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i])) |
| 1366 | if assert_equal(self.igmp_threads_result[i], True) is True: |
| 1367 | df.callback(0) |
| 1368 | df.callback(0) |
| 1369 | reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df) |
| 1370 | return df |
| 1371 | |
| 1372 | |
| 1373 | 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): |
| 1374 | self.setUp_igmp() |
ChetanGaonker | 12f9f42 | 2016-11-10 23:21:21 -0800 | [diff] [blame] | 1375 | randomDelay = [] |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1376 | groups = [] |
| 1377 | sources = [] |
| 1378 | subscribers_src_ip = [] |
| 1379 | status = [] |
| 1380 | join_threads = [] |
| 1381 | delay_threads = [] |
| 1382 | data_threads = [] |
| 1383 | threads = [] |
| 1384 | subscriber = users |
| 1385 | count = 1 |
| 1386 | j = 1 |
| 1387 | negative_traffic = None |
| 1388 | mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = group_end_ip) |
| 1389 | sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = source_list_end_ip) |
| 1390 | subscriber_sourceips = self.source_ip_range(start_ip = '20.20.0.1',end_ip = user_src_end_ip) |
| 1391 | while count<=subscriber: |
| 1392 | group = random.choice(mcastips) |
| 1393 | source = random.choice(sourceips) |
| 1394 | subscriber_sourceip = random.choice(subscriber_sourceips) |
| 1395 | if group in groups: |
| 1396 | pass |
| 1397 | else: |
| 1398 | log.info('group = %s source list = %s and subscriber source ip in join = %s'%(group,source, subscriber_sourceip)) |
| 1399 | groups.append(group) |
| 1400 | sources.append(source) |
| 1401 | subscribers_src_ip.append(subscriber_sourceip) |
| 1402 | count += 1 |
| 1403 | self.onos_ssm_table_load(groups,src_list=sources,flag=True) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1404 | def multiple_joins_send_in_threads(group, source, subscriber_src_ip,invalid_igmp_join,data_pkt = data_pkt): |
| 1405 | if invalid_igmp_join is None: |
| 1406 | self.send_igmp_join(groups = [group], src_list = [source],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1407 | iface = self.V_INF1, ip_src = [subscriber_src_ip]) |
| 1408 | else: |
| 1409 | negative_traffic = True |
| 1410 | self.send_igmp_join_negative(groups = [group], src_list = [source],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1411 | iface = self.V_INF1, ip_src = [subscriber_src_ip], invalid_igmp_join = invalid_igmp_join) |
ChetanGaonker | 12f9f42 | 2016-11-10 23:21:21 -0800 | [diff] [blame] | 1412 | randomDelay_in_thread = randint(10,30) |
| 1413 | log.info('This is running in thread with igmp join sent and delay {}'.format(randomDelay_in_thread)) |
| 1414 | time.sleep(randomDelay_in_thread) |
| 1415 | log.info('This is running in thread with igmp join sent and delay {}'.format(randomDelay_in_thread)) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1416 | status = self.verify_igmp_data_traffic_in_thread(group,intf=self.V_INF1,source=source, data_pkt = data_pkt,negative=negative_traffic) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1417 | log.info('data received for group %s from source %s and status is %s '%(group,source,status)) |
| 1418 | self.igmp_threads_result.append(status) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1419 | for i in range(subscriber): |
| 1420 | thread = threading.Thread(target = multiple_joins_send_in_threads, args = (groups[i], sources[i], subscribers_src_ip[i], invalid_joins)) |
| 1421 | if bunch_traffic == 'yes': |
| 1422 | if j == 10: |
| 1423 | log.info('Here we are throttle traffic for 100 sec of delay and agian creating igmp threads') |
| 1424 | time.sleep(randint(100,110)) |
| 1425 | j = 1 |
| 1426 | else: |
| 1427 | j = j+ 1 |
| 1428 | time.sleep(randint(1,2)) |
| 1429 | thread.start() |
| 1430 | threads.append(thread) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1431 | for thread in threads: |
| 1432 | thread.join() |
| 1433 | |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1434 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 1435 | def test_netCondition_with_throttle_between_multiple_igmp_joins_and_data_from_multiple_subscribers(self): |
| 1436 | self.setUp_tls() |
| 1437 | df = defer.Deferred() |
| 1438 | log.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result)) |
| 1439 | def netCondition_multiple_igmp_joins_and_data(df): |
| 1440 | ### 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 |
| 1441 | batch_traffic_run = 'yes' |
| 1442 | no_users = 11 |
| 1443 | group_end_ip = '229.0.30.254' |
| 1444 | source_list_end_ip = '10.10.30.254' |
| 1445 | subscriber_src_end_ip = '20.20.20.254' |
| 1446 | 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 ) |
| 1447 | log.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result)) |
| 1448 | for i in xrange(no_users): |
| 1449 | log.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i])) |
| 1450 | if assert_equal(self.igmp_threads_result[i], True) is True: |
| 1451 | df.callback(0) |
| 1452 | df.callback(0) |
| 1453 | reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df) |
| 1454 | return df |
| 1455 | |
| 1456 | @deferred(TEST_TIMEOUT_DELAY+50) |
Thangavelu K S | ef6f0a5 | 2016-12-14 19:57:05 +0000 | [diff] [blame] | 1457 | def test_netCondition_with_invalid_igmp_type_multiple_igmp_joins_and_data_from_multiple_subscribers(self): |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1458 | self.setUp_tls() |
| 1459 | df = defer.Deferred() |
| 1460 | log.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result)) |
| 1461 | def netCondition_multiple_igmp_joins_and_data(df): |
| 1462 | ### 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 |
| 1463 | batch_traffic_run = 'no' |
| 1464 | invalid_igmp_join = 'igmp_type' |
| 1465 | no_users = 11 |
| 1466 | group_end_ip = '229.0.30.254' |
| 1467 | source_list_end_ip = '10.10.30.254' |
| 1468 | subscriber_src_end_ip = '20.20.20.254' |
| 1469 | 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 ) |
| 1470 | log.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result)) |
| 1471 | for i in xrange(no_users): |
| 1472 | log.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i])) |
| 1473 | if assert_equal(self.igmp_threads_result[i], True) is True: |
| 1474 | df.callback(0) |
| 1475 | df.callback(0) |
| 1476 | reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df) |
| 1477 | return df |
| 1478 | |
| 1479 | @deferred(TEST_TIMEOUT_DELAY+50) |
Thangavelu K S | ef6f0a5 | 2016-12-14 19:57:05 +0000 | [diff] [blame] | 1480 | def test_netCondition_with_invalid_record_type_multiple_igmp_joins_and_data_from_multiple_subscribers(self): |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1481 | self.setUp_tls() |
| 1482 | df = defer.Deferred() |
| 1483 | log.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result)) |
| 1484 | def netCondition_multiple_igmp_joins_and_data(df): |
| 1485 | ### 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 |
| 1486 | batch_traffic_run = 'no' |
| 1487 | invalid_igmp_join = 'record_type' |
| 1488 | no_users = 11 |
| 1489 | group_end_ip = '229.0.30.254' |
| 1490 | source_list_end_ip = '10.10.30.254' |
| 1491 | subscriber_src_end_ip = '20.20.20.254' |
| 1492 | 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 ) |
| 1493 | log.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result)) |
| 1494 | for i in xrange(no_users): |
| 1495 | log.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i])) |
| 1496 | if assert_equal(self.igmp_threads_result[i], True) is True: |
| 1497 | df.callback(0) |
| 1498 | df.callback(0) |
| 1499 | reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df) |
| 1500 | return df |
| 1501 | |
| 1502 | |
| 1503 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 1504 | def test_netCondition_with_invalid_ttl_and_multiple_igmp_joins_and_data_from_multiple_subscribers(self): |
| 1505 | self.setUp_tls() |
| 1506 | df = defer.Deferred() |
| 1507 | log.info('IGMP Thread status before running igmp thread %s '%(self.igmp_threads_result)) |
| 1508 | def netCondition_multiple_igmp_joins_and_data(df): |
| 1509 | ### 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 |
| 1510 | batch_traffic_run = 'no' |
| 1511 | invalid_igmp_join = 'ttl_type' |
| 1512 | no_users = 11 |
| 1513 | group_end_ip = '229.0.30.254' |
| 1514 | source_list_end_ip = '10.10.30.254' |
| 1515 | subscriber_src_end_ip = '20.20.20.254' |
| 1516 | 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 ) |
| 1517 | log.info('IGMP Thread status after running igmp thread %s '%(self. igmp_threads_result)) |
| 1518 | for i in xrange(no_users): |
| 1519 | log.info('IGMP Thread %s status is %s after running igmp thread '%(i,self.igmp_threads_result[i])) |
| 1520 | if assert_equal(self.igmp_threads_result[i], True) is True: |
| 1521 | df.callback(0) |
| 1522 | df.callback(0) |
| 1523 | reactor.callLater(0, netCondition_multiple_igmp_joins_and_data, df) |
| 1524 | return df |
| 1525 | |
| 1526 | |
| 1527 | @deferred(TEST_TIMEOUT_DELAY-250) |
| 1528 | def test_netCondition_in_multiple_eap_tls_sessions_with_out_of_order_exchanges_between_serverHello_and_client_packet(self): |
| 1529 | self.setUp_tls() |
| 1530 | df = defer.Deferred() |
| 1531 | threads = [] |
Thangavelu K S | ef6f0a5 | 2016-12-14 19:57:05 +0000 | [diff] [blame] | 1532 | clients = 100 |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1533 | def eap_tls_eapTlsHelloReq_pkt_delay(df): |
| 1534 | def multiple_tls_random_delay(): |
ChetanGaonker | 12f9f42 | 2016-11-10 23:21:21 -0800 | [diff] [blame] | 1535 | randomDelay = randint(10,300) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1536 | tls = TLSAuthTest(src_mac = 'random') |
| 1537 | tls._eapSetup() |
| 1538 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1539 | tls._eapStart() |
| 1540 | tls.tlsEventTable.EVT_EAP_START |
| 1541 | tls._eapIdReq() |
| 1542 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1543 | tls._eapTlsCertReq() |
| 1544 | assert_equal(tls.failTest, True) |
| 1545 | tls._eapTlsHelloReq() |
| 1546 | assert_equal(tls.failTest, True) |
| 1547 | tls._eapTlsChangeCipherSpec() |
| 1548 | assert_equal(tls.failTest, True) |
| 1549 | tls._eapTlsFinished() |
| 1550 | assert_equal(tls.failTest, True) |
| 1551 | log.info('Authentication successful for user %d'%i) |
| 1552 | # Sending multiple tls clients and making random delay in between client and server packets. |
| 1553 | for i in xrange(clients): |
| 1554 | thread = threading.Thread(target = multiple_tls_random_delay) |
| 1555 | time.sleep(randint(1,2)) |
| 1556 | thread.start() |
| 1557 | threads.append(thread) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1558 | for thread in threads: |
| 1559 | thread.join() |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1560 | reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df) |
| 1561 | return df |
| 1562 | |
| 1563 | @deferred(TEST_TIMEOUT_DELAY-250) |
| 1564 | def test_netCondition_in_multiple_eap_tls_session_with_out_of_order_exchanges_in_eapTlsCertReq_packets(self): |
| 1565 | self.setUp_tls() |
| 1566 | df = defer.Deferred() |
| 1567 | threads = [] |
Thangavelu K S | ef6f0a5 | 2016-12-14 19:57:05 +0000 | [diff] [blame] | 1568 | clients = 100 |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1569 | def eap_tls_eapTlsHelloReq_pkt_delay(df): |
| 1570 | def multiple_tls_random_delay(): |
ChetanGaonker | 12f9f42 | 2016-11-10 23:21:21 -0800 | [diff] [blame] | 1571 | randomDelay = randint(10,300) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1572 | tls = TLSAuthTest(src_mac = 'random') |
| 1573 | tls._eapSetup() |
| 1574 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1575 | tls._eapStart() |
| 1576 | tls.tlsEventTable.EVT_EAP_START |
| 1577 | tls._eapTlsCertReq() |
| 1578 | assert_equal(tls.failTest, True) |
| 1579 | tls._eapIdReq() |
| 1580 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1581 | assert_equal(tls.failTest, True) |
| 1582 | tls._eapTlsCertReq() |
| 1583 | assert_equal(tls.failTest, True) |
| 1584 | tls._eapTlsHelloReq() |
| 1585 | assert_equal(tls.failTest, True) |
| 1586 | tls._eapTlsChangeCipherSpec() |
| 1587 | assert_equal(tls.failTest, True) |
| 1588 | tls._eapTlsFinished() |
| 1589 | assert_equal(tls.failTest, True) |
| 1590 | log.info('Authentication successful for user %d'%i) |
| 1591 | # Sending multiple tls clients and making random delay in between client and server packets. |
| 1592 | for i in xrange(clients): |
| 1593 | thread = threading.Thread(target = multiple_tls_random_delay) |
| 1594 | time.sleep(randint(1,2)) |
| 1595 | thread.start() |
| 1596 | threads.append(thread) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1597 | for thread in threads: |
| 1598 | thread.join() |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1599 | reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df) |
| 1600 | return df |
| 1601 | |
| 1602 | @deferred(TEST_TIMEOUT_DELAY-250) |
| 1603 | def test_netCondition_in_multiple_eap_tls_sessions_with_out_of_order_eapTlsChangeCipherSpec_packets(self): |
| 1604 | self.setUp_tls() |
| 1605 | df = defer.Deferred() |
| 1606 | threads = [] |
Thangavelu K S | ef6f0a5 | 2016-12-14 19:57:05 +0000 | [diff] [blame] | 1607 | clients = 100 |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1608 | def eap_tls_eapTlsHelloReq_pkt_delay(df): |
| 1609 | def multiple_tls_random_delay(): |
ChetanGaonker | 12f9f42 | 2016-11-10 23:21:21 -0800 | [diff] [blame] | 1610 | randomDelay = randint(10,300) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1611 | tls = TLSAuthTest(src_mac = 'random') |
| 1612 | tls._eapSetup() |
| 1613 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1614 | tls._eapStart() |
| 1615 | tls.tlsEventTable.EVT_EAP_START |
| 1616 | tls._eapTlsChangeCipherSpec() |
| 1617 | tls.failTest = False |
| 1618 | tls._eapIdReq() |
| 1619 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1620 | assert_equal(tls.failTest, True) |
| 1621 | tls._eapTlsHelloReq() |
| 1622 | assert_equal(tls.failTest, True) |
| 1623 | tls._eapTlsCertReq() |
| 1624 | assert_equal(tls.failTest, True) |
| 1625 | tls._eapTlsChangeCipherSpec() |
| 1626 | assert_equal(tls.failTest, True) |
| 1627 | tls._eapTlsFinished() |
| 1628 | assert_equal(tls.failTest, True) |
| 1629 | log.info('Authentication successful for user %d'%i) |
| 1630 | # Sending multiple tls clients and making random delay in between client and server packets. |
| 1631 | for i in xrange(clients): |
| 1632 | thread = threading.Thread(target = multiple_tls_random_delay) |
| 1633 | time.sleep(randint(1,2)) |
| 1634 | thread.start() |
| 1635 | threads.append(thread) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1636 | for thread in threads: |
| 1637 | thread.join() |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1638 | reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df) |
| 1639 | return df |
| 1640 | |
| 1641 | @deferred(TEST_TIMEOUT_DELAY-250) |
| 1642 | def test_netCondition_in_multiple_eap_tls_sessions_dropping_eapTlsHelloReq_packets(self): |
| 1643 | self.setUp_tls() |
| 1644 | df = defer.Deferred() |
| 1645 | threads = [] |
Thangavelu K S | ef6f0a5 | 2016-12-14 19:57:05 +0000 | [diff] [blame] | 1646 | clients = 100 |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1647 | def eap_tls_eapTlsHelloReq_pkt_delay(df): |
| 1648 | def multiple_tls_random_delay(): |
ChetanGaonker | 12f9f42 | 2016-11-10 23:21:21 -0800 | [diff] [blame] | 1649 | randomDelay = randint(10,300) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1650 | tls = TLSAuthTest(src_mac = 'random') |
| 1651 | tls._eapSetup() |
| 1652 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1653 | tls._eapStart() |
| 1654 | tls.tlsEventTable.EVT_EAP_START |
| 1655 | tls._eapIdReq() |
| 1656 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1657 | #tls._eapTlsHelloReq() |
| 1658 | tls._eapTlsCertReq() |
| 1659 | tls._eapTlsChangeCipherSpec() |
| 1660 | assert_equal(tls.failTest, True) |
| 1661 | tls._eapTlsFinished() |
| 1662 | log.info('Authentication successful for user %d'%i) |
| 1663 | # Sending multiple tls clients and making random delay in between client and server packets. |
| 1664 | for i in xrange(clients): |
| 1665 | thread = threading.Thread(target = multiple_tls_random_delay) |
| 1666 | time.sleep(randint(1,2)) |
| 1667 | thread.start() |
| 1668 | threads.append(thread) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1669 | for thread in threads: |
| 1670 | thread.join() |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1671 | reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df) |
| 1672 | return df |
| 1673 | |
| 1674 | @deferred(TEST_TIMEOUT_DELAY-250) |
| 1675 | def test_netCondition_in_multiple_eap_tls_sessions_dropping_eapTlsChangeCipherSpec_packets(self): |
| 1676 | self.setUp_tls() |
| 1677 | df = defer.Deferred() |
| 1678 | threads = [] |
Thangavelu K S | ef6f0a5 | 2016-12-14 19:57:05 +0000 | [diff] [blame] | 1679 | clients = 100 |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1680 | def eap_tls_eapTlsHelloReq_pkt_delay(df): |
| 1681 | def multiple_tls_random_delay(): |
ChetanGaonker | 12f9f42 | 2016-11-10 23:21:21 -0800 | [diff] [blame] | 1682 | randomDelay = randint(10,300) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1683 | tls = TLSAuthTest(src_mac = 'random') |
| 1684 | tls._eapSetup() |
| 1685 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1686 | tls._eapStart() |
| 1687 | tls.tlsEventTable.EVT_EAP_START |
| 1688 | tls._eapIdReq() |
| 1689 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1690 | tls._eapTlsHelloReq() |
| 1691 | tls._eapTlsCertReq() |
| 1692 | #tls._eapTlsChangeCipherSpec() |
| 1693 | assert_equal(tls.failTest, True) |
| 1694 | tls._eapTlsFinished() |
| 1695 | log.info('Authentication successful for user %d'%i) |
| 1696 | # Sending multiple tls clients and making random delay in between client and server packets. |
| 1697 | for i in xrange(clients): |
| 1698 | thread = threading.Thread(target = multiple_tls_random_delay) |
| 1699 | time.sleep(randint(1,2)) |
| 1700 | thread.start() |
| 1701 | threads.append(thread) |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1702 | for thread in threads: |
| 1703 | thread.join() |
ChetanGaonker | fc7b030 | 2016-11-10 08:45:56 -0800 | [diff] [blame] | 1704 | reactor.callLater(0, eap_tls_eapTlsHelloReq_pkt_delay, df) |
| 1705 | return df |
| 1706 | |
Thangavelu K S | ef6f0a5 | 2016-12-14 19:57:05 +0000 | [diff] [blame] | 1707 | @deferred(TEST_TIMEOUT_DELAY+50) |
| 1708 | def test_netCondition_in_eapol_tls_with_invalid_eapol_version_field_in_client_auth_packet(self): |
| 1709 | self.setUp_tls() |
| 1710 | randomDelay = randint(10,300) |
| 1711 | df = defer.Deferred() |
| 1712 | tls = TLSAuthTest() |
| 1713 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 1714 | tls._eapTlsHelloReq() |
| 1715 | tls._eapTlsCertReq() |
| 1716 | tls._eapTlsChangeCipherSpec() |
| 1717 | tls._eapTlsFinished() |
| 1718 | EapolPacket.eap_tls_packets_field_value_replace(invalid_field_name= 'eapolTlsVersion') |
| 1719 | df.callback(0) |
| 1720 | def eap_tls_verify(df): |
| 1721 | tls._eapSetup() |
| 1722 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1723 | tls._eapStart() |
| 1724 | EapolPacket.eap_invalid_tls_packets_info(invalid_field_name= 'eapolTlsVersion', invalid_field_value= 20) |
| 1725 | tls.tlsEventTable.EVT_EAP_START |
| 1726 | tls._eapIdReq() |
| 1727 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1728 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 1729 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 1730 | t.start() |
| 1731 | reactor.callLater(0, eap_tls_verify, df) |
| 1732 | return df |
| 1733 | |
| 1734 | @deferred(TEST_TIMEOUT_DELAY-150) |
| 1735 | def test_netCondition_in_eapol_tls_with_invalid_eapol_tls_type_field_in_client_auth_packet(self): |
| 1736 | self.setUp_tls() |
| 1737 | randomDelay = randint(10,300) |
| 1738 | df = defer.Deferred() |
| 1739 | tls = TLSAuthTest() |
| 1740 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 1741 | tls._eapTlsHelloReq() |
| 1742 | tls._eapTlsCertReq() |
| 1743 | tls._eapTlsChangeCipherSpec() |
| 1744 | tls._eapTlsFinished() |
| 1745 | EapolPacket.eap_tls_packets_field_value_replace(invalid_field_name= 'eapolTlsType') |
| 1746 | df.callback(0) |
| 1747 | def eap_tls_verify(df): |
| 1748 | tls._eapSetup() |
| 1749 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1750 | tls._eapStart() |
| 1751 | EapolPacket.eap_invalid_tls_packets_info(invalid_field_name= 'eapolTlsType', invalid_field_value= 20) |
| 1752 | tls.tlsEventTable.EVT_EAP_START |
| 1753 | tls._eapIdReq() |
| 1754 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1755 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 1756 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 1757 | t.start() |
| 1758 | reactor.callLater(0, eap_tls_verify, df) |
| 1759 | return df |
| 1760 | |
| 1761 | @deferred(TEST_TIMEOUT_DELAY-150) |
| 1762 | def test_netCondition_in_eapol_tls_with_invalid_eapol_type_ID_field_in_client_auth_packet(self): |
| 1763 | self.setUp_tls() |
| 1764 | randomDelay = randint(10,300) |
| 1765 | df = defer.Deferred() |
| 1766 | tls = TLSAuthTest() |
| 1767 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 1768 | tls._eapTlsHelloReq() |
| 1769 | tls._eapTlsCertReq() |
| 1770 | tls._eapTlsChangeCipherSpec() |
| 1771 | tls._eapTlsFinished() |
| 1772 | EapolPacket.eap_tls_packets_field_value_replace(invalid_field_name= 'eapolTypeID') |
| 1773 | df.callback(0) |
| 1774 | def eap_tls_verify(df): |
| 1775 | tls._eapSetup() |
| 1776 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1777 | tls._eapStart() |
| 1778 | EapolPacket.eap_invalid_tls_packets_info(invalid_field_name= 'eapolTypeID', invalid_field_value= 20) |
| 1779 | tls.tlsEventTable.EVT_EAP_START |
| 1780 | tls._eapIdReq() |
| 1781 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1782 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 1783 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 1784 | t.start() |
| 1785 | reactor.callLater(0, eap_tls_verify, df) |
| 1786 | return df |
| 1787 | |
| 1788 | @deferred(TEST_TIMEOUT_DELAY-150) |
| 1789 | def test_netCondition_in_eapol_tls_with_invalid_eapol_response_field_in_client_auth_packet(self): |
| 1790 | self.setUp_tls() |
| 1791 | randomDelay = randint(10,300) |
| 1792 | df = defer.Deferred() |
| 1793 | tls = TLSAuthTest() |
| 1794 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 1795 | tls._eapTlsHelloReq() |
| 1796 | tls._eapTlsCertReq() |
| 1797 | tls._eapTlsChangeCipherSpec() |
| 1798 | tls._eapTlsFinished() |
| 1799 | EapolPacket.eap_tls_packets_field_value_replace(invalid_field_name= 'eapolResponse') |
| 1800 | df.callback(0) |
| 1801 | def eap_tls_verify(df): |
| 1802 | tls._eapSetup() |
| 1803 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1804 | tls._eapStart() |
| 1805 | EapolPacket.eap_invalid_tls_packets_info(invalid_field_name= 'eapolResponse', invalid_field_value= 20) |
| 1806 | tls.tlsEventTable.EVT_EAP_START |
| 1807 | tls._eapIdReq() |
| 1808 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1809 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 1810 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 1811 | t.start() |
| 1812 | reactor.callLater(0, eap_tls_verify, df) |
| 1813 | return df |
| 1814 | |
| 1815 | @deferred(TEST_TIMEOUT_DELAY-150) |
| 1816 | def test_netCondition_in_eap_tls_with_invalid_eap_content_type_field_in_client_auth_packet(self): |
| 1817 | self.setUp_tls() |
| 1818 | randomDelay = randint(10,300) |
| 1819 | df = defer.Deferred() |
| 1820 | def tls_invalid_content_type_cb(): |
| 1821 | log.info('TLS authentication failed with invalid content type in TLSContentType packet') |
| 1822 | tls = TLSAuthTest(fail_cb = tls_invalid_content_type_cb, invalid_content_type = 44) |
| 1823 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 1824 | tls._eapTlsHelloReq() |
| 1825 | tls._eapTlsCertReq() |
| 1826 | tls._eapTlsChangeCipherSpec() |
| 1827 | tls._eapTlsFinished() |
| 1828 | df.callback(0) |
| 1829 | def eap_tls_verify(df): |
| 1830 | tls._eapSetup() |
| 1831 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1832 | tls._eapStart() |
| 1833 | tls.tlsEventTable.EVT_EAP_START |
| 1834 | tls._eapIdReq() |
| 1835 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1836 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 1837 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 1838 | t.start() |
| 1839 | reactor.callLater(0, eap_tls_verify, df) |
| 1840 | return df |
| 1841 | |
| 1842 | @deferred(TEST_TIMEOUT_DELAY-250) |
| 1843 | def test_netCondition_in_eap_tls_with_invalid_tls_version_field_in_client_auth_packet(self): |
| 1844 | self.setUp_tls() |
| 1845 | randomDelay = randint(10,300) |
| 1846 | df = defer.Deferred() |
| 1847 | def tls_invalid_eap_tls_version_in_client_auth_packet(): |
| 1848 | log.info('TLS authentication failed with invalid tls version field in the packet') |
| 1849 | tls = TLSAuthTest(fail_cb = tls_invalid_eap_tls_version_in_client_auth_packet, version = 'TLS_2_1') |
| 1850 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 1851 | tls._eapTlsHelloReq() |
| 1852 | tls._eapTlsCertReq() |
| 1853 | tls._eapTlsChangeCipherSpec() |
| 1854 | tls._eapTlsFinished() |
| 1855 | df.callback(0) |
| 1856 | def eap_tls_verify(df): |
| 1857 | tls._eapSetup() |
| 1858 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1859 | tls._eapStart() |
| 1860 | tls.tlsEventTable.EVT_EAP_START |
| 1861 | tls._eapIdReq() |
| 1862 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1863 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 1864 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 1865 | t.start() |
| 1866 | reactor.callLater(0, eap_tls_verify, df) |
| 1867 | return df |
| 1868 | |
| 1869 | @deferred(TEST_TIMEOUT_DELAY-250) |
| 1870 | def test_netCondition_in_eap_tls_with_invalid_tls_cipher_suite_field_in_client_auth_packet(self): |
| 1871 | self.setUp_tls() |
| 1872 | randomDelay = randint(10,300) |
| 1873 | df = defer.Deferred() |
| 1874 | def tls_with_invalid_tls_cipher_suite_field_in_client_auth_packet_cb(): |
| 1875 | log.info('TLS authentication failed with invalid tls cipher suite field in the packet') |
| 1876 | tls = TLSAuthTest(fail_cb = tls_with_invalid_tls_cipher_suite_field_in_client_auth_packet_cb, cipher_suite = 'RSA_WITH_AES_512_CBC_SHA') |
| 1877 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 1878 | tls._eapTlsHelloReq() |
| 1879 | tls._eapTlsCertReq() |
| 1880 | tls._eapTlsChangeCipherSpec() |
| 1881 | tls._eapTlsFinished() |
| 1882 | df.callback(0) |
| 1883 | def eap_tls_verify(df): |
| 1884 | tls._eapSetup() |
| 1885 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1886 | tls._eapStart() |
| 1887 | tls.tlsEventTable.EVT_EAP_START |
| 1888 | tls._eapIdReq() |
| 1889 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1890 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 1891 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 1892 | t.start() |
| 1893 | reactor.callLater(0, eap_tls_verify, df) |
| 1894 | return df |
| 1895 | |
| 1896 | @deferred(TEST_TIMEOUT_DELAY-150) |
| 1897 | def test_netCondition_in_eap_tls_with_id_mismatch_in_identifier_field_in_client_auth_packet(self): |
| 1898 | self.setUp_tls() |
| 1899 | randomDelay = randint(10,300) |
| 1900 | df = defer.Deferred() |
| 1901 | def tls_with_invalid_id_in_identifier_response_packet_cb(): |
| 1902 | log.info('TLS authentication failed with invalid id in identifier packet') |
| 1903 | tls = TLSAuthTest(fail_cb = tls_with_invalid_id_in_identifier_response_packet_cb, |
| 1904 | id_mismatch_in_identifier_response_packet = True) |
| 1905 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 1906 | tls._eapTlsHelloReq() |
| 1907 | tls._eapTlsCertReq() |
| 1908 | tls._eapTlsChangeCipherSpec() |
| 1909 | tls._eapTlsFinished() |
| 1910 | df.callback(0) |
| 1911 | def eap_tls_verify(df): |
| 1912 | tls._eapSetup() |
| 1913 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1914 | tls._eapStart() |
| 1915 | tls.tlsEventTable.EVT_EAP_START |
| 1916 | tls._eapIdReq() |
| 1917 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1918 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 1919 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 1920 | t.start() |
| 1921 | reactor.callLater(0, eap_tls_verify, df) |
| 1922 | return df |
| 1923 | |
| 1924 | @deferred(TEST_TIMEOUT_DELAY-150) |
| 1925 | def test_netCondition_in_eap_tls_with_id_mismatch_in_client_hello_auth_packet(self): |
| 1926 | self.setUp_tls() |
| 1927 | randomDelay = randint(10,300) |
| 1928 | df = defer.Deferred() |
| 1929 | def tls_with_invalid_id_in_client_hello_packet_cb(): |
| 1930 | log.info('TLS authentication failed with invalid id in client hello packet') |
| 1931 | tls = TLSAuthTest(fail_cb = tls_with_invalid_id_in_client_hello_packet_cb, |
| 1932 | id_mismatch_in_client_hello_packet = True) |
| 1933 | |
| 1934 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 1935 | tls._eapTlsHelloReq() |
| 1936 | tls._eapTlsCertReq() |
| 1937 | tls._eapTlsChangeCipherSpec() |
| 1938 | tls._eapTlsFinished() |
| 1939 | df.callback(0) |
| 1940 | def eap_tls_verify(df): |
| 1941 | tls._eapSetup() |
| 1942 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1943 | tls._eapStart() |
| 1944 | tls.tlsEventTable.EVT_EAP_START |
| 1945 | tls._eapIdReq() |
| 1946 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1947 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 1948 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 1949 | t.start() |
| 1950 | reactor.callLater(0, eap_tls_verify, df) |
| 1951 | return df |
| 1952 | |
| 1953 | @deferred(TEST_TIMEOUT_DELAY-150) |
| 1954 | def test_netCondition_in_eap_tls_with_invalid_client_hello_handshake_type_auth_packet(self): |
| 1955 | self.setUp_tls() |
| 1956 | randomDelay = randint(10,300) |
| 1957 | df = defer.Deferred() |
| 1958 | def tls_incorrect_handshake_type_client_hello_cb(): |
| 1959 | log.info('TLS authentication failed with incorrect handshake type in client hello packet') |
| 1960 | tls = TLSAuthTest(fail_cb = tls_incorrect_handshake_type_client_hello_cb, invalid_client_hello_handshake_type=True) |
| 1961 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 1962 | tls._eapTlsHelloReq() |
| 1963 | tls._eapTlsCertReq() |
| 1964 | tls._eapTlsChangeCipherSpec() |
| 1965 | tls._eapTlsFinished() |
| 1966 | df.callback(0) |
| 1967 | def eap_tls_verify(df): |
| 1968 | tls._eapSetup() |
| 1969 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1970 | tls._eapStart() |
| 1971 | tls.tlsEventTable.EVT_EAP_START |
| 1972 | tls._eapIdReq() |
| 1973 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 1974 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 1975 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 1976 | t.start() |
| 1977 | reactor.callLater(0, eap_tls_verify, df) |
| 1978 | return df |
| 1979 | |
| 1980 | @deferred(TEST_TIMEOUT_DELAY-150) |
| 1981 | def test_netCondition_in_eap_tls_with_invalid_client_cert_req_handshake_auth_packet(self): |
| 1982 | self.setUp_tls() |
| 1983 | randomDelay = randint(10,300) |
| 1984 | df = defer.Deferred() |
| 1985 | def tls_incorrect_handshake_type_certificate_request_cb(): |
| 1986 | log.info('TLS authentication failed with incorrect handshake type in client certificate request packet') |
| 1987 | tls = TLSAuthTest(fail_cb = tls_incorrect_handshake_type_certificate_request_cb, invalid_cert_req_handshake = True) |
| 1988 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 1989 | tls._eapTlsHelloReq() |
| 1990 | tls._eapTlsCertReq() |
| 1991 | tls._eapTlsChangeCipherSpec() |
| 1992 | tls._eapTlsFinished() |
| 1993 | df.callback(0) |
| 1994 | def eap_tls_verify(df): |
| 1995 | tls._eapSetup() |
| 1996 | tls.tlsEventTable.EVT_EAP_SETUP |
| 1997 | tls._eapStart() |
| 1998 | tls.tlsEventTable.EVT_EAP_START |
| 1999 | tls._eapIdReq() |
| 2000 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 2001 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 2002 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 2003 | t.start() |
| 2004 | reactor.callLater(0, eap_tls_verify, df) |
| 2005 | return df |
| 2006 | |
| 2007 | @deferred(TEST_TIMEOUT_DELAY-150) |
| 2008 | def test_netCondition_in_eap_tls_with_invalid_client_key_ex_replacing_server_key_ex(self): |
| 2009 | self.setUp_tls() |
| 2010 | randomDelay = randint(10,300) |
| 2011 | df = defer.Deferred() |
| 2012 | def tls_clientkeyex_replace_with_serverkeyex_cb(): |
| 2013 | log.info('TLS authentication failed with client key exchange replaced with server key exchange') |
| 2014 | tls = TLSAuthTest(fail_cb = tls_clientkeyex_replace_with_serverkeyex_cb,clientkeyex_replace_with_serverkeyex=True) |
| 2015 | def eap_tls_eapTlsHelloReq_pkt_delay(): |
| 2016 | tls._eapTlsHelloReq() |
| 2017 | tls._eapTlsCertReq() |
| 2018 | tls._eapTlsChangeCipherSpec() |
| 2019 | tls._eapTlsFinished() |
| 2020 | df.callback(0) |
| 2021 | def eap_tls_verify(df): |
| 2022 | tls._eapSetup() |
| 2023 | tls.tlsEventTable.EVT_EAP_SETUP |
| 2024 | tls._eapStart() |
| 2025 | tls.tlsEventTable.EVT_EAP_START |
| 2026 | tls._eapIdReq() |
| 2027 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 2028 | log.info('Holding tlsHelloReq packet for a period of random delay = {} secs'.format(randomDelay)) |
| 2029 | t = Timer(randomDelay, eap_tls_eapTlsHelloReq_pkt_delay) |
| 2030 | t.start() |
| 2031 | reactor.callLater(0, eap_tls_verify, df) |
| 2032 | return df |
| 2033 | |
| 2034 | def tcpreplay_radius_server_packets_from_pcap_file(self, pcap_file_path =None, error_pkt = None): |
| 2035 | #default radius server packets in path in test/netCondition/xxx.pcap file |
| 2036 | if pcap_file_path and (error_pkt == None): |
| 2037 | pcap_file_path = pcap_file_path |
| 2038 | elif error_pkt == None: |
| 2039 | pcap_file_path = "/root/test/src/test/netCondition/tls_auth_exhange_packets_Radius_server_packets_only.pcap" |
| 2040 | elif error_pkt: |
| 2041 | pcap_file_path = "/root/test/src/test/netCondition/error_tls_auth_exhange_packets_Radius_server_packets_only.pcap" |
| 2042 | log.info('Started replaying pcap file packets on docker0 interface using tcprelay linux command') |
| 2043 | time.sleep(0.4) |
| 2044 | sendp(rdpcap(pcap_file_path), iface="eth0", loop=0, inter=1) |
| 2045 | time.sleep(5) |
| 2046 | log.info('Replayed pcap file packets on docker0 interface') |
| 2047 | |
| 2048 | def tcpreplay_radius_server_error_packets_from_pcap_file(self, pcap_file_path =None, error_pkt = None): |
| 2049 | #default radius server packets in path in test/netCondition/xxx.pcap file |
| 2050 | if pcap_file_path: |
| 2051 | pcap_file_path = pcap_file_path |
| 2052 | else: |
| 2053 | pcap_file_path = "/root/test/src/test/netCondition/error_tls_auth_exhange_packets_Radius_server_packets_only.pcap" |
| 2054 | log.info('Started replaying pcap file error packets on docker0 interface using tcprelay linux command') |
| 2055 | time.sleep(0.4) |
| 2056 | sendp(rdpcap(pcap_file_path), iface="eth0", loop=0, inter=1) |
| 2057 | time.sleep(5) |
| 2058 | return 'success' |
| 2059 | |
| 2060 | 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): |
| 2061 | #default radius server packets in path in test/netCondition/xxx.pcap file |
| 2062 | random_port = 1222 |
| 2063 | if pcap_file_path: |
| 2064 | pcap_file_path = pcap_file_path |
| 2065 | else: |
| 2066 | pcap_file_path = "/root/test/src/test/netCondition/tls_auth_exhange_packets_Radius_server_packets_only.pcap" |
| 2067 | log.info('Started corrupting tls server packet no = {}'.format(pkt_no)) |
| 2068 | radius_server_pkts = rdpcap(pcap_file_path) |
| 2069 | error_server_pkt = radius_server_pkts[pkt_no] |
| 2070 | if pkt_no == 0: |
| 2071 | if L4: |
| 2072 | error_server_pkt[UDP].sport = random_port |
| 2073 | error_server_pkt[UDP].dport = random_port |
| 2074 | |
| 2075 | if no_of_radius_attribute: |
| 2076 | error_server_pkt[3][2].value = '\n\xd8\xf0\xbbW\xd6$;\xd2s\xd5\xc5Ck\xd5\x01' |
| 2077 | error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9' |
| 2078 | if pkt_no == 1: |
| 2079 | if L4: |
| 2080 | error_server_pkt[UDP].sport = random_port |
| 2081 | error_server_pkt[UDP].dport = random_port |
| 2082 | |
| 2083 | if no_of_radius_attribute: |
| 2084 | error_server_pkt[3][2].type = 79 |
| 2085 | error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9' |
| 2086 | |
| 2087 | if pkt_no == 2: |
| 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][1].type = 79 |
| 2094 | error_server_pkt[3][2].len = 18 |
| 2095 | error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9' |
| 2096 | error_server_pkt[3][3].len = 18 |
| 2097 | error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9' |
| 2098 | |
| 2099 | if pkt_no == 3: |
| 2100 | if L4: |
| 2101 | error_server_pkt[UDP].sport = random_port |
| 2102 | error_server_pkt[UDP].dport = random_port |
| 2103 | |
| 2104 | if no_of_radius_attribute: |
| 2105 | error_server_pkt[3][1].type = 79 |
| 2106 | error_server_pkt[3][2].len = 18 |
| 2107 | error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9' |
| 2108 | error_server_pkt[3][3].len = 18 |
| 2109 | error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9' |
| 2110 | |
| 2111 | if pkt_no == 4: |
| 2112 | if L4: |
| 2113 | error_server_pkt[UDP].sport = random_port |
| 2114 | error_server_pkt[UDP].dport = random_port |
| 2115 | |
| 2116 | if no_of_radius_attribute: |
| 2117 | error_server_pkt[3][1].type = 79 |
| 2118 | error_server_pkt[3][2].len = 18 |
| 2119 | error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9' |
| 2120 | error_server_pkt[3][3].len = 18 |
| 2121 | error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9' |
| 2122 | |
| 2123 | if pkt_no == 5: |
| 2124 | if L4: |
| 2125 | error_server_pkt[UDP].sport = random_port |
| 2126 | error_server_pkt[UDP].dport = random_port |
| 2127 | |
| 2128 | if no_of_radius_attribute: |
| 2129 | error_server_pkt[3][1].type = 79 |
| 2130 | error_server_pkt[3][2].len = 18 |
| 2131 | error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9' |
| 2132 | error_server_pkt[3][3].len = 18 |
| 2133 | error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9' |
| 2134 | |
| 2135 | if pkt_no == 6: |
| 2136 | if L4: |
| 2137 | error_server_pkt[UDP].sport = random_port |
| 2138 | error_server_pkt[UDP].dport = random_port |
| 2139 | |
| 2140 | if no_of_radius_attribute: |
| 2141 | error_server_pkt[3][1].type = 79 |
| 2142 | error_server_pkt[3][2].len = 18 |
| 2143 | error_server_pkt[3][2].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9' |
| 2144 | error_server_pkt[3][3].len = 18 |
| 2145 | error_server_pkt[3][3].value = 'R\x1d`#R\x1cm[\xfd\xeb\xb9\xa84\xfc\xa3\xe9' |
| 2146 | error_server_pkt[3][5].len = 18 |
| 2147 | error_server_pkt[3][5].value = 'R\x1d`#R\x1cm[\xff\xeb\x99\xa77\xfc\xa3\xe9' |
| 2148 | |
| 2149 | |
| 2150 | error_server_pkt.show() |
| 2151 | radius_server_pkts[pkt_no] = error_server_pkt |
| 2152 | wrpcap("/root/test/src/test/netCondition/error_tls_auth_exhange_packets_Radius_server_packets_only.pcap", radius_server_pkts) |
| 2153 | pcap_file_path = "/root/test/src/test/netCondition/error_tls_auth_exhange_packets_Radius_server_packets_only.pcap" |
| 2154 | |
| 2155 | log.info('Done corrupting tls server packet no = {} send back filepath along with file name'.format(pkt_no)) |
| 2156 | return pcap_file_path |
| 2157 | |
| 2158 | @deferred(TEST_TIMEOUT_DELAY-50) |
| 2159 | def test_netCondition_in_eap_tls_with_valid_client_and_emulating_server_packets_without_radius_server_container(self): |
| 2160 | self.setUp_tls() |
| 2161 | df = defer.Deferred() |
| 2162 | threads = [] |
| 2163 | threads_status = [] |
| 2164 | clients = 1 |
| 2165 | radius_image = 'cord-test/radius:candidate' |
| 2166 | delay = 20 |
| 2167 | que = Queue.Queue() |
| 2168 | def eap_tls_emulating_server_pkts(df): |
| 2169 | def tls_client_packets(start): |
| 2170 | time.sleep(0.2) |
| 2171 | randomDelay = randint(10,300) |
| 2172 | tls = TLSAuthTest(src_mac = 'random') |
| 2173 | tls._eapSetup() |
| 2174 | tls.tlsEventTable.EVT_EAP_SETUP |
| 2175 | tls._eapStart() |
| 2176 | tls.tlsEventTable.EVT_EAP_START |
| 2177 | tls._eapIdReq() |
| 2178 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 2179 | tls._eapTlsHelloReq() |
| 2180 | tls._eapTlsCertReq() |
| 2181 | tls._eapTlsChangeCipherSpec() |
| 2182 | tls._eapTlsFinished() |
| 2183 | if tls.failTest == False: |
| 2184 | log.info('Authentication successful for user') |
| 2185 | return 'success' |
| 2186 | else: |
| 2187 | log.info('Authentication not successful for user') |
| 2188 | return 'failed' |
| 2189 | thread_client = threading.Thread(target=lambda q, arg1: q.put(tls_client_packets(arg1)), args=(que, 'start')) |
| 2190 | thread_radius = threading.Thread(target = Container.pause_container, args = (radius_image,delay)) |
| 2191 | thread_tcpreplay = threading.Thread(target = self.tcpreplay_radius_server_packets_from_pcap_file) |
| 2192 | threads.append(thread_radius) |
| 2193 | threads.append(thread_client) |
| 2194 | threads.append(thread_tcpreplay) |
| 2195 | for thread in threads: |
| 2196 | thread.start() |
| 2197 | for thread in threads: |
| 2198 | thread.join() |
| 2199 | while not que.empty(): |
| 2200 | threads_status = que.get() |
| 2201 | assert_equal(threads_status, 'success') |
| 2202 | df.callback(0) |
| 2203 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2204 | return df |
| 2205 | |
| 2206 | |
| 2207 | def eap_tls_emulating_server_pkts_negative_testing(df,msg): |
| 2208 | threads = [] |
| 2209 | threads_status = [] |
| 2210 | clients = 1 |
| 2211 | radius_image = 'cord-test/radius:candidate' |
| 2212 | delay = 20 |
| 2213 | que = Queue.Queue() |
| 2214 | def tls_client_packets(start): |
| 2215 | time.sleep(0.2) |
| 2216 | randomDelay = randint(10,300) |
| 2217 | def tls_invalid_server_packets_scenario_cb(): |
| 2218 | log.info('TLS authentication failed with {}'.format(msg)) |
| 2219 | tls = TLSAuthTest(fail_cb = tls_invalid_server_packets_scenario_cb, src_mac = 'random') |
| 2220 | tls._eapSetup() |
| 2221 | tls.tlsEventTable.EVT_EAP_SETUP |
| 2222 | tls._eapStart() |
| 2223 | tls.tlsEventTable.EVT_EAP_START |
| 2224 | tls._eapIdReq() |
| 2225 | tls.tlsEventTable.EVT_EAP_ID_REQ |
| 2226 | tls._eapTlsHelloReq() |
| 2227 | tls._eapTlsCertReq() |
| 2228 | tls._eapTlsChangeCipherSpec() |
| 2229 | tls._eapTlsFinished() |
| 2230 | if tls.failTest == True: |
| 2231 | log.info('Authentication not successful for user') |
| 2232 | return 'failed' |
| 2233 | else: |
| 2234 | log.info('Authentication successful for user') |
| 2235 | return 'success' |
| 2236 | def tcpreplay_radius_server_error_packets_from_pcap_file(pcap_file_path =None, error_pkt = None): |
| 2237 | #default radius server packets in path in test/netCondition/xxx.pcap file |
| 2238 | if pcap_file_path: |
| 2239 | pcap_file_path = pcap_file_path |
| 2240 | else: |
| 2241 | pcap_file_path = "/root/test/src/test/netCondition/error_tls_auth_exhange_packets_Radius_server_packets_only.pcap" |
| 2242 | |
| 2243 | log.info('Started replaying pcap file error packets on docker0 interface using tcprelay linux command') |
| 2244 | time.sleep(0.4) |
| 2245 | sendp(rdpcap(pcap_file_path), iface="eth0", loop=0, inter=1) |
| 2246 | time.sleep(5) |
| 2247 | return 'success' |
| 2248 | thread_client = threading.Thread(target=lambda q, arg1: q.put(tls_client_packets(arg1)), args=(que, 'start')) |
| 2249 | thread_radius = threading.Thread(target = Container.pause_container, args = (radius_image,delay)) |
| 2250 | thread_tcpreplay = threading.Thread(target = tcpreplay_radius_server_error_packets_from_pcap_file) |
| 2251 | threads.append(thread_radius) |
| 2252 | threads.append(thread_client) |
| 2253 | threads.append(thread_tcpreplay) |
| 2254 | for thread in threads: |
| 2255 | thread.start() |
| 2256 | for thread in threads: |
| 2257 | thread.join() |
| 2258 | while not que.empty(): |
| 2259 | threads_status = que.get() |
| 2260 | assert_equal(threads_status, 'failed') |
| 2261 | |
| 2262 | |
| 2263 | @deferred(TEST_TIMEOUT_DELAY-250) |
| 2264 | def test_netCondition_in_eap_tls_with_valid_client_and_dropped_server_eapid_response_packet(self): |
| 2265 | self.setUp_tls() |
| 2266 | df = defer.Deferred() |
| 2267 | self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 0, L4 = True) |
| 2268 | def eap_tls_emulating_server_pkts(df): |
| 2269 | self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping server eapId response') |
| 2270 | df.callback(0) |
| 2271 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2272 | return df |
| 2273 | |
| 2274 | @deferred(TEST_TIMEOUT_DELAY-50) |
| 2275 | def test_netCondition_in_eap_tls_with_valid_client_and_invalid_server_eapid_response_packet(self): |
| 2276 | self.setUp_tls() |
| 2277 | df = defer.Deferred() |
| 2278 | self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 0, no_of_radius_attribute = 1) |
| 2279 | def eap_tls_emulating_server_pkts(df): |
| 2280 | self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid server eapId response') |
| 2281 | df.callback(0) |
| 2282 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2283 | return df |
| 2284 | @deferred(TEST_TIMEOUT_DELAY-50) |
| 2285 | def test_netCondition_in_eap_tls_with_valid_client_and_dropped_server_hello_packet(self): |
| 2286 | self.setUp_tls() |
| 2287 | df = defer.Deferred() |
| 2288 | self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 1, L4 = True) |
| 2289 | def eap_tls_emulating_server_pkts(df): |
| 2290 | self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping server hello packet') |
| 2291 | df.callback(0) |
| 2292 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2293 | return df |
| 2294 | |
| 2295 | @deferred(TEST_TIMEOUT_DELAY-50) |
| 2296 | def test_netCondition_in_eap_tls_with_valid_client_and_invalid_server_hello_packet(self): |
| 2297 | self.setUp_tls() |
| 2298 | df = defer.Deferred() |
| 2299 | self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 1, no_of_radius_attribute = 1) |
| 2300 | def eap_tls_emulating_server_pkts(df): |
| 2301 | self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid server hello packet') |
| 2302 | df.callback(0) |
| 2303 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2304 | return df |
| 2305 | |
| 2306 | @deferred(TEST_TIMEOUT_DELAY-50) |
| 2307 | def test_netCondition_in_eap_tls_with_valid_client_and_dropped_client_certficate_access_challenge_server_packet(self): |
| 2308 | self.setUp_tls() |
| 2309 | df = defer.Deferred() |
| 2310 | self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 2, L4 = True) |
| 2311 | def eap_tls_emulating_server_pkts(df): |
| 2312 | self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping client certificate access challenge packet') |
| 2313 | df.callback(0) |
| 2314 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2315 | return df |
| 2316 | |
| 2317 | @deferred(TEST_TIMEOUT_DELAY-50) |
| 2318 | def test_netCondition_in_eap_tls_with_valid_client_and_invalid_client_certficate_access_challenge_server_packet(self): |
| 2319 | self.setUp_tls() |
| 2320 | df = defer.Deferred() |
| 2321 | self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 2, no_of_radius_attribute = 1) |
| 2322 | def eap_tls_emulating_server_pkts(df): |
| 2323 | self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid client certificate access challenge packet') |
| 2324 | df.callback(0) |
| 2325 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2326 | return df |
| 2327 | |
| 2328 | @deferred(TEST_TIMEOUT_DELAY-50) |
| 2329 | def test_netCondition_in_eap_tls_with_valid_client_and_dropped_client_certficate_with_2nd_fragment_access_challenge_server_packet(self): |
| 2330 | self.setUp_tls() |
| 2331 | df = defer.Deferred() |
| 2332 | self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 3, L4 = True) |
| 2333 | def eap_tls_emulating_server_pkts(df): |
| 2334 | self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping client certificate with 2nd fragment access challenge packet') |
| 2335 | df.callback(0) |
| 2336 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2337 | return df |
| 2338 | |
| 2339 | @deferred(TEST_TIMEOUT_DELAY-50) |
| 2340 | def test_netCondition_in_eap_tls_with_valid_client_and_invalid_client_certficate_with_2nd_fragment_access_challenge_server_packet(self): |
| 2341 | self.setUp_tls() |
| 2342 | df = defer.Deferred() |
| 2343 | self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 3, no_of_radius_attribute = 1) |
| 2344 | def eap_tls_emulating_server_pkts(df): |
| 2345 | self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid client certificate for 2nd fragment access challenge packet') |
| 2346 | df.callback(0) |
| 2347 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2348 | return df |
| 2349 | |
| 2350 | @deferred(TEST_TIMEOUT_DELAY-50) |
| 2351 | def test_netCondition_in_eap_tls_with_valid_client_and_dropped_client_certficate_with_3rd_fragment_access_challenge_server_packet(self): |
| 2352 | self.setUp_tls() |
| 2353 | df = defer.Deferred() |
| 2354 | self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 4, L4 = True) |
| 2355 | def eap_tls_emulating_server_pkts(df): |
| 2356 | self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping client certificate for 3rd fragment access challenge packet') |
| 2357 | df.callback(0) |
| 2358 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2359 | return df |
| 2360 | |
| 2361 | @deferred(TEST_TIMEOUT_DELAY-50) |
| 2362 | def test_netCondition_in_eap_tls_with_valid_client_and_invalid_client_certficate_with_3rd_fragment_access_challenge_server_packet(self): |
| 2363 | self.setUp_tls() |
| 2364 | df = defer.Deferred() |
| 2365 | self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 4, no_of_radius_attribute = 1) |
| 2366 | def eap_tls_emulating_server_pkts(df): |
| 2367 | self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid client certificate for 3rd fragment access challenge packet') |
| 2368 | df.callback(0) |
| 2369 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2370 | return df |
| 2371 | |
| 2372 | @deferred(TEST_TIMEOUT_DELAY-50) |
| 2373 | def test_netCondition_in_eap_tls_with_valid_client_and_dropped_cipher_suite_request_server_packet(self): |
| 2374 | self.setUp_tls() |
| 2375 | df = defer.Deferred() |
| 2376 | self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 5, L4 = True) |
| 2377 | def eap_tls_emulating_server_pkts(df): |
| 2378 | self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping cipher suite request server packet') |
| 2379 | df.callback(0) |
| 2380 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2381 | return df |
| 2382 | |
| 2383 | @deferred(TEST_TIMEOUT_DELAY-50) |
| 2384 | def test_netCondition_in_eap_tls_with_valid_client_and_invalid_cipher_suite_request_server_packet(self): |
| 2385 | self.setUp_tls() |
| 2386 | df = defer.Deferred() |
| 2387 | self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 5, no_of_radius_attribute = 1) |
| 2388 | def eap_tls_emulating_server_pkts(df): |
| 2389 | self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid cipher suite request server packet') |
| 2390 | df.callback(0) |
| 2391 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2392 | return df |
| 2393 | |
| 2394 | @deferred(TEST_TIMEOUT_DELAY-50) |
| 2395 | def test_netCondition_in_eap_tls_with_valid_client_and_dropped_access_accept_server_packet(self): |
| 2396 | self.setUp_tls() |
| 2397 | df = defer.Deferred() |
| 2398 | self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 6, L4 = True) |
| 2399 | def eap_tls_emulating_server_pkts(df): |
| 2400 | self.eap_tls_emulating_server_pkts_negative_testing(msg = 'dropping access accept server packet ') |
| 2401 | df.callback(0) |
| 2402 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2403 | return df |
| 2404 | |
| 2405 | @deferred(TEST_TIMEOUT_DELAY-50) |
| 2406 | def test_netCondition_in_eap_tls_with_valid_client_and_invalid_access_accept_server_packet(self): |
| 2407 | self.setUp_tls() |
| 2408 | df = defer.Deferred() |
| 2409 | self.emulating_invalid_radius_server_packets_from_pcap_file(pkt_no = 6, no_of_radius_attribute = 1) |
| 2410 | def eap_tls_emulating_server_pkts(df): |
| 2411 | self.eap_tls_emulating_server_pkts_negative_testing(msg = 'invalid access accept server packet ') |
| 2412 | df.callback(0) |
| 2413 | reactor.callLater(0, eap_tls_emulating_server_pkts, df) |
| 2414 | return df |
| 2415 | |