Commit Graph
28 Commits
Author SHA1 Message Date
Otavio Pontes 2bf4169a4a Don't mix tabs with spaces in the same file
And prefer tabs over spaces, because that's the project standard for
source files

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-10-29 11:54:25 -07:00
Otavio Pontes 66ea5fea0f progress: Make progress bar and spinner more similar in style
And protect spinner from printf's during spinner time

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-10-18 09:27:25 -07:00
Otavio Pontes bb1559ef6e compliant: Add check for trailing whitespaces on tests
Note that the clang-format already does this for the source code

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-10-04 16:05:21 -07:00
Otavio Pontes 3e674a66c7 json: Remove trailing spaces at the end of strings
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-10-03 15:26:54 -07:00
Karthik Prabhu Vinod 15be9a7f09 Show format bump
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>
2019-09-18 14:22:30 -07:00
Otavio Pontes 0696de4435 curl: Initialize curl as needed
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 #801
Fixes #895
Fixes #277

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-20 10:48:20 -07:00
Otavio Pontes 277fc0284e mirror: Handle global parameters properly on mirror set
We have 2 global parameters to change content and version url that
were confusing when using mirror. For example user's didn't know what
to expect from:

$ swupd mirror --content-url https://new_url

or

$ swupd mirror --set https://new_url1 --content-url https://new_url2

Fix #941

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-25 14:06:27 -07:00
Otavio Pontes 0968948389 test: Rename the name of the distro for tests
We don't need to have a real distribution name for tests. Use a swupd
specific value.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-19 14:20:00 -07:00
Brandon Hong d0494ba47e Update test case MIR008 for the new swupd info output
Signed-off-by: Brandon Hong <brandon.hong@intel.com>
2019-07-19 10:10:10 -07:00
Brandon Hong b09bdddabe Update testcases to reflect new info format
Signed-off-by: Brandon Hong <brandon.hong@intel.com>
2019-07-19 10:10:10 -07:00
Castulo Martinez a61eed9bb7 Fix bug in mirror-allow-http.bats test
This test is yielding different results depending on if it is being run
in a system that has a proxy set up o there is no proxy.
This is happening because when usnig a non existing  server, if
there is a proxy set up, the proxy does respond during curl
initialization instead of the specified server, which allows swupd to
initialize only to fail further down the process when requesting the MoM
to the server. If the system where the test is run doesn't have a proxy
set up, curl fails to initialize since it gets no reply from the server,
which causes swupd to fail initialization, so swupd exits earlier in the
process and with different exit code.

This commit fixes the ambiguity of the test by not checking for an exit
code explicitelly but only making sure it does get an error code.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-10 13:37:01 -07:00
Castulo Martinez 2f45cf4c55 Warn user setting mirror to http
If a user sets a mirror that uses http, it is going to cause autoupdates
to stop working since autoupdate would need the --allow-insecure-http
flag to continue with the insecure connection. In order for autoupdate
to work the user will need to add the key/value allow-insecure-http=true
in the swupd config file.

This commit warns the user about this when setting up a mirror with http
so they can take steps to re-enable autoupdate.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-01 17:18:50 -07:00
Otavio Pontes 4e1968165e test: Adding extra allow-insecure-http tests
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-01 16:12:08 -07:00
Otavio Pontes db7701bf73 test: Use https instead of http on mirror tests
This tests aren't testing the insecure http flag, so prefer to use https here

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-01 16:12:08 -07:00
Otavio Pontes ac210d375d test: Remove a swupd option specific for mirror
We shouldn't use a swupd without setting without -S and there's no reason to
have a custom option for mirror anymore

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-01 16:12:08 -07:00
Castulo Martinez 43ba5def2a Require a force flag to continue with insecure URL
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>
2019-06-27 14:48:50 -07:00
Castulo Martinez eb694590a4 Re-enable the json tests
The json tests had been disabled because they were unstable. This issue
was fixed in a previous commit, so these tests should be enabled again.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-04-18 10:29:49 -07:00
Otavio Pontes 9525c93265 test: Disabling json tests for now
Disabling json tests that checks for progress because tests are unstable.
If we have any minor changes in the code that could affect how curl is called
we could have different progress reports and because of that we would have false
negatives.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-10 15:27:30 -07:00
Castulo Martinez 069af9decf Enabling the --json-output flag as a global option
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>
2019-04-01 12:03:23 -07:00
Castulo Martinez c545a02378 Use logger to print all messages in screen
swupd prints some messages to stdout and others to stderr, this makes
the code somewhat confusing and also it creates a mess regarding which
messages go where. Messages are usually printed using fprintf() and
printf().

This commit replaces all calls to printf and fprintf with one of the
functions that are part of the logger. This will bring many advantages
to the code:
 - readability, it is straightforward to identify where a message needs
to go based on the name of the logger functions.
 - consistency, the output will go to either stderr or stdout depending
on the type of message being printed.
 - the format of the messages will also be consistent, so for example,
if the message is an error the message will automatically include the
"Error: " label in the beginning of the message, this way we avoid
having things like "ERROR:", "error - ", etc...

Closes #864
Closes #294
Closes #489
Closes #433

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-03-25 16:07:40 -07:00
Castulo Martinez a3fa69847b Fixes a bug in update when using mirrors
There are a couple of problems when the user has a mirror set up,
and tries to update. The first one is that in the case where the
user is using the -p option and a mirror, the version of the mirror
was failing to be retrieved since the path_prefix was being added
to the path twice. The second problem was that when the mirror being
used by the user was stale, the mirror was being unset but some values
had already being cached, causing the update function to fail.

This commit fixes the issues and add a few tests to validate the
correct behavior.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-12-06 14:53:19 -08:00
Castulo Martinez 85c8e9f816 Define versionurl and contenturl in test env
The versionurl and contenturl files are used by swupd to see where
the upstream server is.

This commit adds those files into the test environment and sets
them up so they point to the appropriate content in the test
environment, this way we can get rid of the -u option for most of
the tests, also this resembles closer a real environment.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-12-06 14:53:19 -08:00
Castulo Martinez 09967f5508 Adding IDs to mirror tests
Adding IDs to mirror tests and some small changes.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-11-16 15:51:32 -08:00
Otavio Pontes 3b37d0192e test: Fix errors reported by shellcheck
Shellcheck is a shell script static analysis tool that looks for errors and
programming pitfalls in shell scripts.
Fixing errors reported by running that tool on bats scripts

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-31 09:51:42 -07:00
Castulo Martinez 808f70cd1c Replacing old mirror tests
The old mirror tests used the swupdlib.bash library that was
replaced by testlib.bash.

This commit replaces those old mirror tests with new versions
of the same tests that now use testlib.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Matthew Johnson 5a8420b06a Remove copyright header checks from tests
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-05-14 11:05:33 -07:00
Brett T. Warden ebe8a8118a Check status of swupd command in mirror tests 2018-05-09 16:51:23 -07:00
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