| 86 | | use Storable qw(dclone); |
|---|
| | 91 | can_ok('Storable', 'thaw'); |
|---|
| | 92 | use Storable qw(dclone thaw); |
|---|
| | 93 | |
|---|
| | 94 | # Make sure MIME::Base64 loads. |
|---|
| | 95 | BEGIN { use_ok('MIME::Base64', qw(encode_base64 decode_base64)) or diag("Can't load MIME::Base64 package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| | 96 | require_ok('MIME::Base64'); |
|---|
| | 97 | can_ok('MIME::Base64', 'encode_base64'); |
|---|
| | 98 | can_ok('MIME::Base64', 'decode_base64'); |
|---|
| | 99 | use MIME::Base64 qw(encode_base64 decode_base64); |
|---|
| | 123 | |
|---|
| | 124 | # Make sure Sys::Hostname loads. |
|---|
| | 125 | BEGIN { use_ok('Sys::Hostname') or diag("Can't load Sys::Hostname package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| | 126 | require_ok('Sys::Hostname'); |
|---|
| | 127 | use Sys::Hostname; |
|---|
| | 128 | |
|---|
| | 129 | # Make sure Sys::HostIP loads. |
|---|
| | 130 | BEGIN { use_ok('Sys::HostIP') or diag("Can't load Sys::HostIP package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| | 131 | require_ok('Sys::HostIP'); |
|---|
| | 132 | use Sys::HostIP; |
|---|
| | 133 | |
|---|
| | 134 | # Make sure DateTime::HiRes loads. |
|---|
| | 135 | BEGIN { use_ok('DateTime::HiRes') or diag("Can't load Sys::HostIP package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| | 136 | require_ok('DateTime::HiRes'); |
|---|
| | 137 | use DateTime::HiRes; |
|---|
| | 138 | |
|---|
| | 139 | # Make sure IO::File loads. |
|---|
| | 140 | BEGIN { use_ok('IO::File') or diag("Can't load IO::File package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| | 141 | require_ok('IO::File'); |
|---|
| | 142 | use IO::File; |
|---|
| | 143 | |
|---|
| | 144 | # Make sure Filesys::DfPortable loads |
|---|
| | 145 | BEGIN { use_ok('Filesys::DfPortable') |
|---|
| | 146 | or diag("Can't load Filesys::DfPortable package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| | 147 | require_ok('Filesys::DfPortable'); |
|---|
| | 148 | use Filesys::DfPortable; |
|---|
| 169 | | my $clone = HoneyClient::Manager::VM::Clone->new(test => 1, master_vm_config => $masterVM, _dont_init => 1); |
|---|
| 170 | | is($clone->{test}, 1, "new(test => 1, master_vm_config => '$masterVM', _dont_init => 1)") or diag("The new() call failed."); |
|---|
| 171 | | isa_ok($clone, 'HoneyClient::Manager::VM::Clone', "new(test => 1, master_vm_config => '$masterVM', _dont_init => 1)") or diag("The new() call failed."); |
|---|
| | 206 | my $clone = HoneyClient::Manager::VM::Clone->new(test => 1, master_vm_config => $masterVM, _dont_init => 1, _bypass_firewall => 1); |
|---|
| | 207 | is($clone->{test}, 1, "new(test => 1, master_vm_config => '$masterVM', _dont_init => 1, _bypass_firewall => 1)") or diag("The new() call failed."); |
|---|
| | 208 | isa_ok($clone, 'HoneyClient::Manager::VM::Clone', "new(test => 1, master_vm_config => '$masterVM', _dont_init => 1, _bypass_firewall => 1)") or diag("The new() call failed."); |
|---|
| | 318 | # =begin testing |
|---|
| | 319 | { |
|---|
| | 320 | # Shared test variables. |
|---|
| | 321 | my ($stub, $som, $URL); |
|---|
| | 322 | my $testVM = $ENV{PWD} . "/" . getVar(name => "test_vm_config", |
|---|
| | 323 | namespace => "HoneyClient::Manager::VM::Test"); |
|---|
| | 324 | |
|---|
| | 325 | # Catch all errors, in order to make sure child processes are |
|---|
| | 326 | # properly killed. |
|---|
| | 327 | eval { |
|---|
| | 328 | |
|---|
| | 329 | # Pretend as though no other Clone objects have been created prior |
|---|
| | 330 | # to this point. |
|---|
| | 331 | $HoneyClient::Manager::VM::Clone::OBJECT_COUNT = -1; |
|---|
| | 332 | |
|---|
| | 333 | my $question; |
|---|
| | 334 | $question = prompt("#\n" . |
|---|
| | 335 | "# Note: Testing real drive operations will *ONLY* work\n" . |
|---|
| | 336 | "# with a fully functional master VM that has the HoneyClient code\n" . |
|---|
| | 337 | "# loaded upon boot-up.\n" . |
|---|
| | 338 | "#\n" . |
|---|
| | 339 | "# This test also requires that the firewall VM is registered,\n" . |
|---|
| | 340 | "# powered on, and operational.\n" . |
|---|
| | 341 | "#\n" . |
|---|
| | 342 | "# Your master VM is: " . getVar(name => "master_vm_config", namespace => "HoneyClient::Manager::VM") . "\n" . |
|---|
| | 343 | "#\n" . |
|---|
| | 344 | "# Do you want to test cloning and driving this master VM?", "no"); |
|---|
| | 345 | if ($question =~ /^y.*/i) { |
|---|
| | 346 | |
|---|
| | 347 | # Create a generic empty clone, with test state data. |
|---|
| | 348 | my $clone = HoneyClient::Manager::VM::Clone->new(_bypass_firewall => 1); |
|---|
| | 349 | my $cloneConfig = $clone->{config}; |
|---|
| | 350 | |
|---|
| | 351 | $clone = $clone->drive(work => { 'http://www.google.com/' => 1 }); |
|---|
| | 352 | isa_ok($clone, 'HoneyClient::Manager::VM::Clone', "drive(work => { 'http://www.google.com/' => 1})") or diag("The drive() call failed."); |
|---|
| | 353 | $clone = undef; |
|---|
| | 354 | |
|---|
| | 355 | # Connect to daemon as a client. |
|---|
| | 356 | $stub = getClientHandle(namespace => "HoneyClient::Manager::VM"); |
|---|
| | 357 | |
|---|
| | 358 | # Destroy the clone VM. |
|---|
| | 359 | $som = $stub->destroyVM(config => $cloneConfig); |
|---|
| | 360 | } |
|---|
| | 361 | }; |
|---|
| | 362 | |
|---|
| | 363 | # Kill the child daemon, if it still exists. |
|---|
| | 364 | HoneyClient::Manager::VM->destroy(); |
|---|
| | 365 | |
|---|
| | 366 | # Report any failure found. |
|---|
| | 367 | if ($@) { |
|---|
| | 368 | fail($@); |
|---|
| | 369 | } |
|---|
| | 370 | } |
|---|
| | 371 | |
|---|
| | 372 | |
|---|
| | 373 | |
|---|