19 Commits
Author SHA1 Message Date
Brett T. Warden 541acddecd Tidy up /etc/swupd creation
Set /etc/swupd permissions to 0777 to let the default umask policy
handle stripping bits appropriately.
If we can write files to /etc/swupd, do it, making the directory first,
if necessary. If not, bail out cleanly. Only delete the
mirror_contenturl and mirror_versionurl files from the directory, not
the directory itself.
Add tests to verify normal behavior and corner cases.
2018-05-09 16:51:23 -07:00
Patrick McCarty 4b6b5c3305 test: update progress message for latest changes
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-10-12 10:40:37 -07:00
Patrick McCarty 82c25392b8 test: honor ignore-list in check_lines diff output
Fixes #306

Because 'ignore-list' contains patterns that cannot match lines from
'lines-checked', they should also be absent from the diff output that
compares 'lines-checked' to 'lines-output'. Implement this by post
processing 'lines-output' to omit ignored lines.

This change improves error reporting when check_lines() finds mismatches
between 'lines-checked' and 'lines-output' for a particular test.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-10-12 10:40:37 -07:00
Patrick McCarty 8f868bef1c test: validate correctness of lines-checked
Fixes #307

Previously to this change, lines-checked may have contained lines
matching patterns from the ignore-list, but matcher.awk does not expect
this situation and may result in difficult-to-diagnose test failures.

Instead, pre-validate lines-checked and if this validation fails, exit
with status code 2.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-10-12 10:40:37 -07:00
Patrick McCarty 58d7f667f2 test: echo test output regardless of exit status
If the test passes, BATS will not print the output anyway, so always
echoing $output (regardless of exit status) is better.

Also, make sure check_lines() returns the correct status.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-10-12 10:40:37 -07:00
Patrick McCarty 6c7674a08d test: process ignore-list before lines-checked
Because the next commit will be adding validation to ensure
lines-checked lines do not match ignore-list patterns, ignore-list must
be processed first.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-10-12 10:40:37 -07:00
Icarus Sparry 52c0ad20df Additional swupdlib.bash functionality
Allow chown_root and revert_chown_root to take multiple parameters, in
particular they can now take -R to do a recursive chown.

New functions clean_web_dir, clean_state_dir and clean_target_dir to
clean things up (clean_test_dir is now an alias for
clean_state_dir).

New function set_os_release to set the value in target_dir

New function unpack_target_from_manifest. This takes two parameters
release and name. It reads the manifest, locates the files from the
web-dir/$release/staged directory and copies them into target-dir, and
also creates the directories. Helpful in creating initial versions of
target-dir. Should be expanded to do deletion.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-10-02 13:13:27 -07:00
Matthew Johnson 1d19db4bc1 Add funtional test for swupd re-update
Adds functional test for swupd re-execs over format bumps.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-07-28 23:19:54 -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
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
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
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 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 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 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 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 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 a52eeb42cb Move functional tests to use the BATS framework 2016-04-26 22:15:04 +00:00