blob: 2168640383c548159987c8031753ddc9be39e74b [file] [log] [blame]
Chetan Gaonkercfcce782016-05-10 10:10:42 -07001#
2# Copyright 2016-present Ciena Corporation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
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 Karthicka2e53d62016-02-19 17:38:30 -080024
25class eap_auth_exchange(unittest.TestCase):
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -080026
27 app = 'org.onosproject.aaa'
28
29 def setUp(self):
30 self.onos_ctrl = OnosCtrl(self.app)
31 self.onos_aaa_config()
32
33 def onos_aaa_config(self):
34 aaa_dict = {'apps' : { 'org.onosproject.aaa' : { 'AAA' : { 'radiusSecret': 'radius_password',
35 'radiusIp': '172.17.0.2' } } } }
36 radius_ip = os.getenv('ONOS_AAA_IP') or '172.17.0.2'
37 aaa_dict['apps']['org.onosproject.aaa']['AAA']['radiusIp'] = radius_ip
Chetan Gaonker41d2e072016-03-15 16:41:31 -070038 self.onos_ctrl.activate()
39 time.sleep(2)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -080040 self.onos_load_config(aaa_dict)
41
42 def onos_load_config(self, config):
Chetan Gaonkera2b87df2016-03-31 15:41:31 -070043 status, code = OnosCtrl.config(config)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -080044 if status is False:
45 log.info('Configure request for AAA returned status %d' %code)
46 assert_equal(status, True)
Chetan Gaonker41d2e072016-03-15 16:41:31 -070047 time.sleep(3)
A R Karthick22aa0c62016-05-31 11:17:12 -070048
49 @deferred(20)
A R Karthicka2e53d62016-02-19 17:38:30 -080050 def test_eap_tls(self):
A R Karthick22aa0c62016-05-31 11:17:12 -070051 df = defer.Deferred()
52 def eap_tls_verify(df):
53 tls = TLSAuthTest()
54 tls.runTest()
55 df.callback(0)
56 reactor.callLater(0, eap_tls_verify, df)
57 return df
A R Karthicka2e53d62016-02-19 17:38:30 -080058
59if __name__ == '__main__':
60 t = TLSAuthTest()
61 t.runTest()
62