changed settings restore functionality for the browser.
Needs addition of rsync on VM and setup
2 # -*- coding: utf-8 -*-
4 # ------------------------------------------------------------
7 # test the open security vmmanager
9 # Autor: Mihai Bartha, <mihai.bartha@ait.ac.at>
11 # Copyright 2013-2014 X-Net and AIT Austrian Institute of Technology
18 # https://www.x-net.at
20 # AIT Austrian Institute of Technology
21 # Donau City Strasse 1
24 # http://www.ait.ac.at
27 # Licensed under the Apache License, Version 2.0 (the "License");
28 # you may not use this file except in compliance with the License.
29 # You may obtain a copy of the License at
31 # http://www.apache.org/licenses/LICENSE-2.0
33 # Unless required by applicable law or agreed to in writing, software
34 # distributed under the License is distributed on an "AS IS" BASIS,
35 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36 # See the License for the specific language governing permissions and
37 # limitations under the License.
38 # ------------------------------------------------------------
41 # ------------------------------------------------------------
56 class TestVMManager(unittest.TestCase):
64 gvm_mgr = vmmanager.VMManager.getInstance()
68 #def tearOffClass(self):
72 @unittest.skip("skipping")
73 def testGetTemplateUUID(self):
74 template = vmmanager.VMManager.getVDiskUUID(gvm_mgr.templateImage)
75 self.assertIsNotNone(template, "returned no UUID for template")
77 @unittest.skip("skipping")
78 def testUpdateTemplate(self):
79 gvm_mgr.updateTemplate()
82 def setKey(self, key, name, value):
83 _, reg_type = _winreg.QueryValueEx(key, name)
84 _winreg.SetValueEx(key, name, 0, reg_type, value)
86 @unittest.skip("skipping")
87 def testGetProxySettings(self):
88 #sudo echo "http_proxy=http://80.122.169.38:8080/" >> /etc/environment
89 aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_CURRENT_USER)
90 aKey = _winreg.OpenKey(aReg, r"Software\Microsoft\Windows\CurrentVersion\Internet Settings")
91 subCount, valueCount, lastModified = _winreg.QueryInfoKey(aKey)
93 for i in range(valueCount):
95 n,v,t = _winreg.EnumValue(aKey,i)
97 except EnvironmentError:
99 _winreg.CloseKey(aKey)
101 if 'ProxyEnable' in proxy.keys() and proxy['ProxyEnable'] == 1:
102 print proxy['ProxyServer']
103 return proxy['ProxyServer']
107 @unittest.skip("skipping")
108 def testMatchProxy(self):
109 #http=212.17.86.109:8080;https=212.17.86.109:8080;ftp=212.17.86.109:8080
111 text = 'http=212.17.86.109:8080;https=212.17.86.109:8080;ftp=212.17.86.109:8080'
112 print re.search(r"(?<=http=)(?P<HttpProxy>.*?)(?=;)", text).groupdict()
113 print re.search(r"(?<=http=)(.*?)(?=;)", text)
117 @unittest.skip("skipping")
118 def testImportTemplate(self):
120 if 'SecurityDVM' in gvm_mgr.listVMS():
121 gvm_mgr.removeVM('SecurityDVM')
123 uuid = gvm_mgr.getVDiskUUID(gvm_mgr.templateImage)
125 gvm_mgr.removeImage(uuid)
127 gvm_mgr.removeVMFolder('SecurityDVM')
128 gvm_mgr.importTemplate('C:\Windows\System32\config\systemprofile\VirtualBox VMs\OsecVM.ova')
129 gvm_mgr.updateTemplate()
131 @unittest.skip("skipping")
132 def testHostOnlyDHCP(self):
134 #Cygwin.vboxExecute("list hostonlyifs")
136 hostonlyifs = gvm_mgr.getHostOnlyIFs()
139 dhcpservers = gvm_mgr.getDHCPServers()
142 @unittest.skip("skipping")
143 def testBrowsingRequest(self):
145 gvm_mgr.handleBrowsingRequest()
152 gvm_mgr.syncRemoteFile("SecurityDVM0", gvm_mgr.getHostOnlyIP("SecurityDVM0"), gvm_mgr.getAppDataDir() + '/OpenSecurity/chromium', '/home/osecuser/.config/')
156 if __name__ == '__main__':
157 TestVMManager.setUpClass()
159 suite = unittest.TestLoader().loadTestsFromTestCase(TestVMManager)
160 unittest.TextTestRunner().run(suite)
162 #VBoxManage list hostonlyifs
163 #VBoxManage list dhcpservers
164 #VBoxManage dhcpserver remove --netname "HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter"
165 #VBoxManage dhcpserver add --ifname "VirtualBox Host-Only Ethernet Adapter" --ip 192.168.56.100 --netmask 255.255.255.0 --lowerip 192.168.56.101 --upperip 192.168.56.254 --enable
166 #VBoxManage dhcpserver modify --ifname "VirtualBox Host-Only Ethernet Adapter" --enable
167 #VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter" --dhcp
168 #VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter" --ip 192.168.56.1 --netmask 255.255.255.0
169 # logger = setupLogger('Cygwin')
172 #man = VMManager.getInstance()
174 #print man.getConnectedRSDs()
175 #print man.getNetworkDrives()
176 #man.genNetworkDrive()
177 #drive_bitmask = ctypes.cdll.kernel32.GetLogicalDrives()
178 #print list(itertools.compress(string.ascii_uppercase, map(lambda x:ord(x) - ord('0'), bin(drive_bitmask)[:1:-1])))
179 #print list(map(chr, range(68, 91)))
180 #print Cygwin.getRegEntry('SYSTEM\CurrentControlSet\Enum\USB', 'VID_1058&PID_0704')[0]
181 #devices = VMManager.getConnectedRSDS()
184 #drives = VMManager.getLogicalDrives()
186 #print VMManager.getDriveType("E")
187 #print VMManager.getVolumeInfo("E")
188 #print VMManager.getNetworkPath("E")
191 #for device in devices.values():
193 # if VMManager.isMassStorageDevice(device):
203 #man.genCertificateISO('SecurityDVM0')
204 #man.guestExecute('SecurityDVM0', '/bin/ls -la')
205 #logger = setupLogger('VMManager')
208 #man.sshExecute('/bin/ls -la', 'SecurityDVM0')
209 #man.sshExecuteX11('/usr/bin/iceweasel', 'SecurityDVM0')
210 #man.removeVM('SecurityDVM0')
211 #man.netUse('192.168.56.134', 'USB\\')
212 #ip = '192.168.56.139'
214 #man.cygwin_path = 'c:\\cygwin64\\bin\\'
215 #man.handleDeviceChange()
216 #print man.listSDVM()
217 #man.configureHostNetworking()
218 #new_vm = man.generateSDVMName()
219 #man.createVM(new_vm)
222 #man.isAvailable('c:')
223 #ip = man.getHostOnlyIP('SecurityDVM0')
224 #man.mapNetworkDrive('h:', '\\\\' + ip + '\Download', None, None)
226 #man.genCertificateISO(new_vm)
227 #man.attachCertificateISO(new_vm)
229 #man.attachCertificateISO(vm_name)
230 #man.guestExecute(vm_name, "ls")
231 #man.sshGuestX11Execute('SecurityDVM1', '/usr/bin/iceweasel')
233 #print man.cygwinPath("C:\Users\BarthaM\VirtualBox VMs\SecurityDVM\.ssh\*")
234 #man.genCertificateISO('SecurityDVM')
235 #man.attachCertificateISO('SecurityDVM')
236 #man.isStorageAttached('SecurityDVM')
237 #man.guestExecute('SecurityDVM', 'sudo apt-get -y update')
238 #man.guestExecute('SecurityDVM', 'sudo apt-get -y upgrade' )
240 #man.stopVM('SecurityDVM')
241 #man.detachStorage('SecurityDVM')
242 #man.changeStorageType('C:\Users\BarthaM\VirtualBox VMs\SecurityDVM\SecurityDVM.vmdk','immutable')
243 #man.storageAttach('SecurityDVM')
246 #cmd = "c:\\cygwin64\\bin\\bash.exe --login -c \"/bin/ls\""