Feature: Download Public VM images In order to download public VM images to the target As a command line user I want to retrieve the URI via an optional cache and copy correctly to target in the right format Background: Given an empty directory named "/tmp/uricp" And the default aruba timeout is 15 seconds Scenario: HTTP URI qcow2 to qcow2 When I successfully run `uricp http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.qcow2 file:///tmp/uricp/srv-testy` Then a file named "/tmp/uricp/srv-testy" should exist And the file named "/tmp/uricp/srv-testy" should have a file format of "qcow2" Scenario: HTTP URI qcow2 via cache Given a correctly initialised cache at "/tmp/uricp" When I successfully run `uricp --cache=/tmp/uricp http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.qcow2 file:///tmp/uricp/srv-testy` Then a file named "/tmp/uricp/srv-testy" should exist And the file named "/tmp/uricp/srv-testy" should have a file format of "qcow2" And a file named "/tmp/uricp/cache/freedos.qcow2" should exist And the file named "/tmp/uricp/cache/freedos.qcow2" should have a file format of "qcow2" Scenario: HTTP URI qcow2 via cache - size limited Given a correctly initialised cache at "/tmp/uricp" When I successfully run `uricp --cache=/tmp/uricp --max-cache=8MB http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.qcow2 file:///tmp/uricp/srv-testy` Then a file named "/tmp/uricp/srv-testy" should exist And the file named "/tmp/uricp/srv-testy" should have a file format of "qcow2" And a file named "/tmp/uricp/cache/freedos.qcow2" should not exist Scenario: HTTP URI qcow2 to qcow2 via cache Given a correctly initialised cache at "/tmp/uricp" When I successfully run `uricp --target-format=qcow2 --cache=/tmp/uricp http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.qcow2 file:///tmp/uricp/srv-testy` Then a file named "/tmp/uricp/srv-testy" should exist And the file named "/tmp/uricp/srv-testy" should have a file format of "qcow2" And a file named "/tmp/uricp/cache/freedos.qcow2" should exist And the file named "/tmp/uricp/cache/freedos.qcow2" should have a file format of "qcow2" Scenario: HTTP URI qcow2 to qcow2 via cache - size limited Given a correctly initialised cache at "/tmp/uricp" When I successfully run `uricp --target-format=qcow2 --cache=/tmp/uricp --max-cache=8Mb http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.qcow2 file:///tmp/uricp/srv-testy` Then a file named "/tmp/uricp/srv-testy" should exist And the file named "/tmp/uricp/srv-testy" should have a file format of "qcow2" And a file named "/tmp/uricp/cache/freedos.qcow2" should not exist @new-qemu-image Scenario: HTTP URI qcow2 to qcow2v3 via cache Given a correctly initialised cache at "/tmp/uricp" When I successfully run `uricp --target-format=qcow2v3 --cache=/tmp/uricp http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.qcow2 file:///tmp/uricp/srv-testy` Then a file named "/tmp/uricp/srv-testy" should exist And the file named "/tmp/uricp/srv-testy" should have a file format of "qcow2v3" And a file named "/tmp/uricp/cache/freedos.qcow2" should exist And the file named "/tmp/uricp/cache/freedos.qcow2" should have a file format of "qcow2" Scenario: HTTP URI qcow2 to raw via cache Given a correctly initialised cache at "/tmp/uricp" When I successfully run `uricp --target-format=raw --cache=/tmp/uricp http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.qcow2 file:///tmp/uricp/srv-testy` Then a file named "/tmp/uricp/srv-testy" should exist And the file named "/tmp/uricp/srv-testy" should have a file format of "raw" And a file named "/tmp/uricp/cache/freedos.qcow2" should exist And the file named "/tmp/uricp/cache/freedos.qcow2" should have a file format of "qcow2" Scenario: HTTP URI qcow2 to raw via cache - size limited Given a correctly initialised cache at "/tmp/uricp" When I successfully run `uricp --target-format=raw --cache=/tmp/uricp --max-cache=8Mb http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.qcow2 file:///tmp/uricp/srv-testy` Then a file named "/tmp/uricp/srv-testy" should exist And the file named "/tmp/uricp/srv-testy" should have a file format of "raw" And a file named "/tmp/uricp/cache/freedos.qcow2" should not exist Scenario: HTTP URI from cache Given a correctly initialised cache at "/tmp/uricp" And a 102400 byte file named "/tmp/uricp/cache/freedos.qcow2" When I successfully run `uricp --cache=/tmp/uricp http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.qcow2 file:///tmp/uricp/srv-testy` Then a 102400 byte file named "/tmp/uricp/srv-testy" should exist And a 102400 byte file named "/tmp/uricp/cache/freedos.qcow2" should exist Scenario: HTTP URI raw.xz to raw via cache Given a correctly initialised cache at "/tmp/uricp" When I successfully run `uricp --target-format=raw --cache=/tmp/uricp http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.raw.xz file:///tmp/uricp/srv-testy` Then a file named "/tmp/uricp/srv-testy" should exist And the file named "/tmp/uricp/srv-testy" should have a file format of "raw" And a file named "/tmp/uricp/cache/freedos.raw.xz" should exist And the file named "/tmp/uricp/cache/freedos.raw.xz" should have a file format of "xz" Scenario: Unsupported source URI should error Given a correctly initialised cache at "/tmp/uricp" When I run `uricp --target-format=raw --cache=/tmp/uricp wibble://some/url file:///tmp/uricp/srv-testy` Then the exit status should not be 0 And the stderr should contain "Unsupported transfer" Scenario: Unsupported target URI should error Given a correctly initialised cache at "/tmp/uricp" When I run `uricp --target-format=raw --cache=/tmp/uricp http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.qcow2 http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.qcow2` Then the exit status should not be 0 And the stderr should contain "Unsupported transfer" Scenario: Download from authorised http without authorisation When I run `uricp https://orbit.brightbox.com/v1/acc-tqs4c/images/img-c5q5i file:///tmp/uricp/srv-testy` Then the exit status should not be 0 And the stderr should contain "failed"