OpenSecurity/bin/test_vmmanager.pyw
changeset 212 59ebaa44c12c
child 213 2e0b94e12bfc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/OpenSecurity/bin/test_vmmanager.pyw	Thu Jul 17 10:20:10 2014 +0100
     1.3 @@ -0,0 +1,155 @@
     1.4 +#!/bin/env python
     1.5 +# -*- coding: utf-8 -*-
     1.6 +
     1.7 +# ------------------------------------------------------------
     1.8 +# opensecurityd
     1.9 +#   
    1.10 +# the opensecurityd as RESTful server
    1.11 +#
    1.12 +# Autor: Mihai Bartha, <mihai.bartha@ait.ac.at>       
    1.13 +#
    1.14 +# Copyright (C) 2013 AIT Austrian Institute of Technology
    1.15 +# AIT Austrian Institute of Technology GmbH
    1.16 +# Donau-City-Strasse 1 | 1220 Vienna | Austria
    1.17 +# http://www.ait.ac.at
    1.18 +#
    1.19 +# This program is free software; you can redistribute it and/or
    1.20 +# modify it under the terms of the GNU General Public License
    1.21 +# as published by the Free Software Foundation version 2.
    1.22 +# 
    1.23 +# This program is distributed in the hope that it will be useful,
    1.24 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.25 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.26 +# GNU General Public License for more details.
    1.27 +# 
    1.28 +# You should have received a copy of the GNU General Public License
    1.29 +# along with this program; if not, write to the Free Software
    1.30 +# Foundation, Inc., 51 Franklin Street, Fifth Floor, 
    1.31 +# Boston, MA  02110-1301, USA.
    1.32 +# ------------------------------------------------------------
    1.33 +
    1.34 +
    1.35 +# ------------------------------------------------------------
    1.36 +# imports
    1.37 +
    1.38 +import unittest
    1.39 +
    1.40 +import os
    1.41 +import os.path
    1.42 +import sys
    1.43 +import cygwin
    1.44 +import vmmanager
    1.45 +gvm_mgr = None
    1.46 +
    1.47 +class TestVMManager(unittest.TestCase):
    1.48 +    
    1.49 +    def setUp(self):
    1.50 +        pass
    1.51 +    
    1.52 +    @classmethod
    1.53 +    def setUpClass(self):
    1.54 +        global gvm_mgr
    1.55 +        gvm_mgr = vmmanager.VMManager.getInstance()
    1.56 +        pass
    1.57 +    
    1.58 +    @unittest.skip("skipping")
    1.59 +    def testGetTemplateUUID(self):
    1.60 +        template = vmmanager.VMManager.getTemplateUUID()
    1.61 +        self.assertIsNotNone(template,  "returned no UUID for template")
    1.62 +    
    1.63 +    #@unittest.skip("skipping (requires running vmmanager)")    
    1.64 +    def testUpdateTemplate(self):
    1.65 +        gvm_mgr.updateTemplate()
    1.66 +        pass
    1.67 +    
    1.68 +    #@classmethod
    1.69 +    #def tearOffClass(self):
    1.70 +    #    gvm_mgr.stop()
    1.71 +    #    gvm_mgr.cleanup()
    1.72 +        
    1.73 +
    1.74 +if __name__ == '__main__':
    1.75 +    TestVMManager.setUpClass()
    1.76 +    
    1.77 +    suite = unittest.TestLoader().loadTestsFromTestCase(TestVMManager)
    1.78 +    unittest.TextTestRunner().run(suite)
    1.79 +    
    1.80 +#    logger = setupLogger('Cygwin')
    1.81 +#    c = Cygwin()
    1.82 +#    unittest.main()
    1.83 +    #man = VMManager.getInstance()
    1.84 +    #man.listVM()
    1.85 +    #print man.getConnectedRSDs()
    1.86 +    #print man.getNetworkDrives()
    1.87 +    #man.genNetworkDrive()
    1.88 +    #drive_bitmask = ctypes.cdll.kernel32.GetLogicalDrives()
    1.89 +    #print list(itertools.compress(string.ascii_uppercase,  map(lambda x:ord(x) - ord('0'), bin(drive_bitmask)[:1:-1])))
    1.90 +    #print list(map(chr, range(68, 91))) 
    1.91 +    #print Cygwin.getRegEntry('SYSTEM\CurrentControlSet\Enum\USB', 'VID_1058&PID_0704')[0]
    1.92 +    #devices = VMManager.getConnectedRSDS()
    1.93 +    #print devices
    1.94 +    
    1.95 +    #drives = VMManager.getLogicalDrives()
    1.96 +    #print drives
    1.97 +    #print VMManager.getDriveType("E")
    1.98 +    #print VMManager.getVolumeInfo("E")
    1.99 +    #print VMManager.getNetworkPath("E")
   1.100 +    
   1.101 +    #vmm.backupFile()
   1.102 +    #for device in devices.values():
   1.103 +    #    #print device
   1.104 +    #    if VMManager.isMassStorageDevice(device):
   1.105 +    #        print device
   1.106 +        
   1.107 +    
   1.108 +    
   1.109 +    #time.sleep(-1)
   1.110 +    #man.listVM()
   1.111 +    #man.listVM()
   1.112 +    #man.listVM()
   1.113 +    #man.listVM()
   1.114 +    #man.genCertificateISO('SecurityDVM0')
   1.115 +    #man.guestExecute('SecurityDVM0', '/bin/ls -la')
   1.116 +    #logger = setupLogger('VMManager')
   1.117 +    #c = Cygwin()
   1.118 +    
   1.119 +    #man.sshExecute('/bin/ls -la', 'SecurityDVM0')
   1.120 +    #man.sshExecuteX11('/usr/bin/iceweasel', 'SecurityDVM0')
   1.121 +    #man.removeVM('SecurityDVM0')
   1.122 +    #man.netUse('192.168.56.134', 'USB\\')
   1.123 +    #ip = '192.168.56.139'
   1.124 +    
   1.125 +    #man.cygwin_path = 'c:\\cygwin64\\bin\\'
   1.126 +    #man.handleDeviceChange()
   1.127 +    #print man.listSDVM()
   1.128 +    #man.configureHostNetworking()
   1.129 +    #new_vm = man.generateSDVMName()
   1.130 +    #man.createVM(new_vm)
   1.131 +    
   1.132 +    #print Cygwin.cmd()
   1.133 +    #man.isAvailable('c:')
   1.134 +    #ip = man.getHostOnlyIP('SecurityDVM0')
   1.135 +    #man.mapNetworkDrive('h:', '\\\\' + ip + '\Download', None, None)
   1.136 +    
   1.137 +    #man.genCertificateISO(new_vm)
   1.138 +    #man.attachCertificateISO(new_vm)
   1.139 +    
   1.140 +    #man.attachCertificateISO(vm_name)
   1.141 +    #man.guestExecute(vm_name, "ls")
   1.142 +    #man.sshGuestX11Execute('SecurityDVM1', '/usr/bin/iceweasel')
   1.143 +    #time.sleep(60)
   1.144 +    #print man.cygwinPath("C:\Users\BarthaM\VirtualBox VMs\SecurityDVM\.ssh\*")
   1.145 +    #man.genCertificateISO('SecurityDVM')
   1.146 +    #man.attachCertificateISO('SecurityDVM')
   1.147 +    #man.isStorageAttached('SecurityDVM')
   1.148 +    #man.guestExecute('SecurityDVM', 'sudo apt-get -y update')
   1.149 +    #man.guestExecute('SecurityDVM', 'sudo apt-get -y upgrade' )
   1.150 +    
   1.151 +    #man.stopVM('SecurityDVM')
   1.152 +    #man.storageDetach('SecurityDVM')
   1.153 +    #man.changeStorageType('C:\Users\BarthaM\VirtualBox VMs\SecurityDVM\SecurityDVM.vmdk','immutable')
   1.154 +    #man.storageAttach('SecurityDVM')
   1.155 +    
   1.156 +    
   1.157 +    #cmd = "c:\\cygwin64\\bin\\bash.exe --login -c \"/bin/ls\""
   1.158 +    #man.execute(cmd)
   1.159 \ No newline at end of file