44 Commits
Author SHA1 Message Date
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
Tim Pepper 97f46edd52 Implement signature verification
This patch adds functionality for the swupd client to do signature
verification on the MoM, which ensures a root of trust for the rest
of the update by guaranteeing the authenticity of the MoM and content
it includes.

As we focus now on just verifying the signed MoM, a number of functions now
become static to src/signature.c.

By default MoM signature verification is disabled.  Configure
--enable-signature-verification to enable it.  When enabled the default
cert for verification is /usr/share/clear/update-ca/ClearLinuxRoot.pem, as
specified by concatenation of SWUPDCERT onto UPDATE_CA_CERTS_PATH.  The
SWUPDCERT can be overridden via configure --with-swupdcert=some.pem.

When signature verification is enabled, and the MoM's signature does _NOT_
verify, currently only a warning is presented but the swupd operation
continues.  In the future signature verification will become mandatory.
We first need to sort out a few details with mixer to insure the right
thing happens there.

Signed-off-by: Tim Pepper <timothy.c.pepper@linux.intel.com>
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-06-24 15:12:28 -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
Patrick McCarty b6d4758da7 Rename hash_compare to hash_equal
Because hash_compare returns a boolean, hash_equal is a better name to
use.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-05-10 10:50:57 -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
William Douglas 3d0c071e1a Reduce noise for updates and bundle-adds
Stop printing a message when bundles are included and going to be
installed or if bundles are already included and going to be skipped
when doing the add_subscriptions call.

Instead update the install_bundles call to notify users when an
installed bundle was attempted to be be installed again.
2016-04-12 11:03:47 -07:00
Patrick McCarty 846648382d Fix crash when running hashdump
In a previous commit, the init_globals() call was removed from the
hashdump code, which resulted in path_prefix not being set in case the
--basepath option was not specified, and led to a NULL pointer
dereference.

Fix the issue by calling the new set_path_prefix() function. The NULL
value will honor the --basepath option if specified, or set the default
path_prefix.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-08 11:38:05 -07:00
Patrick McCarty 8dc4cb8e18 Fix a bundle-remove test that failed to load manifests
The Manifest.os-core was present, but the compressed version was not.
Fix the issue by providing the compressed version.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 22:33:41 -07:00
Patrick McCarty 23dd3cc2dd Fix fullfile delta application with path_prefix set
Fullfile deltas were only being applied to the root filesystem, since
the prefix was a compile-time constant string (STAGING_SUBVOL) set to
"/" by default.

Instead, use path_prefix for the prefix so that the deltas can be
applied when specifying --path on the command line. This also enables
writing a functional test for the delta application, added in this
commit.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 21:50:31 -07:00
Patrick McCarty 0f5893746b Add functional test for empty directory deletion
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 18:34:58 -07:00
William Douglas a4fe27abad Add includes support in verify
Make verify include aware by adding includes from the official manifest
to the subs list before consolidating the manifests.
2016-04-04 21:24:45 +00:00
William Douglas 7e636c07d1 Fix update when include manifests are not new
Previously include manifests that were not newer than the current
version would be silently ignored even if they had not been previously
installed causing bundles to miss included dependencies.

Fix this by adding a is_tracked field to struct file that is nonzero
when the bundle the file is contained in is marked as tracked via having
a /usr/share/clear/bundles/$name file.

The is_tracked == 0 version of the file will be dropped in the
consolidate_manifest phase if that filename from another bundle has
is_tracked != 0 to avoid downloading and installing an already existing
file.

The is_tracked == 0 version of the file will then be added to the update
list from the consolidated manifest if that file was not previously
installed on the system (in addition to the other cases it would already
have been added to the list for).
2016-04-04 21:24:43 +00:00
Patrick McCarty 5407e70e44 Use formatstaging for functional tests
Since a numeric format now requires a config file, and aligning the
client format with the test format is a maintenance problem, use the
"staging" format for all tests.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 11:42:25 -07:00
William Douglas 7544162243 Add include support for update
Add support in update to properly support bundles that include other
bundles inside them. This feature is intended to work with bundle
additions by adding included bundles (from bundles already subscribed)
to the subscription list prior to downloading packs and full files.

As part of this change the add_subscriptions function from bundle.c was
modified to handle retrying manifest downloads.
2016-03-22 10:38:57 -07:00
William Douglas 4c7f900a79 Fix bundle manifest
Test bundle was for version 100 but used version 10 content, update
contents for version 100.
2016-03-22 10:38:57 -07:00
William Douglas 7fa16a7e25 Update test for missing os-core bundle on update
os-core should always be in the list of subscribed bundles so fix test
to check if it exists in the subscribed list or not.
2016-03-22 10:38:57 -07:00
Brad T. Peters be35968781 swupd-client: Functional test for the Search
This patch adds a host of new functional tests, ensuring the search
feature works as expected.

Signed-off-by: Brad T. Peters <brad.t.peters@intel.com>
2016-03-17 11:04:35 -07:00
William Douglas 92211a6c7d Fix functional test manifest
The manifest references a file but was using the directory flag
incorrectly, fix.
2016-03-14 19:45:30 +00:00
William Douglas 7143aec578 Add bundle-add include support
Eventually manifests will be able to include other manifests and this
patchset adds support for adding those included manifests when running
bundle-add on the including manifest.
2016-03-11 23:36:13 +00:00
William Douglas 1eb40ab8e6 Update source file formats with clang v3.8 2016-03-11 15:30:43 -08:00
Patrick McCarty 97047688c3 Add functional tests for boot file handling fixes
The following tests are added here:

- Add a boot file via 'bundle-add' (failed before the previous commit).

- Remove a boot file via 'bundle-remove'.

- Add a boot file via 'update'.

- Detect a boot file hash mismatch via 'verify' (failed before the
  previous commit).

- Fix a boot file with incorrect hash via 'verify --fix' (failed before
  the previous commit).

- Ignore a boot file during 'verify --fix' if marked deleted (failed
  before the previous commit).

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-10 11:43:31 -08:00
Archana Shinde 81eed9b75e Add functional tests for testing verify_fix_path functionality.
The tests check for missing directory and hash mismatch for a parent directory.
2016-03-07 14:23:51 -08:00
William Douglas 2568e6daf7 Add functional test for hashdump 2016-03-07 14:23:18 -08:00
Patrick McCarty 97db552019 Fix code style in some tests
clang-format does not have an option to make braces mandatory around
blocks (if/for/while/etc), but this is a style rule we are enforcing.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-07 14:23:18 -08:00
Patrick McCarty b925a8481c Run clang-format on the code
The following command was run with clang 3.7.1:

$ clang-format -i -style=file include/*.h src/*.c test/*.c

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-07 14:23:18 -08:00
Patrick McCarty 74973c8f1d Minor adjustments before running clang-format
clang-format is very picky about comment placement... Comments
immediately preceding labels are indented strangely, so move the
comments after labels instead. Also, adjust comment indentation level to
align with the surrounding code.

One other minor adjustment is needed for an array initialization; the
opening brace for the initialization must appear on the same line, or
else clang-format will format the entire statement differently.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-07 14:23:18 -08:00
Patrick McCarty c42f8a3aa1 Initial commit
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-02-24 09:34:13 -08:00