blob: 1dcf7a20c3346439408a7d21be41d3e20f342cb3 [file] [log] [blame]
ChetanGaonkerd43b7d42016-06-08 11:07:34 -07001#
Chetan Gaonkercfcce782016-05-10 10:10:42 -07002# 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
ChetanGaonkerd43b7d42016-06-08 11:07:34 -07007#
Chetan Gaonkercfcce782016-05-10 10:10:42 -07008# http://www.apache.org/licenses/LICENSE-2.0
ChetanGaonkerd43b7d42016-06-08 11:07:34 -07009#
Chetan Gaonkercfcce782016-05-10 10:10:42 -070010# 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#
A R Karthicka2e53d62016-02-19 17:38:30 -080016import unittest
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -080017import time
18import os
19from nose.tools import *
A R Karthick22aa0c62016-05-31 11:17:12 -070020from nose.twistedtools import reactor, deferred
21from twisted.internet import defer
A R Karthicka2e53d62016-02-19 17:38:30 -080022from EapTLS import TLSAuthTest
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -080023from OnosCtrl import OnosCtrl
A R Karthick9313b762016-11-07 13:14:35 -080024from CordLogger import CordLogger
ChetanGaonkerd43b7d42016-06-08 11:07:34 -070025from scapy.all import *
ChetanGaonker6138fcd2016-08-18 17:56:39 -070026from scapy_ssl_tls.ssl_tls import *
27from scapy_ssl_tls.ssl_tls_crypto import *
ChetanGaonkerd43b7d42016-06-08 11:07:34 -070028log.setLevel('INFO')
A R Karthicka2e53d62016-02-19 17:38:30 -080029
A R Karthick9313b762016-11-07 13:14:35 -080030class eap_auth_exchange(CordLogger):
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -080031
A.R Karthick95d044e2016-06-10 18:44:36 -070032 app = 'org.opencord.aaa'
ChetanGaonkerd43b7d42016-06-08 11:07:34 -070033 TLS_TIMEOUT = 20
ChetanGaonker6138fcd2016-08-18 17:56:39 -070034 TEST_TIMEOUT = 3600
ChetanGaonkerd43b7d42016-06-08 11:07:34 -070035 CLIENT_CERT_INVALID = '''-----BEGIN CERTIFICATE-----
A R Karthickaa10a202016-08-15 15:06:21 -070036MIIEyTCCA7GgAwIBAgIJAM6l2jUG56pLMA0GCSqGSIb3DQEBCwUAMIGLMQswCQYD
37VQQGEwJVUzELMAkGA1UECBMCQ0ExEjAQBgNVBAcTCVNvbWV3aGVyZTETMBEGA1UE
38ChMKQ2llbmEgSW5jLjEeMBwGCSqGSIb3DQEJARYPYWRtaW5AY2llbmEuY29tMSYw
39JAYDVQQDEx1FeGFtcGxlIENlcnRpZmljYXRlIEF1dGhvcml0eTAeFw0xNjAzMTEx
40ODUzMzVaFw0xNzAzMDYxODUzMzVaMIGLMQswCQYDVQQGEwJVUzELMAkGA1UECBMC
41Q0ExEjAQBgNVBAcTCVNvbWV3aGVyZTETMBEGA1UEChMKQ2llbmEgSW5jLjEeMBwG
42CSqGSIb3DQEJARYPYWRtaW5AY2llbmEuY29tMSYwJAYDVQQDEx1FeGFtcGxlIENl
43cnRpZmljYXRlIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
44ggEBAL9Jv54TkqycL3U2Fdd/y5NXdnPVXwAVV3m6I3eIffVCv8eS+mwlbl9dnbjo
45qqlGEgA3sEg5HtnKoW81l3PSyV/YaqzUzbcpDlgWlbNkFQ3nVxh61gSU34Fc4h/W
46plSvCkwGSbV5udLtEe6S9IflP2Fu/eXa9vmUtoPqDk66p9U/nWVf2H1GJy7XanWg
47wke+HpQvbzoSfPJS0e5Rm9KErrzaIkJpqt7soW+OjVJitUax7h45RYY1HHHlbMQ0
48ndWW8UDsCxFQO6d7nsijCzY69Y8HarH4mbVtqhg3KJevxD9UMRy6gdtPMDZLah1c
49LHRu14ucOK4aF8oICOgtcD06auUCAwEAAaOCASwwggEoMB0GA1UdDgQWBBQwEs0m
50c8HARTVp21wtiwgav5biqjCBwAYDVR0jBIG4MIG1gBQwEs0mc8HARTVp21wtiwga
51v5biqqGBkaSBjjCBizELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRIwEAYDVQQH
52EwlTb21ld2hlcmUxEzARBgNVBAoTCkNpZW5hIEluYy4xHjAcBgkqhkiG9w0BCQEW
53D2FkbWluQGNpZW5hLmNvbTEmMCQGA1UEAxMdRXhhbXBsZSBDZXJ0aWZpY2F0ZSBB
54dXRob3JpdHmCCQDOpdo1BueqSzAMBgNVHRMEBTADAQH/MDYGA1UdHwQvMC0wK6Ap
55oCeGJWh0dHA6Ly93d3cuZXhhbXBsZS5jb20vZXhhbXBsZV9jYS5jcmwwDQYJKoZI
56hvcNAQELBQADggEBAK+fyAFO8CbH35P5mOX+5wf7+AeC+5pwaFcoCV0zlfwniANp
57jISgcIX9rcetLxeYRAO5com3+qLdd9dGVNL0kwufH4QhlSPErG7OLHHAs4JWVhUo
58bH3lK9lgFVlnCDBtQhslzqScR64SCicWcQEjv3ZMZsJwYLvl8unSaKz4+LVPeJ2L
59opCpmZw/V/S2NhBbe3QjTiRPmDev2gbaO4GCfi/6sCDU7UO3o8KryrkeeMIiFIej
60gfwn9fovmpeqCEyupy2JNNUTJibEuFknwx7JAX+htPL27nEgwV1FYtwI3qLiZqkM
61729wo9cFSslJNZBu+GsBP5LszQSuvNTDWytV+qY=
ChetanGaonkerd43b7d42016-06-08 11:07:34 -070062-----END CERTIFICATE-----'''
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -080063
ChetanGaonker6138fcd2016-08-18 17:56:39 -070064 invalid_cipher_suites = ['TLS_RSA_WITH_NULL_SHA256',
65 'TLS_RSA_WITH_AES_128_CBC_SHA',
66 'TLS_RSA_WITH_AES_128_CBC_SHA256',
67 'TLS_RSA_WITH_AES_256_CBC_SHA256',
68 'TLS_DHE_DSS_WITH_AES_128_CBC_SHA256',
69 'TLS_DHE_RSA_WITH_AES_128_CBC_SHA256',
70 'TLS_DH_anon_WITH_AES_128_CBC_SHA256',
71 'TLS_DHE_DSS_WITH_AES_256_CBC_SHA256',
72 'TLS_DHE_RSA_WITH_AES_256_CBC_SHA256',
73 'TLS_DH_anon_WITH_AES_256_CBC_SHA256']
74
ChetanGaonkerd43b7d42016-06-08 11:07:34 -070075 def setUp(self):
A R Karthick9313b762016-11-07 13:14:35 -080076 super(eap_auth_exchange, self).setUp()
ChetanGaonkerd43b7d42016-06-08 11:07:34 -070077 self.onos_ctrl = OnosCtrl(self.app)
78 self.onos_aaa_config()
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -080079
ChetanGaonkerd43b7d42016-06-08 11:07:34 -070080 def onos_aaa_config(self):
81 aaa_dict = {'apps' : { 'org.onosproject.aaa' : { 'AAA' : { 'radiusSecret': 'radius_password',
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -080082 'radiusIp': '172.17.0.2' } } } }
ChetanGaonkerd43b7d42016-06-08 11:07:34 -070083 radius_ip = os.getenv('ONOS_AAA_IP') or '172.17.0.2'
84 aaa_dict['apps']['org.onosproject.aaa']['AAA']['radiusIp'] = radius_ip
85 self.onos_ctrl.activate()
86 time.sleep(2)
87 self.onos_load_config(aaa_dict)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -080088
ChetanGaonkerd43b7d42016-06-08 11:07:34 -070089 def onos_load_config(self, config):
90 status, code = OnosCtrl.config(config)
91 if status is False:
92 log.info('Configure request for AAA returned status %d' %code)
93 assert_equal(status, True)
Chetan Gaonker41d2e072016-03-15 16:41:31 -070094 time.sleep(3)
A R Karthick22aa0c62016-05-31 11:17:12 -070095
ChetanGaonkerd43b7d42016-06-08 11:07:34 -070096 @deferred(TLS_TIMEOUT)
97 def test_eap_tls(self):
98 df = defer.Deferred()
99 def eap_tls_verify(df):
100 tls = TLSAuthTest()
101 tls.runTest()
102 df.callback(0)
103 reactor.callLater(0, eap_tls_verify, df)
104 return df
105
106 @deferred(TLS_TIMEOUT)
107 def test_eap_tls_with_no_cert(self):
108 df = defer.Deferred()
109 def eap_tls_no_cert(df):
110 def tls_no_cert_cb():
111 log.info('TLS authentication failed with no certificate')
ChetanGaonkerd43b7d42016-06-08 11:07:34 -0700112 tls = TLSAuthTest(fail_cb = tls_no_cert_cb, client_cert = '')
113 tls.runTest()
114 assert_equal(tls.failTest, True)
115 df.callback(0)
116 reactor.callLater(0, eap_tls_no_cert, df)
117 return df
118
119 @deferred(TLS_TIMEOUT)
120 def test_eap_tls_with_invalid_cert(self):
121 df = defer.Deferred()
122 def eap_tls_invalid_cert(df):
123 def tls_invalid_cert_cb():
124 log.info('TLS authentication failed with invalid certificate')
125
126 tls = TLSAuthTest(fail_cb = tls_invalid_cert_cb,
127 client_cert = self.CLIENT_CERT_INVALID)
128 tls.runTest()
129 assert_equal(tls.failTest, True)
130 df.callback(0)
131 reactor.callLater(0, eap_tls_invalid_cert, df)
132 return df
133
134 @deferred(TLS_TIMEOUT)
135 def test_eap_tls_Nusers_with_same_valid_cert(self):
136 df = defer.Deferred()
137 def eap_tls_Nusers_with_same_valid_cert(df):
138 num_users = 3
139 for i in xrange(num_users):
140 tls = TLSAuthTest(intf = 'veth{}'.format(i*2))
141 tls.runTest()
142 df.callback(0)
143 reactor.callLater(0, eap_tls_Nusers_with_same_valid_cert, df)
144 return df
A R Karthicka2e53d62016-02-19 17:38:30 -0800145
ChetanGaonker6138fcd2016-08-18 17:56:39 -0700146 @deferred(TLS_TIMEOUT)
147 def test_eap_tls_invalid_session_id(self):
148 df = defer.Deferred()
149 def eap_tls_invalid_session_id(df):
150 def tls_invalid_session_id_cb():
151 log.info('TLS authentication failed with invalid session id')
152 tls = TLSAuthTest(fail_cb = tls_invalid_session_id_cb,session_id = 12345, session_id_length = 1)
153 tls.runTest()
154 assert_equal(tls.failTest, True)
155 df.callback(0)
156 reactor.callLater(0, eap_tls_invalid_session_id, df)
157 return df
158
159 @deferred(TLS_TIMEOUT)
160 def test_eap_tls_random_gmt_unix_time(self):
161 df = defer.Deferred()
162 def eap_tls_invalid_gmt_unix_time(df):
163 def eap_tls_invalid_gmt_unix_time_cb():
164 log.info('TLS authentication failed with invalid gmt_unix_time in Client Hello Packet')
165 for i in [0,7265,98758,23627238]:
166 log.info("\nExecuting test case with gmt_unix_time value is set to %d"%i)
167 tls = TLSAuthTest(fail_cb = eap_tls_invalid_gmt_unix_time_cb, gmt_unix_time = i)
168 tls.runTest()
169 assert_equal(tls.failTest, True)
170 df.callback(0)
171 reactor.callLater(0, eap_tls_invalid_gmt_unix_time, df)
172 return df
173
174 @deferred(TLS_TIMEOUT)
175 def test_eap_tls_invalid_content_type(self,Positive_Test=True):
176 df = defer.Deferred()
177 def eap_tls_invalid_content_type(df):
178 def tls_invalid_content_type_cb():
179 log.info('TLS authentication failed with invalid content type in TLSContentType packet')
180 tls = TLSAuthTest(fail_cb = tls_invalid_content_type_cb, invalid_content_type = 24)
181 tls.runTest()
182 assert_equal(tls.failTest, True)
183 df.callback(0)
184 reactor.callLater(0, eap_tls_invalid_content_type, df)
185 return df
186
187 @deferred(TLS_TIMEOUT)
188 def test_eap_tls_invalid_record_fragment_length(self):
189 df = defer.Deferred()
190 def eap_tls_invalid_record_fragment_length(df):
191 def eap_tls_invalid_record_fragment_length_cb():
192 log.info('TLS authentication failed with invalid fragment length field in TLSRecord packet')
193 tls = TLSAuthTest(fail_cb = eap_tls_invalid_record_fragment_length_cb, record_fragment_length = 17384)
194 tls.runTest()
195 assert_equal(tls.failTest, True)
196 df.callback(0)
197 reactor.callLater(0, eap_tls_invalid_record_fragment_length, df)
198 return df
199
200 #invalid id field in identifier response packet
201 @deferred(TLS_TIMEOUT)
202 def test_eap_tls_with_invalid_id_in_identifier_response_packet(self):
203 df = defer.Deferred()
204 def eap_tls_with_invalid_id_in_identifier_response_packet(df):
205 def tls_with_invalid_id_in_identifier_response_packet_cb():
206 log.info('TLS authentication failed with invalid id in identifier packet')
207 tls = TLSAuthTest(fail_cb = tls_with_invalid_id_in_identifier_response_packet_cb,
208 id_mismatch_in_identifier_response_packet = True)
209 tls.runTest()
210 assert_equal(tls.failTest, True)
211 df.callback(0)
212 reactor.callLater(0, eap_tls_with_invalid_id_in_identifier_response_packet, df)
213 return df
214
215 #invalid id field in client hello packet
216 @deferred(TLS_TIMEOUT)
217 def test_eap_tls_with_invalid_id_in_client_hello_packet(self):
218 df = defer.Deferred()
219 def eap_tls_with_invalid_id_in_client_hello_packet(df):
220 def tls_with_invalid_id_in_client_hello_packet_cb():
221 log.info('TLS authentication failed with invalid id in client hello packet')
222 tls = TLSAuthTest(fail_cb = tls_with_invalid_id_in_client_hello_packet_cb,
223 id_mismatch_in_client_hello_packet = True)
224 tls.runTest()
225 assert_equal(tls.failTest, True)
226 df.callback(0)
227 reactor.callLater(0, eap_tls_with_invalid_id_in_client_hello_packet, df)
228 return df
229
230 @deferred(TLS_TIMEOUT)
231 def test_eap_tls_without_sending_client_hello(self):
232 df = defer.Deferred()
233 def eap_tls_without_sending_client_hello(df):
234 def tls_without_sending_client_hello_cb():
235 log.info('TLS authentication failed with not sending client hello')
236 tls = TLSAuthTest(fail_cb = tls_without_sending_client_hello_cb,
237 dont_send_client_hello = True)
238 tls.runTest()
239 assert_equal(tls.failTest, True)
240 df.callback(0)
241 reactor.callLater(0, eap_tls_without_sending_client_hello, df)
242 return df
243
244 @deferred(TLS_TIMEOUT)
245 def test_eap_tls_aaa_app_deactivate(self):
246 df = defer.Deferred()
247 def eap_tls_aaa_app_deactivate(df):
248 def tls_aaa_app_deactivate_cb():
249 log.info('TLS authentication failed with aaa app deactivated in ONOS')
250 tls = TLSAuthTest(fail_cb = tls_aaa_app_deactivate_cb)
251 self.onos_ctrl.deactivate()
252 tls.runTest()
253 assert_equal(tls.failTest, True)
254 df.callback(0)
255 reactor.callLater(0, eap_tls_aaa_app_deactivate, df)
256 return df
257
258 #keeping cipher suite length as zero but including cipher suite key which is more than zero length in client hello packet
259 @deferred(TLS_TIMEOUT)
260 def test_eap_tls_incorrect_cipher_suite_length_field(self):
261 df = defer.Deferred()
262 def eap_tls_incorrect_cipher_suite_length_field(df):
263 def tls_incorrect_cipher_suite_length_field_cb():
264 log.info('TLS authentication failed with incorrect cipher suite length field in client hello packet')
265 tls = TLSAuthTest(fail_cb = tls_incorrect_cipher_suite_length_field_cb, cipher_suites_length = 0)
266 tls.runTest()
267 assert_equal(tls.failTest, True)
268 df.callback(0)
269 reactor.callLater(0, eap_tls_incorrect_cipher_suite_length_field, df)
270 return df
271
272 #keeping compression methods length to zero but sending compression method of more than 0 zero length in client hello packet
273 @deferred(TLS_TIMEOUT)
274 def test_eap_tls_incorrect_compression_methods_length_field(self):
275 df = defer.Deferred()
276 def eap_tls_incorrect_compression_methods_length_field(df):
277 def tls_incorrect_compression_methods_length_field_cb():
278 log.info('TLS authentication failed with incorrect compression methods length field in client hello packet')
279 tls = TLSAuthTest(fail_cb = tls_incorrect_compression_methods_length_field_cb, compression_methods_length=1,compression_methods=TLSCompressionMethod.LZS)
280 tls.runTest()
281 assert_equal(tls.failTest, True)
282 df.callback(0)
283 reactor.callLater(0, eap_tls_incorrect_compression_methods_length_field, df)
284 return df
285
286 #checking with broadcast source mac of EAPOL packet
287 @deferred(TLS_TIMEOUT)
288 def test_eap_tls_invalid_source_mac_broadcast(self):
289 df = defer.Deferred()
290 def eap_tls_invalid_source_mac_broadcast(df):
291 def tls_invalid_source_mac_broadcast_cb():
292 log.info('TLS authentication failed with invalid source mac as broadcast in EAPOL packet')
293 tls = TLSAuthTest(fail_cb = tls_invalid_source_mac_broadcast_cb, src_mac='bcast')
294 tls.runTest()
295 assert_equal(tls.failTest, True)
296 df.callback(0)
297 reactor.callLater(0, eap_tls_invalid_source_mac_broadcast, df)
298 return df
299
300 #checking with multicast source mac of EAPOL packet
301 @deferred(TLS_TIMEOUT)
302 def test_eap_tls_invalid_source_mac_multicast(self):
303 df = defer.Deferred()
304 def eap_tls_invalid_source_mac_multicast(df):
305 def tls_invalid_source_mac_multicast_cb():
306 log.info('TLS authentication failed with invalid source mac as multicast in EAPOL packet')
307 tls = TLSAuthTest(fail_cb = tls_invalid_source_mac_multicast_cb, src_mac='mcast')
308 tls.runTest()
309 assert_equal(tls.failTest, True)
310 df.callback(0)
311 reactor.callLater(0, eap_tls_invalid_source_mac_multicast, df)
312 return df
313
314 #checking with zero source mac of EAPOL packet
315 @deferred(TLS_TIMEOUT)
316 def test_eap_tls_invalid_source_mac_zero(self):
317 df = defer.Deferred()
318 def eap_tls_invalid_source_mac_zero(df):
319 def tls_invalid_source_mac_zero_cb():
320 log.info('TLS authentication failed with invalid source mac as zero in EAPOL packet')
321 tls = TLSAuthTest(fail_cb = tls_invalid_source_mac_zero_cb, src_mac='zeros')
322 tls.runTest()
323 assert_equal(tls.failTest, True)
324 df.callback(0)
325 reactor.callLater(0, eap_tls_invalid_source_mac_zero, df)
326 return df
327
328 #Restarting Radius server after sending client hello
329 @deferred(TLS_TIMEOUT)
330 def test_eap_tls_restart_radius_server(self):
331 df = defer.Deferred()
332 def eap_tls_restart_radius_server(df):
333 def tls_restart_radius_server_cb():
334 log.info('TLS authentication failed with radius server down in middle of authentication process')
335 tls = TLSAuthTest(fail_cb = tls_restart_radius_server_cb, restart_radius=True)
336 tls.runTest()
337 assert_equal(tls.failTest, True)
338 df.callback(0)
339 reactor.callLater(0, eap_tls_restart_radius_server, df)
340 return df
341
342 @deferred(TLS_TIMEOUT)
343 def test_eap_tls_with_incorrect_handshake_type_client_hello(self):
344 df = defer.Deferred()
345 def eap_tls_incorrect_handshake_type_client_hello(df):
346 def tls_incorrect_handshake_type_client_hello_cb():
347 log.info('TLS authentication failed with incorrect handshake type in client hello packet')
348 tls = TLSAuthTest(fail_cb = tls_incorrect_handshake_type_client_hello_cb, invalid_client_hello_handshake_type=True)
349 tls.runTest()
350 assert_equal(tls.failTest, True)
351 df.callback(0)
352 reactor.callLater(0, eap_tls_incorrect_handshake_type_client_hello, df)
353 return df
354
355 #Sending certificate request type of handhsake instead of certificate verify in client certificate request message
356 @deferred(TLS_TIMEOUT)
357 def test_eap_tls_with_incorrect_handshake_type_certificate_request(self):
358 df = defer.Deferred()
359 def eap_tls_incorrect_handshake_type_certificate_request(df):
360 def tls_incorrect_handshake_type_certificate_request_cb():
361 log.info('TLS authentication failed with incorrect handshake type in client certificate request packet')
362 tls = TLSAuthTest(fail_cb = tls_incorrect_handshake_type_certificate_request_cb, invalid_cert_req_handshake=True)
363 tls.runTest()
364 assert_equal(tls.failTest, True)
365 df.callback(0)
366 reactor.callLater(0, eap_tls_incorrect_handshake_type_certificate_request, df)
367 return df
368
369 #Sending tls record content type as 'ALERT' instead of 'HANDSHAKE' in certificate request packet
370 @deferred(TLS_TIMEOUT)
371 def test_eap_tls_with_incorrect_tlsrecord_certificate_request(self):
372 df = defer.Deferred()
373 def eap_tls_incorrect_tlsrecord_certificate_request(df):
374 def tls_incorrect_tlsrecord_certificate_request_cb():
375 log.info('TLS authentication failed with incorrect tlsrecord type in certificate request packet')
376 tls = TLSAuthTest(fail_cb = tls_incorrect_tlsrecord_certificate_request_cb, incorrect_tlsrecord_type_cert_req=True)
377 tls.runTest()
378 assert_equal(tls.failTest, True)
379 df.callback(0)
380 reactor.callLater(0, eap_tls_incorrect_tlsrecord_certificate_request, df)
381 return df
382
383 #Sending client hello with zero lenght field in Handshake protocol
384 @deferred(TLS_TIMEOUT)
385 def test_eap_tls_invalid_handshake_length_client_hello(self):
386 df = defer.Deferred()
387 def eap_tls_invalid_handshake_length_client_hello(df):
388 def tls_invalid_handshake_length_client_hello_cb():
389 log.info('TLS authentication failed with invalid handshake length in client hello packet')
390 tls = TLSAuthTest(fail_cb = tls_invalid_handshake_length_client_hello_cb, invalid_client_hello_handshake_length=True)
391 tls.runTest()
392 assert_equal(tls.failTest, True)
393 df.callback(0)
394 reactor.callLater(0, eap_tls_invalid_handshake_length_client_hello, df)
395 return df
396
397 @deferred(TLS_TIMEOUT)
398 def test_eap_tls_clientkeyex_replace_with_serverkeyex(self):
399 df = defer.Deferred()
400 def eap_tls_clientkeyex_replace_with_serverkeyex(df):
401 def tls_clientkeyex_replace_with_serverkeyex_cb():
402 log.info('TLS authentication failed with client key exchange replaced with server key exchange')
403 tls = TLSAuthTest(fail_cb = tls_clientkeyex_replace_with_serverkeyex_cb,clientkeyex_replace_with_serverkeyex=True)
404 tls.runTest()
405 assert_equal(tls.failTest, True)
406 df.callback(0)
407 reactor.callLater(0, eap_tls_clientkeyex_replace_with_serverkeyex, df)
408 return df
409
410 #simulating authentication for multiple users, 1K in this test case
411 @deferred(TEST_TIMEOUT)
412 def test_eap_tls_1k_with_diff_mac(self):
413 df = defer.Deferred()
414 def eap_tls_1k_with_diff_mac(df):
415 for i in xrange(1000):
416 tls = TLSAuthTest(src_mac = 'random')
417 tls.runTest()
418 log.info('Authentication successfull for user %d'%i)
419 df.callback(0)
420 reactor.callLater(0, eap_tls_1k_with_diff_mac, df)
421 return df
422
423 #simulating authentication for multiple users, 5K in this test case
424 @deferred(TEST_TIMEOUT)
425 def test_eap_tls_5k_with_diff_mac(self):
426 df = defer.Deferred()
427 def eap_tls_5k_with_diff_mac(df):
428 for i in xrange(5000):
429 tls = TLSAuthTest(src_mac = 'random')
430 tls.runTest()
431 log.info('Authentication successfull for user %d'%i)
432 df.callback(0)
433 reactor.callLater(0, eap_tls_5k_with_diff_mac, df)
434 return df
435
A R Karthicka2e53d62016-02-19 17:38:30 -0800436if __name__ == '__main__':
437 t = TLSAuthTest()
438 t.runTest()