Suggested change on check-update --verbose. Print extra line with latest version in current format.
The only 2 cases where this will be different from latest version is in the case of a format bump or
in the case where a format is explicitly stated using -F.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Now, we have global option
and info_verbose logging level.
For this PR, we have verbose for info,
check-update which shows format versions.
This also helps future implementations leverage
the use of a verbose option for their own need.
commands:
swupd check-update --verbose
swupd info --verbose
Fixes#1066
Signed-off-by: Karthik Prabhu Vinod <karthik.prabhu.vinod@intel.com>
There was a bug in the logic of the setup function in testlib which was
causing the globale_teardown to be incorrectly called when tests were
being run using "bats <directory>/". This commit fixs the issue.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Instead of initializing curl library on start, initialize it only when needed.
The advantage of this approach is that we can run some commands offline, if
there's no file to download.
Fixes#801Fixes#895Fixes#277
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
When running the check-update command we get the latest version for the
format we are currently in, but we really want to get the latest version
regardless of the format.
This commit fixes the issue.
Closes#482
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Currently users can set content and version urls based on http or https
protocols. This pose a security risk if users decide to use http.
This commit blocks swupd from working with http unless is specifically
allowed by using the --allow-insecure-http flag.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The --json-output flag can be enabled for every swupd command.
This commit converts it to be a global flag, and enables it in every
swupd command.
Closes#869
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Instead of printing errors and warnings, just print debug information
when we are looking for the right ca path to use. If we couldn't
connect to the server, abort and print a clear error message.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Renaming codes following these rules:
- All codes should start with SWUPD_ so we never get confused what
code comes from swupd
- Always separate codes that contain multiple words using an underscore
SWUPD_MULTI_WORD_ERROR instead of using SWUPDMULTIWORDERROR
- Code 0 is reserved for SWUPD_SUCCESS (or SWUPD_OK)
- Code 1 is reserved to be used as "no" by commands that return a boolean
state (e.g. swupd autoupdate, check-update)
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This will make outputs a lot better when using --quiet because optional
curl messages wont be printed.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Sometimes is useful to be able to limit the size of a test environment
to validate some scenarios that are bound to disk size.
This commit adds a -s (size) option that can be used when creating test
environments so the user can control how much space is available in that
environment. If not used, the test environment works the same as before.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
When we have SSL connections errors we try to use fallback CA paths added by the
--with-fallback-ca-paths configuration flag.
Instead of printing errors in this case, just print a warning. An error
message will be printed when we fail when trying all fallbacks.
Fixes: #746
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
The tests that attempt to verify the client certificate were using the
swupd -u option to set the url of the "upstream server". Recently a
function was added to the test library to set the default upstream
server.
This commit modifies these tests so they used the new function to set
the upstream server instead of using the -u option. This will provide
the benefit of the test environment being more similar to a prod
environment, also makes the test setup less convoluted and the tests
easier to read.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The server.py script is used in some functional tests to simulate
a slow content server. This commit provides a few extra options
that extend the use of this script for testing purposes.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The slow server tests are using the global setup to create the test
dependencies, like setting up the web server. Recently a function to set
the upstream server in a test environment was added to the test library
which now makes possible to configure the environment to use this server
after it's been created so we no longer need to create the web server in
the global setup.
This commit moves the creation of the web server to the test_setup
function to make the code from the tests easier to read and less
convoluted.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
When the system time is way off, the certificate validation will
fail. For this reason, many swupd commands attempt to fix the
system time if wrong. check-update was not doing this so the
command would fail in this situation.
This commit adds a verification for this so check-update attempts
to fix the system time and continue instead of failing.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Tests will be cleaned up by a trap routine when interrupted early. This
change also moves test web server and certificate store clean up to the
destroy_test_environment function.
Signed-off-by: John Akre <john.w.akre@intel.com>
Some tests wrote files and directories to /tmp. This change moves the
test certificates directory into the swupd repo's top level directory
and moves other test files into their corresponding test directories.
Fixes#650
Signed-off-by: John Akre <john.w.akre@intel.com>
There were two web server implementations in the functional tests and the
test library's slow server implementation was not functional. These issues
were addressed by the following changes:
- Consolidate test web server implementations into test library
- Add partial download support to start_web_server test library function
- Fix test library slow server functionality.
Signed-off-by: John Akre <john.w.akre@intel.com>
read_versions is a function that attempts to read the current version
of the target system and the server version, but if there is an error
reading any of those values no action was performed so it was necessary
to validate these values wherever the function was being used,
duplicating code.
This commit adds a verification to make sure the current version of the
target system and the server version was able to be identified.
Closes#589
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The old checkupdate tests used the swupdlib.bash library that was
replaced by testlib.bash.
This commit replaces those old checkupdate tests with new versions
of the same tests that now use testlib.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Instead of checking if server supports resume for every execution
that uses the network, do it only when resume is going to be used
Fixes one of the problems cited on #432
A colon-separated list of alternative CApath options can be passed to
swupd-client at the configuration time using --with-fallback-capaths
option.
In runtime, fallback CApath support is implemented as part of the
connectivity check. The implementation will try the default (built into
curl) and then will iterate through the list in the order they were
specified. It is done only once on the first call.
The code is reorganized to keep the connectivity check inside curl
wrapper:
* Deleted check_network implementation from version.c
* Removed have_network global (globals.c)
* Scoped swupd_curl_test_resume to curl.c
* Change use of check_network to swupd_curl_check_network
Also:
* Fixed an issue where SSL was only enabled if a URL was matching the
content URL
Fixing the compiler issue for check_network in check_update.c triggered
test failures. Fix the test failures and improve the error output for
when check_network() fails.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Adds status checks for each swupd command called in the functional
tests. At this point several of these tests fail due to some successful
commands returning error statuses.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Check that the simple test server in the checkupdate/slow-server/ test
is available before actually running the swupd command. This check is
done by testing the return status of a curl command on the server up to
ten times until successful.
Since this is an historically touchy test, output an additional
debug.log in the test directory with much more verbose logging (using
set -x).
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
We draw a hard line with error codes, such that:
Error code 16 is reserved for failures resulting from the basic
network check. Any call to check_network() that fails will
return this error code. No other error path returns this
error code.
Additionally, check_network() is called in every normal code path.
All other, possibly network related issues, return a different
error code. If the basic network check succeeds, but e.g. pack
downloads fail, we return a new (23) error code so that we
can better establish the conditions through telemetry and
determine whether the error is on the client or the server,
which is highly likely with this new error code 23.
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>
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>
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>
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.
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>