68 Commits
Author SHA1 Message Date
Tudor Marcu 29b9d1e3a9 Retry pack downloads on bundle-add
The download_subscribed_packs() could fail for network issues or other related
problems, and because the only option for getting new packs is by downloading
zero packs or fullfiles, swupd should retry to get the packs before falling
into the verify_fix_path flow which signifies pack downloads errored out.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2017-04-28 14:38:53 -07:00
Tudor Marcu dac74856da Update tests for new messages being printed
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2017-04-19 10:12:51 -07:00
Jaime A. Garcia 6a8d36763b Accept multiple bundles at bundle-remove
This is a wrapper around remove_bundle()
to add consistency for bundle-remove
subcommand respect bundle-add that accepts
one or more bundles to be removed.

This must not be the optimal implementation
but it works fine and gives a better user
usage experience.
2017-04-04 11:50:21 -07:00
Icarus Sparry 3ec26daff7 Improved return code for bundleadd + test
Arrange for "bad names" to give non-zero exit code
Arrange for "do nothing" in particular when packages are already
installed to give a zero return code.

This means that typos in names result in failures, but that trying to
add an existing package is fine.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-04-04 11:46:19 -07:00
Tudor Marcu fd6b54d964 Try to recover from invalid certificate date
The system clock may be terribly off, especially on new hardware that has not
yet been calibrated. Updates rely on the certificate and system time being
sane to verify validity, so if a mismatch is found the certificate will
be deemed invalid and the update stopped. This patch attempts to fix the
system time to something sane using the time from the swupd binary itself,
which should not have been touched by any user except root. If the time is
normal and verification fails, the cert cannot be trusted.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2017-03-25 00:00:41 -07:00
Icarus Sparry 9c4c2cec08 Improved error reporting for adding bad bundle
Currently if you try and add a non existent bundle, e.g. "foo" you get
two lines of output

  foo bundle name is invalid, skipping it...
  bundle(s) already installed, exiting now

This is caused by the add_subscriptions function calling itself
recursivly but failing to pass up results in a meaningful way. This
change makes the return value of add_subscriptions be a bitmask so it
can signal errors and packages added distinctly.

I did think about changing this function to return a struct but
decided this was a step too far.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-03-24 15:27:55 -07:00
Tudor Marcu bfb26b5c40 Change certpath to be full path of certificate
The mixer and image creator treat the certpath as the full path of the
certificate filename, and swupd should too. If someone is overriding the
certificate with the cert path option, use the supplied string and don't
append a pre-defined name to it.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2017-02-27 11:40:11 -08:00
Ikey Doherty 6324401974 scripts: Port to the modern clr-boot-manager usage model
In the current system we depend on the legacy boot infrastructure, which
has been provided by clr-boot-manager in the way of compatibility scripts.
These scripts all do the same thing, which is to invoke clr-boot-manager
with the "update" subcommand.

Given that clr-boot-manager doesn't need to know the context of the
operation, i.e. it is able to deduce whether kernel or bootloaders need
updating, regardless, it makes little sense to use any of these scripts,
and we should begin to deprecate them.

In clr-boot-manager 2.0, we will look to remove these compat scripts
completely, however they will continue to exist until then to facilitate
necessary format bumps, etc.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-02-01 17:39:23 -08:00
Mario Alfredo Carrillo Arevalo 504000ec3a Fix swupd options for bundle-list --all unit test
The swupd unit tests need a group of
options for execution environment.

Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
2017-02-01 11:03:43 -08:00
Patrick McCarty bce9fb436f test: remove unused .signed files
These files have never been used by the functional tests, so remove them
from the tree.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-31 12:39:09 -08:00
Patrick McCarty 54d494b0fb test: update swupdlib to not consume .signed files
These files are not used by swupd-client, so do not add them to the MoM
tarball.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-31 12:39:09 -08:00
Mario Alfredo Carrillo Arevalo b49fb6419b Update swupd unit test
"bundle-add" sub-command used to validate "list" option in a unit test,
now that option is part of "bundle-list" sub-command with a new
name: [-a, all], for this reason the test has been updated in order to
validate it using "bundle-list" sub-command.

Furthermore this test has been moved to new directory called
"bundlelist/all" this in order to keep source code integrity.

Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
2017-01-31 12:38:29 -08:00
Tudor Marcu a1c0d9995a Update swupd signature verification certificate
The current certificate used to verify the Manifest.MoM signature is also used
to verify various build artifacts, and thus should be split up into multiple,
single function certs. This introduces a new certificate that will be used
exclusively to verify signatures for updates, while the old one will be used
to verify build artifacts like the image.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2017-01-26 01:19:11 -08:00
Tudor Marcu a4fb9ae027 Add missing certificate attributes conf
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-12-21 12:18:08 -08:00
Tudor Marcu cd48c3f6be Add prereq file to make tests work in parallel
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-12-21 12:14:27 -08:00
Tudor Marcu a565cd0304 Update tests for mandatory signature verification
With mandatory signature verification being enabled, the tests will have
to generate a certificate and sign their Manifest.MoMs to properly run the
swupd operations.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-12-20 16:13:55 -08:00
Patrick McCarty 8a80b3422a test: update ignore list for Ubuntu support
Ubuntu's /bin/sh is Dash, which has different error strings than Bash
for equivalent errors.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-22 15:22:24 -08:00
Icarus Sparry 5d637de5be swupd-client check-update return 1 if none available
make the return code for swupd-client be 1 if there is no update
available. This follows in the tradition of grep, which returns 0 if
there are matches, 1 if there are not, and 2 for errors.

Do the same for swupd-client update --status

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2016-11-15 16:59:06 -08:00
Tudor Marcu 5f5c7dcaf2 Remove more unneeded printfs
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-11-04 16:24:50 -07:00
Tudor Marcu 26658ca8e0 Update tests for new ouput
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-11-04 16:24:50 -07:00
Patrick McCarty 2143fbf513 Only grep the output for search tests
It's not clear to me why the 'swupd search' output for the functional
tests is so much different than running it outside that environment, but
regardless, the most interesting output line is what is grepped for.

This output disparity needs further debugging.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-03 09:32:36 -07:00
Patrick McCarty 2b6db84fe3 Check bundle-remove exit status instead of checking output
The bundle-remove subcommand returns a unique error code for invalid
usage, so check that instead. This also avoids the need to track
bundle-remove --help output, or ignore it.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-03 09:32:36 -07:00
Patrick McCarty a55870ed51 Fix several tests with unchecked output lines
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-03 09:32:36 -07:00
Patrick McCarty c2d2e244a9 Support an output line ignore list for tests
There are several output lines that are not very interesting to check
for functional tests, so ignore those lines completely for testing by
adding some specific regular expressions for matching.

This also enables detection of unexpected error messages that may arise
when running the tests.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-03 09:32:30 -07:00
Patrick McCarty 1c23a7bea3 Remove obsolete helper function for tests
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-02 21:04:17 -07:00
Patrick McCarty 0ca1975ed5 Convert all functional tests to the new interface
This commit adds "lines-checked" files for every test that checks
swupd-client output and removes the old bash-array-style checks from
the test scripts.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-02 21:02:46 -07:00
Patrick McCarty 10dcbb5fa9 Add new interface for functional test framework
This commit adds a new helper function for functional tests that enables
a more streamlined mechanism for declaring a fixed set of output lines
to check for and to compare against the swupd-client output.

To use this new interface, lines of output to be checked for a given
test will live in the "lines-checked" file within the test directory,
with the swupd-client output dumped to "lines-output".  Each line of
"lines-checked" is either interpreted as a literal string, or as a
regular expression; regular expression lines are denoted with the
"REGEXP:" prefix, and all other lines are literal strings.

Note that swupd-client may emit more output lines than those checked for
in "lines-checked", and that the checked lines should be declared in
order.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-02 21:01:15 -07:00
Patrick McCarty 9affcd210e Updates for functional tests
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-02 11:41:00 -07:00
Patrick McCarty 2b3af5af08 Update hashdump functional tests
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-09-30 15:18:12 -07:00
William Douglas 285c18c54e Add missing update include test
This is a functional test for the fix implemented in #122.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-09-30 15:05:44 -07:00
Patrick McCarty 5cdad496c0 Fix functional tests for breaking changes
To two latest commits introduce breaking changes to the updater, so the
static server content needs to be refreshed.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-08-15 15:22:34 -07:00
Patrick McCarty 3e0fff6a47 Ignore signature verification errors in functional tests
Because signature verification is a feature that we need separate
testing for, and swupd's output may print a verification error (or not)
depending on how swupd was built, add a helper function to remove the
verification error message when swupd is built with verification
enabled. If verification is not enabled, swupd will not print any
message, and the function is a no-op.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-06-27 11:56:01 -07:00
Patrick McCarty eecd292ae4 Check more output in the 'directory-tree-deleted' test
To make the change in my next commit more uniform, make sure this test
checks for the presence of some of the initial lines printed by swupd.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-06-27 11:54:13 -07:00
Patrick McCarty a384265d88 Refactor test cases; update bundle manifest hashes
This commit expands the swupd BATS library to encapsulate more of the
boilerplate steps in the test cases.

Additionally, bundle manifest hashes needed updating now that swupd is
emitting warnings (and later on, errors). Better to be prepared for the
switch to errors on mismatches.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-06-22 16:12:38 -07:00
William Douglas 4b522b352a Skip verified unchanged files in update
Instead of just checking if the versions have changed for a file to be
updated, compare the current file's hash to updated file's expected hash
and only queue files for update that are changed.
2016-06-07 16:06:42 -07:00
Patrick McCarty a5632aba0d Fix tests for compatibility with latest GNU tar
The recent GNU tar release (1.29) is more strict with option parsing in
that positional options must come before the file list to add to the
archive.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-06-07 15:54:32 -07:00
William Douglas 080d805727 Allow bundle-add to fallback to full files
Instead of requiring a pack is used for bundle-add, allow the use of
verify_fix_path when staging fails to: download, verify and stage the
item using the full file.

Correct output of tests where the 'required' wording was removed.
2016-05-31 11:24:07 -07:00
Patrick McCarty b202b87187 Expand test from previous commit to check the error message
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-05-20 12:35:03 -07:00
William Douglas 9f4feee501 Fail instead of staging bad file hashes in update
Check file hashes after successful tar extraction and fail if there is a
hash mismatch during udpate. As part of this change failure handling for
errors in the tar extraction path with a check space warning as a best
guess of error cause.

This change also fixes tests where the hashes were not correct and adds
a test to verify hash matching is verified.
2016-05-17 21:04:17 +00:00
William Douglas e0b859448a Sleep a little longer for python web server test 2016-05-17 20:06:57 +00:00
William Douglas 6fc6d6113d Enforce includes hierarchy with bundle-remove
Don't allow bundle-remove to remove bundles that are included by other
currently installed bundles.
2016-05-13 10:39:22 -07:00
William Douglas d593490621 Confirm verify_fix_path works with bundle-add
Validate that verify_fix_path will correctly handle missing directories
when running bundle-add.
2016-05-10 10:31:00 -07:00
William Douglas 33ecb6357f Rework file consolidation functionality
Add new function consolidate_files that replaces
consolidate_submanifests in order to remove the requirement of modifying
manifest components in place. This change enables creating seperate
consolidated file lists for bundle-add, one for new files to be
installed on the system and one for the currently installed bundles
files. Once these have been seperated out, only files requiring
installation can be processed by do_staging and the list of files
installed on the system can be used to run verify_fix_path.

This also modifies bundle-add to stop trying to create tracking
files which was impacting testing.
2016-05-10 10:31:00 -07:00
William Douglas 442185b20a Correct return check of get_latest_version
Update verify to correctly check the return value of get_latest_version
for errors. Since get_latest_version could return a variety of negative
error codes to signify errors compare against that range instead of -1
to determine success of the operation.
2016-05-10 10:31:00 -07:00
William Douglas 55540d4896 Ensure bundle-remove gets one bundle argument
Instead of only checking if bundle-remove has at least one bundle
argument and ignoring additional ones, check that there is exactly one
argument passed to bundle-remove instead.
2016-05-02 21:50:16 +00:00
William Douglas d4a96fedf6 Fix version to memory download
In the case where the swupd_download_version_to_memory callback was run
multiple times, it would overwrite previous data instead of appending.

Correct this behavior by keeping track of data written so far in the
struct passed to the callback.
2016-04-28 17:22:59 +00:00
Patrick McCarty 47963d7f97 Add functional test for verify --fix directory tree removal
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-27 10:05:59 -07:00
William Douglas a52eeb42cb Move functional tests to use the BATS framework 2016-04-26 22:15:04 +00:00
Patrick McCarty 311050ddd1 Add a functional test for the expected delete/delete consolidation
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-12 15:19:15 -07:00
William Douglas 1b9032a448 Add support for verify --install -m latest
Instead of specifying a version number argument to -m allow passing the
latest string which will query for the latest version and use that as
the install target version.
2016-04-12 21:33:19 +00:00