当前位置: 首页>>代码示例>>Python>>正文


Python NS.ping方法代码示例

本文整理汇总了Python中NS.NS.ping方法的典型用法代码示例。如果您正苦于以下问题:Python NS.ping方法的具体用法?Python NS.ping怎么用?Python NS.ping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NS.NS的用法示例。


在下文中一共展示了NS.ping方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_AAA_NEG_003

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_AAA_NEG_003(test_case):

    myLog = getLogger()

    def setUp(self):
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(ssx1['ip_addr'])
	self.ssx.telnet()
        self.ssx.clear_health_stats()

        # Clear SSX configuration
	self.ssx.clear_config()
        # wait for card to come up
        self.ssx.wait4cards()

        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns['ip_addr'])
	self.ns5gt.telnet()
	self.ns5gt.clear_config()	

    def tearDown(self):
 	"""Clear the config and Close down the telnet session."""
        self.ssx.close()
        self.ns5gt.close()

    def test_AAA_NEG_003(self):
        """
        Test case Id: -  AAA-NEG-003
	"""

        #On SSX configure an AAA profile with the session authentication set to query local database..
        self.ssx.config_from_string(script_var['common_ssx1'])
        self.ssx.config_from_string(script_var['neg_003_ssx'])

        #Get the configuration from a string in a config file config.py and Load it in NS-5GT.
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['neg_003_ns5gt'])

        # Enable the iked & aaad debug on the SSX to verify the results
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")

        # Initiate IKEv1 session from the client to the SSX .
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.failUnless(not ping_output, "SSX didnot drop all the session requests though the radius profile is not configured in the context")

        op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s"%script_var['context'],"radius")
        self.failUnless(not op_debug,"Session authentication from client to SSX did not fail")

        # Checking SSX Health
        hs = self.ssx.get_health_stats()
        self.failUnless(is_healthy(hs), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:57,代码来源:AAA_NEG_003.py

示例2: test_AAA_FUN_023

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_AAA_FUN_023(test_case):

    myLog = getLogger()

    def setUp(self):
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(ssx1['ip_addr'])
        self.ssx.telnet()

        # Clear SSX configuration
        self.ssx.clear_config()
        # wait for card to come up
        self.ssx.wait4cards()
        self.ssx.clear_health_stats()


        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns['ip_addr'])
        self.ns5gt.telnet()
        self.ns5gt.clear_config()

    def tearDown(self):
 	"""Clear the config and Close down the telnet session."""
        self.ssx.close()
        self.ns5gt.close()

    def test_AAA_FUN_023(self):

        """
        Test case Id: -  AAA-FUN-023
        """

        #Push the SSX configuration 
        self.ssx.config_from_string(script_var['common_ssx1'])
        self.ssx.config_from_string(script_var['fun_023_ssx'])

        #Push the Netscreen configuration
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['fun_023_ns5gt'])

        # Enable debug logs for aaad
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")


        # Initiate IKEv1 session from a Netscreen to the SSX
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.failUnless(not ping_output, "session authentication with Radius \
                        succeeded even with INVALID session credentials")

        #Verify IKEv1 session authentication
        op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s" %script_var['context'],"radius")
	self.failUnless(not op_debug, "session authentication successful even with invalid authentication crentials")

        # Checking SSX Health
        hs = self.ssx.get_health_stats()
        self.failUnless(is_healthy(hs), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:62,代码来源:AAA_FUN_023.py

示例3: test_AAA_FUN_026

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_AAA_FUN_026(test_case):

    myLog = getLogger()

    def setUp(self):
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(ssx1['ip_addr'])
        self.ssx.telnet()

        # Clear SSX configuration
        self.ssx.clear_config()
        # wait for card to come up
        self.ssx.wait4cards()

        self.ssx.clear_health_stats()

        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns['ip_addr'])
        self.ns5gt.telnet()
        self.ns5gt.clear_config()


    def tearDown(self):
 	"""Clear the config and Close down the telnet session."""
        self.ssx.close()
        self.ns5gt.close()

    def test_AAA_FUN_026(self):

        """
	Test case Id: -  AAA-FUN-026
	"""

        #On SSX configure an AAA profile with the session authentication set to query local database
        self.ssx.config_from_string(script_var['common_ssx1'])
        self.ssx.config_from_string(script_var['fun_026_ssx'])

        #Get the configuration from a string in a config file config.py and Load it in NS-5GT.
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['fun_026_ns5gt'])

        # Enable debug logs for aaad
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")


	# Initiate IKEv1 session from a client to the SSX with valid session credentials.
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.failUnless(not ping_output, "session authentication succeeded with the primary database(RADIUS)")

        #Verify IKEv1 Session authentication
        op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s" %script_var['context'],"local")
        self.failUnless(not op_debug, "X-auth not successful")

        # Checking SSX Health
        hs = self.ssx.get_health_stats()
        self.failUnless(is_healthy(hs), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:61,代码来源:AAA_FUN_026.py

示例4: test_AAA_FUN_031

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_AAA_FUN_031(test_case):

    myLog = getLogger()
    def setUp(self):
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(ssx1['ip_addr'])
        self.ssx.telnet()
        self.ssx.clear_config()
        # wait for card to come up
        self.ssx.wait4cards()
        self.ssx.clear_health_stats()

        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns['ip_addr'])
        self.ns5gt.telnet()
        self.ns5gt.clear_config()

    def tearDown(self):
 	"""Clear the config and Close down the telnet session."""
        self.ssx.close()
        self.ns5gt.close()

    def test_AAA_FUN_031(self):

        """
        Test case Id: -  AAA-FUN-031
        """

        #On SSX configure an AAA profile with the session authentication set to Radius
        self.ssx.config_from_string(script_var['common_ssx1'])
        self.ssx.config_from_string(script_var['fun_031_ssx'])

        #Get the configuration from a string in a config file config.py and Load it in NS-5GT.
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['fun_031_ns5gt'])

        # Enable debug logs for aaad
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")


	# Initiate IKEv1 session from a client (which have valid authorization attribute binded to improroper session)
	# to the SSX with valid session credentials.
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
	self.failUnless(ping_output, "client not having authorized IPSEC policy")

	#Verify successful Phase1 authentication and  IKEv1 session establishment
        op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s" %script_var['context'],"local")
        self.failUnless(op_debug, "phase-1 session authentication and establishment is not successful")
     
	#Verify successful Phase2 authentication and session establishment
	op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s" %script_var['context'],"local")
        self.failUnless(op_debug, "X-auth not successful")

        #Check the SA status in SSX.
        self.ssx.cmd("context %s" %script_var['context'])
        sa_output= sa_check(self.ssx,script_var['ns_phy_ip'])
        self.failUnless(sa_output,"SA not loaded")
					
	 # Checking SSX Health
        hs = self.ssx.get_health_stats()
        self.failUnless(is_healthy(hs), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:67,代码来源:AAA_FUN_031.py

示例5: test_RADIUS_FUN_030

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_RADIUS_FUN_030(test_case):

    myLog = getLogger()

    def setUp(self):
        #Establish a telnet session to the SSX box.
	self.ssx = SSX(ssx1['ip_addr'])
        self.ssx.telnet()

        # Clear the SSX config
        self.ssx.clear_config()
        # wait for card to come up
        self.ssx.wait4cards()
        self.ssx.clear_health_stats()

        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns['ip_addr'])
        self.ns5gt.telnet()
        self.ns5gt.clear_config()

        """Establish a telnet session to Linux machine ."""
        self.linux = Linux(topo.linux["ip_addr"],topo.linux["user_name"],topo.linux["password"])
        self.linux.telnet()

        self.ether_radius1 = Linux(radius1['ip_addr'],radius1['user_name'],radius1['password'])
        self.ether_radius1.telnet()


    def tearDown(self):
        """Clear the config and Close down the telnet session."""

        self.ssx.close()
        self.ns5gt.close()
        self.linux.close()
	self.ether_radius1.close()

    def test_RADIUS_FUN_030(self):

        """
        Test case Id: -  RADIUS-FUN-030
        Description: - Verify that the correct terminate cause type is reflected 
		 in the Accounting-request (stop) when the session is terminated.
        """

	self.myLog.output("\n**********start the test**************\n")
	
	# Configure SSX to forward session authentication & session accounting 
	# credentials to radius server for authentication.
	self.ssx.config_from_string(script_var['common_ssx1'])
	self.ssx.config_from_string(script_var['rad_fun_030_ssx'])

	# Configure the IKEv1 Phase1 & Phase2 Polices on the SSX. 
	# Ensure that the client is also configured with matching policies.
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['rad_fun_030_ns5gt'])

        # Enable debug logs for aaad
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
	# Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug") 


        self.myLog.output(" Step 1 - removing the file rad_fun_030.pcap")
        self.ether_radius1.cmd("sudo rm rad_fun_030.pcap -f")

        self.myLog.output("Step 2 -Start tethereal to capture the packets and store the result in a pcap file")
        #self.ether_radius1.cmd('sudo /usr/sbin/tethereal -h')
        self.ether_radius1.cmd('sudo /usr/sbin/tethereal -i %s -q  -w rad_fun_030.pcap  & '% topo.port_ssx_radius1[1])

        # Initiate IKEv1 session from a Netscreen to the SSX
        # ping ikev1 clent from ssx
        self.ssx.ping('%s'% script_var['ns_phy_ip'])
        time.sleep(5)
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        time.sleep(5)

        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.failUnless(ping_output,"session authentication with Radius is not\
                        successed even with valid session credentials")
       
        #Clear the sessions
        self.ssx.cmd("context %s" %script_var['context'])
        self.ssx.cmd("clear session all")

        self.myLog.output (" Step 3 - stop tethereal by killing the tethereal application.")
	time.sleep(10)
        self.ether_radius1.cmd("sudo pkill tethereal")

        # Check whether the pcap file is created or not
        ll_output = self.ether_radius1.cmd("ls -lrt *.pcap")
        self.failUnless("rad_fun_030.pcap" in ll_output,"Testcase FAILED because pcap file has not created ")

	# Read the contents of the pcap file 
        self.myLog.output (" Step 4 - read the content of the file rad_fun_030.pcap")
        output=self.ether_radius1.cmd('sudo /usr/sbin/tethereal -r rad_fun_030.pcap -R "radius.Acct_Terminate_Cause  == 6"',timeout = 30)

        # Checking SSX Health
        hs = self.ssx.get_health_stats()
#.........这里部分代码省略.........
开发者ID:muttu2244,项目名称:MyPython,代码行数:103,代码来源:RADIUS_FUN_030.py

示例6: test_AAA_FUN_030

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_AAA_FUN_030(test_case):

    def setUp(self):
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(ssx1['ip_addr'])
        self.ssx.telnet()
        self.ssx.clear_config()

        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns1['ip_addr'])
        self.ns5gt.telnet()
        self.ns5gt.clear_config()

        """Establish a telnet session to the Xpress VPN client box."""
        linux1 = Linux(topo.linux_client["ip_addr"],topo.linux_client["user_name"],topo.linux_client["password"])
        self.linux_client.telnet()



    def tearDown(self):
 	"""Clear the config and Close down the telnet session."""
        self.ssx.close()
        self.ns5gt.close()
	linux1.close()        
    def test_AAA_FUN_030(self):

        """
        Test case Id: -  AAA-FUN-030
        Description: - Verify the SSX behavior when session authentication database is changed from local to radius 
"""
        #On SSX configure an AAA profile with the session authentication set to Radius and 
	#user authentication set to query local database.
        self.ssx.config_from_string(script_var['common_ssx'])
        self.ssx.config_from_string(script_var['fun_030_ssx'])
        self.ssx.config_from_string(script_var['user_add_ssx'])

        #Get the configuration from a string in a config file config.py and Load it in NS-5GT.
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['fun_030_ns5gt'])

        # Enable debug logs for aaad
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")


	# Initiate IKEv1 session from a client to the SSX with valid session credentials.
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
	self.failUnless(ping_output, "session radius authentication and establishment with local database is not successful")

	#Verify successful Phase1 authentication and  IKEv1 session establishedment
	op_debug = self.ssx.aaa_verify_authentication("[email protected]%s"%script_var['context'],"local")
        self.failUnless(op_debug, "Verifying in debugs:session radius authentication and establishment with local database\
				    is not successful")
	
	#Deleting old configuration
	self.cfg_from_str('''"context%s"script_var['context']\
			     clear session all 
				''')
	#change the session authentication from local to Radius
	self.cfg_from_str("aaa profile\ 
			session authentication radius\
	    	        service authorization radius
		     ")

	#Re-Initiate IKEv1 session from a client to the SSX with valid session credentials.
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.failUnless(ping_output, "PING FAILED")

	#Verify successful Phase1 authentication and  IKEv1 session establishedment
	op_debug = self.ssx.aaa_verify_authentication("[email protected]%s"%script_var['context'],"radius")
        self.failUnless(op_debug, "session Radius authentication and establishment is not successful")
				
	###################repeat this same case for user authentication also###########################################

	# Initiate Telnet Session from Xpress VPN Client  where user has adminstrator privileages
        op_telnet = self.linux1.generic_verify_telnet_2_ssx(script_var['ssx_phy_iface1_ip'],"[email protected]%s"%script_var['context'],"user1")
        self.failUnless(op_telnet is True,"telnet to SSX as a user was not success")

        # Check whether SSX queries the Radius database for user authentication 
	op_debug = self.ssx.aaa_verify_authentication("[email protected]","local")
        self.failUnless(op_debug,"the user authentication with local database was  not successful ")
	#chage the session authentication from local to Radius
	self.cfg_from_str("context %s\
			aaa profile\
		        session authentication radius\
			service authorization radius" %script_var['context'])

	#Re-Initiate Telnet Session from Xpress VPN Client  where user has adminstrator privileages
        op_telnet = self.linux1.generic_verify_telnet_2_ssx(script_var['ssx_phy_iface1_ip'],"[email protected]%s"%script_var['context'],"user1")
        self.failUnless(op_telnet is True,"telnet to SSX as a user was not success")

        # Check whether SSX quiries the local database for user authentication 
	op_debug = self.ssx.aaa_verify_authentication("[email protected]","radius")
        self.failUnless(op_debug,"the user authentication with Radius not success ")
开发者ID:muttu2244,项目名称:MyPython,代码行数:100,代码来源:AAA_FUN_030_backup.py

示例7: test_RADIUS_FUN_007

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_RADIUS_FUN_007(test_case):

    myLog = getLogger()

    def setUp(self):
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(ssx1['ip_addr'])
        self.ssx.telnet()

        # Clear SSX configuration
        self.ssx.clear_config()
        # wait for card to come up
        self.ssx.wait4cards()
        self.ssx.clear_health_stats()

        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns['ip_addr'])
        self.ns5gt.telnet()
        self.ns5gt.clear_config()

        self.ether_linux = Linux(radius1['ip_addr'],radius1['user_name'],radius1['password'])
        self.ether_linux.telnet()

    def tearDown(self):
 	"""Clear the config and Close down the telnet session."""
        self.ssx.close()
        self.ns5gt.close()

        # Start the (killed) Radius daemon
        self.ether_linux.cmd("sudo /etc/init.d/radiusd start")

	self.ether_linux.close()

    def test_RADIUS_FUN_007(self):
        """
        Test case Id: -  RADIUS-FUN-007
        """

        #Push the SSX configuration        
	self.ssx.config_from_string(script_var['common_ssx'])
        self.ssx.config_from_string(script_var['rad_fun_006_ssx'])

        #Get the configuration from a string in a config file config.py and Load it in NS-5GT.
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['rad_fun_007_ns5gt'])

        # Enable debug logs for aaad
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")

	# Kill the Radius daemon 
	self.ether_linux.cmd("sudo /etc/init.d/radiusd stop")

        #### Ethereal cap
        self.myLog.output(" Step 1 - removing the file rad_fun_007.pcap")
        self.ether_linux.cmd("sudo rm rad_fun_007.pcap -f")

        self.myLog.output("Step 2 -Start tethereal to capture the packets and store the result in a pcap file")
        #self.ether_linux.cmd('sudo /usr/sbin/tethereal  -h')
        self.ether_linux.cmd('sudo /usr/sbin/tethereal -i %s -q  -w rad_fun_007.pcap -R "radius" & '% topo.port_ssx_radius1[1])
	
	# Initiate IKEv1 session from a client to the SSX with valid X-auth credentials.
        self.ssx.ping('%s'% script_var['ns_phy_ip'])
        time.sleep(5)
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")

        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.myLog.output (" Step 3 - stop tethereal by killing the tethereal application.")
        self.myLog.output ("  Going to sleep for 60 secs untill ssx retrys ")
	time.sleep(25)
        self.ether_linux.cmd("sudo pkill tethereal")
	time.sleep(8)
        self.myLog.output  (" Step 4 - read the content of the file rad_fun_007.pcap ")
        output=self.ether_linux.cmd('sudo /usr/sbin/tethereal -r rad_fun_007.pcap -R "radius.code == 1 && radius.id ==0 && ! icmp" ',timeout = 100)

        #checking retry timeouts and no.of retrys
	self.myLog.output(output)
	ether_op=output.split('\n')
	count = 0
	for line in ether_op:
	    if "RADIUS" in line:
		count = count+1
        self.failUnless(count in [3,4], """ Expected - packet with radius.code == 1; not found in 3 times  Actual = %d"""% count)

	time_stamps = []
	for line in ether_op:
	    x=re.search('\d+.\d{6}',line)
            if x!=None :
		time_stamps.append(x.group(0))

        # check the time diff between each packet
	diff_time_stamps = 0
	for i in range(0,len(time_stamps)-1):
	    temp = float(time_stamps[i+1])-float(time_stamps[i])
            diff_time_stamps = diff_time_stamps+temp

	avg_time_stamp = diff_time_stamps/(len(time_stamps)-1)
        # verifying the time intervels
#.........这里部分代码省略.........
开发者ID:muttu2244,项目名称:MyPython,代码行数:103,代码来源:RADIUS_FUN_007.py

示例8: test_AAA_NEG_002

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_AAA_NEG_002(test_case):

    myLog = getLogger()

    def setUp(self):
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(ssx1['ip_addr'])
	self.ssx.telnet()

        # Clear SSX configuration
	self.ssx.clear_config()
        # wait for card to come up
        self.ssx.wait4cards()

        self.ssx.clear_health_stats()
        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns['ip_addr'])
	self.ns5gt.telnet()
	self.ns5gt.clear_config()	

        #Establish a telnet session to the linux client box.
        self.linux = Linux(topo.linux["ip_addr"],topo.linux["user_name"],topo.linux["password"])
        self.linux.telnet()

    def tearDown(self):
 	"""Clear the config and Close down the telnet session."""
        self.ssx.close()
        self.ns5gt.close()

    def test_AAA_NEG_002(self):
        """
        Test case Id: -  AAA-NEG-002
        """

        #On SSX configure an AAA profile with the session authentication set to query local database.
        self.ssx.config_from_string(script_var['common_ssx1'])
        self.ssx.config_from_string(script_var['user_add_ssx'])
        self.ssx.config_from_string(script_var['neg_002_ssx'])

        # Get the configuration from a string in a config file config.py and Load it in NS-5GT.
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['neg_002_ns5gt'])

        # Enable debug logs for aaad
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")

        # Initiate Telnet Session from linux Client with valid user-1 credentials
        # where user is having admin privileges
        op_telnet = generic_verify_telnet_2_ssx(self.linux,script_var['ssx_phy_ip2'],
					"[email protected]%s"%script_var['context'],"123user3")
        self.failUnless(op_telnet is True,"telnet from client to SSX failed")

        # Checking user authentication is sucesscuful or not with valid user-1 credentials
        op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s"%script_var['context'],"local")
        self.failUnless(op_debug,"telnet from client to SSX failed")


	# Initiate IKEv1 session from a client to the SSX with valid session credentials.
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.failUnless(ping_output, " IKEv1 session from client to SSX with valid session credentials is unsucessfull ")

        op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s"%script_var['context'],"radius")
        self.failUnless(op_debug,"Session authentication from client to SSX failed")


	# Deleting the AAA profile on the SSX
	self.ssx.configcmd("context %s" %script_var["context"])
	self.ssx.configcmd("no aaa profile")

	####################### Re-initiate the sessions.#########################

        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")

	# Flush ike sessions
	self.ssx.cmd("context %s" %script_var["context"])
	self.ssx.cmd("clear session all")

        # Initiate Telnet Session from linux Client with valid user-1 credentials
        # where user is having admin privileges
        op_telnet = generic_verify_telnet_2_ssx(self.linux,script_var['ssx_phy_ip2'],
                                        "[email protected]%s"%script_var['context'],"123user4")
        self.failUnless(op_telnet is True,"telnet from client to SSX failed")

        # Checking user authentication is sucesscuful or not with valid user-1 credentials
        op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s"%script_var['context'],"local")
        self.failUnless(op_debug,"telnet from client to SSX failed")


	# Initiate IKEv1 session
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.failUnless(not ping_output,"SSX respond to the session request coming into that context ater deleting the context")

        #op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s"%script_var['context'],"radius")
        #self.failUnless(not op_debug,"Session authentication from client to SSX failed")
#.........这里部分代码省略.........
开发者ID:muttu2244,项目名称:MyPython,代码行数:103,代码来源:AAA_NEG_002.py

示例9: test_RADIUS_FUN_003

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_RADIUS_FUN_003(test_case):

    myLog = getLogger()

    def setUp(self):
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(ssx1['ip_addr'])
        self.ssx.telnet()

        # Clear SSX configuration
        self.ssx.clear_config()
        # wait for card to come up
        self.ssx.wait4cards()
        self.ssx.clear_health_stats()


        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns['ip_addr'])
        self.ns5gt.telnet()
        self.ns5gt.clear_config()

        self.ether_linux = Linux(radius1['ip_addr'],radius1['user_name'],radius1['password'])
        self.ether_linux.telnet()

    def tearDown(self):
 	"""Clear the config and Close down the telnet session."""
        self.ssx.close()
        self.ns5gt.close()
	self.ether_linux.close()

    def test_RADIUS_FUN_003(self):
        """
        Test case Id: -  RADIUS-FUN-003
        """

        self.myLog.output("\n**********start the test**************\n")

        #Push the SSX configuration        
	self.ssx.config_from_string(script_var['common_ssx'])
        self.ssx.config_from_string(script_var['rad_fun_003_ssx'])

        #Get the configuration from a string in a config file config.py and Load it in NS-5GT.
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['rad_fun_003_ns5gt'])

        # Enable debug logs for aaad
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")

        #### Ethereal cap
        self.myLog.output(" Step 1 - removing the file rad_fun_003.pcap")
        self.ether_linux.cmd("sudo rm rad_fun_003.pcap -f")

        self.myLog.output (" Step 2 -Start tethereal to capture the packets and store the result in a pcap file")
        #self.ether_linux.cmd('sudo /usr/sbin/tethereal -h')
        self.ether_linux.cmd('sudo /usr/sbin/tethereal -i %s -q  -w rad_fun_003.pcap -R "radius" & '% topo.port_ssx_radius1[1])

	
	# Initiate IKEv1 session from a client to the SSX with in-valid X-auth credentials.
        # ping ikev1 clent from ssx
        self.ssx.ping('%s'% script_var['ns_phy_ip'])
        time.sleep(5)
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        time.sleep(5)
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.myLog.output (" Step 3 - stop tethereal by killing the tethereal application.")
	time.sleep(5)
        self.ether_linux.cmd("sudo pkill tethereal")

        # Check whether the pcap file is created or not
        ll_output = self.ether_linux.cmd("ls -lrt *.pcap")
        self.failUnless( "rad_fun_003.pcap" in ll_output,"Testcase FAILED because pcap file has not created ")

        self.myLog.output  (" Step 4 - read the content of the file rad_fun_003.pcap ")
        output=self.ether_linux.cmd('sudo /usr/sbin/tethereal -r rad_fun_003.pcap -R "radius.code == 3"',timeout = 30)
        self.failUnless(output, """ Expected - packet with radius.code == 3  Actual = %s"""% output)


        # Checking SSX Health
        hs = self.ssx.get_health_stats()
        self.failUnless(is_healthy(hs), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:85,代码来源:RADIUS_FUN_003.py

示例10: test_RADIUS_FUN_027

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_RADIUS_FUN_027(test_case):

    myLog = getLogger()

    def setUp(self):
        #Establish a telnet session to the SSX box.
	self.ssx = SSX(ssx1['ip_addr'])
        self.ssx.telnet()

        # Clear the SSX config
        self.ssx.clear_config()
        # wait for card to come up
        self.ssx.wait4cards()
        self.ssx.clear_health_stats()

        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns['ip_addr'])
        self.ns5gt.telnet()
        self.ns5gt.clear_config()

        """Establish a telnet session to Linux machine ."""
        self.linux = Linux(topo.linux["ip_addr"],topo.linux["user_name"],topo.linux["password"])
        self.linux.telnet()

        self.ether_radius1 = Linux(radius1['ip_addr'],radius1['user_name'],radius1['password'])
        self.ether_radius1.telnet()


    def tearDown(self):
        """Clear the config and Close down the telnet session."""

        self.ssx.close()
        self.ns5gt.close()
        self.linux.close()
	self.ether_radius1.close()

    def test_RADIUS_FUN_027(self):

        """
        Test case Id: -  RADIUS-FUN-027
        """

	self.myLog.output("\n**********start the test**************\n")

        self.myLog.output(" Step 1 - removing the file rad_fun_027.pcap")
        self.ether_radius1.cmd("sudo rm rad_fun_027.pcap -f")

        self.myLog.output (" Step 2 -Start tethereal to capture the packets and store the result in a pcap file")
        self.ether_radius1.cmd('sudo /usr/sbin/tethereal -i %s -q  -w rad_fun_027.pcap  & '% topo.port_ssx_radius1[1])

	# Configure SSX to forward session authentication credentials to 
	# local database and acct info to radius server  .
	self.ssx.config_from_string(script_var['common_ssx1'])
	self.ssx.config_from_string(script_var['rad_fun_027_ssx'])

	# Configure the IKEv1 Phase1 & Phase2 Polices on the SSX. 
	# Ensure that the client is also configured with matching policies.
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['rad_fun_027_ns5gt'])

        # Enable debug logs for aaad
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
	# Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug") 


        # Initiate IKEv1 session from a Netscreen to the SSX (with invalid X-Auth user)
        # ping ikev1 clent from ssx
        self.ssx.ping('%s'% script_var['ns_phy_ip'])
        time.sleep(5)
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")

        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.failUnless(not ping_output, "session established even with in-valid X-Auth user")
       
        self.myLog.output (" Step 3 - stop tethereal by killing the tethereal application.")
	time.sleep(5)
        self.ether_radius1.cmd("sudo pkill tethereal")

        # Check whether the pcap file is created or not
        ll_output = self.ether_radius1.cmd("ls -lrt *.pcap")
        self.failUnless("rad_fun_027.pcap" in ll_output,"Testcase FAILED because pcap file has not created")

        self.myLog.output (" Step 4 - read the content of the file rad_fun_027.pcap")
        output=self.ether_radius1.cmd('sudo /usr/sbin/tethereal -r rad_fun_027.pcap  -R "radius.Acct_Status_Type"',timeout = 30)
        self.failUnless("RADIUS" in output, " Expected - packet with radius.Acct.Status_Type == 4 ")


        #Check out the SA status in SSX.
        self.ssx.cmd("context %s" %script_var['context'])
        sa_output= sa_check(self.ssx,script_var['ns_phy_ip'])
        self.failUnless(not sa_output,"SA loaded even with invalid X-auth user")

        # Checking SSX Health
        hs = self.ssx.get_health_stats()
        self.failUnless(is_healthy(hs), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:100,代码来源:RADIUS_FUN_027.py

示例11: test_AAA_FUN_024

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_AAA_FUN_024(test_case):

    myLog = getLogger()

    def setUp(self):
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(ssx1['ip_addr'])
        self.ssx.telnet()

        # Clear SSX configuration
        self.ssx.clear_config()
        # wait for card to come up
        self.ssx.wait4cards()
        self.ssx.clear_health_stats()

        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns['ip_addr'])
        self.ns5gt.telnet()
        self.ns5gt.clear_config()

        self.ether_radius1 = Linux(radius1['ip_addr'],radius1['user_name'],radius1['password'])
        self.ether_radius1.telnet()

    def tearDown(self):
 	"""Clear the config and Close down the telnet session."""
        self.ssx.close()
        self.ns5gt.close()
	self.ether_radius1.close()
    def test_AAA_FUN_024(self):
        """
        Test case Id: -  AAA-FUN-024
        """

        #Push the SSX configuration        
	self.ssx.config_from_string(script_var['common_ssx1'])
        self.ssx.config_from_string(script_var['fun_024_ssx'])

        #Get the configuration from a string in a config file config.py and Load it in NS-5GT.
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['fun_024_ns5gt'])

        # Enable debug logs for aaad
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")

        #### Ethereal cap
        self.myLog.output(" Step 1 - removing the file aaa_fun_024.pcap")
        self.ether_radius1.cmd("sudo rm aaa_fun_024.pcap -f")

        self.myLog.output (" Step 2 -Start tethereal to capture the packets and store the result in file ")
        #self.ether_radius1.cmd('sudo /usr/sbin/tethereal -h')
        self.ether_radius1.cmd('sudo /usr/sbin/tethereal -i %s -q  -w  aaa_fun_024.pcap -R "radius" & '% topo.port_ssx_radius1[1])
        self.ether_radius1.cmd(' sudo ls -lrt *.pcap')
	
	# Initiate IKEv1 session from a client to the SSX with invalid X-auth credentials.
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
	self.failUnless(not ping_output, "Session established even with invalid X-auth credentials")
        
	self.myLog.output (" Step 3 - stop tethereal by killing the tethereal application.")

	time.sleep(8)
        self.ether_radius1.cmd("sudo pkill tethereal")

        # Check whether the pcap file is created or not
        #ll_output = self.ether_radius1.cmd("ll")
        #self.failUnless( 'aaa_fun_024.pcap' in  ll_output,"Testcase FAILED because pcap file has not created ")

        self.myLog.output  (" Step 4 - read the content of the file aaa_fun_024.pcap ")
        output=self.ether_radius1.cmd('sudo /usr/sbin/tethereal -r aaa_fun_024.pcap -R "radius.code == 3" ',timeout = 30)
        self.failUnless(output, """ Expected - packet with radius.code == 3  Actual = %s"""% output)

        #In debug messages verify whether the X-auth authentication is succeeded or not.
	# With in-valid X-auth credentials
        op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s" %script_var['context'],"radius")
        self.failUnless(not op_debug, "X-auth passed even with invalid credentials")


        # Checking SSX Health
        hs = self.ssx.get_health_stats()
        self.failUnless(is_healthy(hs), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:84,代码来源:AAA_FUN_024.py

示例12: test_AAA_FUN_017

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_AAA_FUN_017(test_case):

    myLog = getLogger()

    def setUp(self):
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(ssx1['ip_addr'])
        self.ssx.telnet()
        # CLear SSX configuration
        self.ssx.clear_config()

        # wait for card to come up
        self.ssx.wait4cards()

        self.ssx.clear_health_stats()
        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns['ip_addr'])
        self.ns5gt.telnet()
        self.ns5gt.clear_config()

    def tearDown(self):
 	"""Clear the config and Close down the telnet session."""
        self.ssx.close()
        self.ns5gt.close()

    def test_AAA_FUN_017(self):
        """
        Test case Id: -  AAA-FUN-017
        """

        #Push the SSX configuration
        self.ssx.config_from_string(script_var['common_ssx1'])
        self.ssx.config_from_string(script_var['fun_017_ssx'])

        #Push the Netscreen configuration
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['fun_017_ns5gt'])

        # Enable debug logs for aaad
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")
	
	# Initiate IKEv1 session from a client to the SSX with in-valid X-auth credentials.
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
	
	# Verify the IKEv1 phase-1 authentication
        op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s"%script_var['context'],"local")
        self.failUnless(op_debug,"Phase-1 authentication is not successful")
        #In debug messages verify whether the X-auth authentication is succeeded or not.
	# With in-valid X-auth credentials
        op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s"%script_var['context'],"local")
	self.failUnless(not op_debug,"session established even with invalid X-auth credentials")

        #Check out the SA status in SSX.
        self.ssx.cmd("context %s" %script_var['context'])
        sa_output= sa_check(self.ssx,script_var['ns_phy_ip'])
        self.failUnless(not sa_output,"SA loaded even with invailed xauth user")

        # Checking SSX Health
        hs = self.ssx.get_health_stats()
        self.failUnless(is_healthy(hs),"Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:66,代码来源:AAA_FUN_017.py

示例13: test_AAA_HA_004

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_AAA_HA_004(test_case):

    myLog = getLogger()

    def setUp(self):
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(ssx2_ha['ip_addr'])
	self.ssx.telnet()
	self.ssx.clear_health_stats()

	# Clear SSX configuration 
	self.ssx.clear_config()

        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns1['ip_addr'])
	self.ns5gt.telnet()
        self.ssx.clear_health_stats()

        # Clear SSX configuration
	self.ns5gt.clear_config()	

    def tearDown(self):
 	"""Clear the config and Close down the telnet session."""
        self.ssx.close()
        self.ns5gt.close()

    def test_AAA_HA_004(self):

        """
        Test case Id: -  AAA-HA-004
        Description: - Verify session authentication with local database using valid credentials.
        """
        #Push the SSX configuration
        self.ssx.config_from_string(script_var['aaa_ha_004_ssx'])

        #Push the Netscreen configuration
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['aaa_ha_004_ns5gt'])

        # Enable debug logs for aaad
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")

	# Initiate IKEv1 session from a netscreen to the SSX with valid session credentials.
	# 1st ping used to get rid of any arp learnings
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
	self.failUnless(ping_output,"session authentication and establishment is not successful")

	#Verify successful Phase1 authentication and  IKEv1 session establishedment
        #op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s"%script_var['context'],"local")
        #self.failUnless(op_debug,"verifying in debug:session authentication and establishment is not successful")

        #Check out the SA status in SSX.
        self.ssx.cmd("context %s" %script_var['context'])
        sa_output= sa_check(self.ssx,script_var['ns_phy_ip'])
        self.failUnless(sa_output,"SA not loaded")

        # Checking SSX Health
        hs = self.ssx.get_health_stats()
        self.failUnless(is_healthy(hs), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:65,代码来源:AAA_HA_004.py

示例14: test_AAA_FUN_028

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_AAA_FUN_028(test_case):

    myLog = getLogger()
    def setUp(self):
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(ssx1['ip_addr'])
        self.ssx.telnet()

        # Clear SSX configuration
        self.ssx.clear_config()
        # wait for card to come up
        self.ssx.wait4cards()
        self.ssx.clear_health_stats()

        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns['ip_addr'])
        self.ns5gt.telnet()
        self.ns5gt.clear_config()

	"""Establish a telnet session to Linux machine ."""
        self.linux = Linux(topo.linux["ip_addr"],topo.linux["user_name"],topo.linux["password"]) 
	self.linux.telnet()


    def tearDown(self):
 	"""Clear the config and Close down the telnet session."""
        self.ssx.close()
        self.ns5gt.close()
	self.linux.close()        
    def test_AAA_FUN_028(self):

        """
        Test case Id: -  AAA-FUN-028
	"""
        #On SSX configure an AAA profile with the session authentication set to Radius and 
	#user authentication set to query local database.
        self.ssx.config_from_string(script_var['common_ssx1'])
        self.ssx.config_from_string(script_var['fun_028_ssx'])
        self.ssx.config_from_string(script_var['user_add_ssx'])

        #Get the configuration from a string in a config file config.py and Load it in NS-5GT.
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['fun_028_ns5gt'])

        # Enable debug logs for aaad
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")


	# Initiate IKEv1 session from a client to the SSX with valid session credentials.
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
	self.failUnless(ping_output, "session authentication and establishment is not successful")

	#Verify IKEv1 session authentication
	op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s"%script_var['context'],"radius")
	self.failUnless(op_debug, "Verifying in debugs:session authentication and establishment is not successful")

	#Check out the SA status in SSX.
        self.ssx.cmd("context %s" %script_var['context'])
        sa_output= sa_check(self.ssx,script_var['ns_phy_ip'])
        self.failUnless(sa_output,"SA not loaded")

        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")
					
	# Initiate Telnet Session from Xpress VPN Client  where user has adminstrator privileages
	op_telnet = generic_verify_telnet_2_ssx(self.linux,script_var['ssx_phy_ip2'],"[email protected]%s"%script_var['context'],"123user3")
        self.failUnless(op_telnet,"telnet to SSX as a user was not success")

        # Check whether SSX quiries the local database for user authentication 
	op_debug =  aaa_verify_authentication(self.ssx,"[email protected]%s"%script_var['context'],"local")
        self.failUnless(op_debug,"Verifying in debugs:the user authentication not success ")

        # Checking SSX Health
        hs = self.ssx.get_health_stats()
        self.failUnless(is_healthy(hs), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:81,代码来源:AAA_FUN_028.py

示例15: test_RADIUS_FUN_012

# 需要导入模块: from NS import NS [as 别名]
# 或者: from NS.NS import ping [as 别名]
class test_RADIUS_FUN_012(test_case):
    myLog = getLogger()

    def setUp(self):
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(topo.ssx1['ip_addr'])
	self.ssx.telnet()

        # CLear SSX configuration
	self.ssx.clear_config()
        # wait for card to come up
        self.ssx.wait4cards()
        self.ssx.clear_health_stats()

 
        """Establish a telnet session to the Netscreen."""
        self.ns5gt = NS(ns['ip_addr'])
        self.ns5gt.telnet()
        self.ns5gt.clear_config()

	# Establish a telnet session to the radius servers 
        self.ether_radius1 = Linux(radius1['ip_addr'],radius1['user_name'],radius1['password'])
        self.ether_radius1.telnet()

        self.ether_radius2 = Linux(radius2['ip_addr'],radius2['user_name'],radius2['password'])
        self.ether_radius2.telnet()


    def tearDown(self):

        # Start The (stopped) radius process
        self.ether_radius1.cmd("sudo /etc/init.d/radiusd start")
        self.ether_radius1.cmd("sudo pkill tethereal")
        self.ether_radius2.cmd("sudo pkill tethereal")
        # Close the telnet session of SSX
        self.ssx.close()
        # Close the telnet session of ns5gt client .
        self.ns5gt.close()
	# Close the telnet session of Radius (tethereal capture machine)
	self.ether_radius1.close()
	self.ether_radius2.close()



    def test_RADIUS_FUN_012(self):
        """
        Test case Id: -  RADIUS_FUN_012
	"""

        self.myLog.output("\n**********start the test**************\n")

        #Configure SSX to forward session authentication credentials to radius server for authentication.
	#Configure two radius servers primary & secondary in the session authentication profile.
        self.ssx.config_from_string(script_var['common_ssx'])
        self.ssx.config_from_string(script_var['rad_fun_012_ssx'])

        #Get the configuration from a string in a config file config.py and Load it in NS-5GT.
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['rad_fun_012_ns5gt'])

        # Enable debug logs for aaad
        self.ssx.cmd("context %s" % script_var['context'])
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")

	# Stop the radius process
        self.ether_radius1.cmd("sudo /etc/init.d/radiusd stop")

        #### Start Ethereal capture on both the Radius servers
        self.myLog.output(" Step 1 - removing the file rad_fun_012.pcap")
        self.ether_radius1.cmd("sudo rm rad_fun_012.pcap -f")
        self.ether_radius2.cmd("sudo rm rad_fun_012.pcap -f")
        self.myLog.output("Step 2 -Start tethereal to capture the packets and store the result in a pcap file")
        #self.ether_radius1.cmd('sudo /usr/sbin/tethereal   -h')
        #self.ether_radius2.cmd('sudo /usr/sbin/tethereal   -h')
        self.ether_radius1.cmd('sudo /usr/sbin/tethereal -i %s -q  -w rad_fun_012.pcap -R "radius" & '% topo.port_ssx_radius1[1])
        self.ether_radius2.cmd('sudo /usr/sbin/tethereal -i %s -q  -w rad_fun_012.pcap -R "radius" & '% topo.port_ssx_radius2[1])

        # Initiate IKEv1 session from a Netscreen to the SSX
        self.ssx.ping('%s'% script_var['ns_phy_ip'])
        self.ssx.ping('%s'% script_var['ns_phy_ip'])
        time.sleep(5)
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")

        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
	time.sleep(45)
        #self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.failUnless(ping_output, "session authentication with Radius is not\
                        successed even with valid session credentials")


        #### terminate tethereal & read the pcap file contents
        self.myLog.output (" Step 3 - stop tethereal by killing the tethereal application.")
        self.ether_radius1.cmd("sudo pkill tethereal")
        self.ether_radius2.cmd("sudo pkill tethereal")
#.........这里部分代码省略.........
开发者ID:muttu2244,项目名称:MyPython,代码行数:103,代码来源:RADIUS_FUN_012.py


注:本文中的NS.NS.ping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。