Commit graph

14 commits

Author SHA1 Message Date
Jussi Kukkonen
e9b294b57c
Add an HTTP error for Fetcher interface
A custom error is required so that updater is able to special case
403 & 404 status codes.

Rewrite the test case a bit to be more readable.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-02-24 11:41:34 +02:00
Jussi Kukkonen
7d73958a2a Add MissingLocalRepositoryError
This allows clients to separate
a) missing local repository and
b) error while loading local repository

This is fully backwards-compliant: MissingLocalRepositoryError derives
from RepositoryError and every situation that now results in
MissingLocalRepositoryError used to result in a RepositoryError.

Fixes #1063

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2020-10-12 15:23:15 +03:00
Joshua Lock
292b18926b Use __name__ for loggers, per convention
Replace hard-coded logger names with __name__. For the most part this just uses
the standard conventions to create the same logger hierarchy as existed before.
The only real difference is that loggers created for printing during tests are
no longer part of the 'tuf' hierarchy.

Signed-off-by: Joshua Lock <jlock@vmware.com>
2020-03-03 10:36:39 +00:00
Sebastien Awwad
522b4a0f54
Fix #857: allow logging NoWorkingMirrorError to include details
for errors that use calculated error messages (like
ReplayedMetadataError).

Do this by adding __repr__() functions to the contained errors.

Additionally:
- adds repr funcs to some other exceptions that have str funcs
- fixes some minor style issues
- for reviewers, adds commented-out direct-reproduction code
  to the repr() funcs.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2019-04-19 13:23:19 -04:00
Sebastien Awwad
18ef3b419d
Improve the way specification version is checked in metadata
and generate more friendly errors.  Prior to this, a test in
test_updater.py was written in such a way to not actually be
testing whether or not specification version checking was
working correctly -- the error updater.py raised if a specification
version number was not supported was the same as would be raised
if a role version was not the expected version, and, amusingly,
the test could not distinguish between these two scenarios and
was providing the wrong role version......

Specification version mismatch now raises a particular error:
UnsupportedSpecificationError.

The specification version supported by this code is now also all
in one place, tuf.formats rather than tuf.updater.

Related error messages and testing were improved (with some
edge cases closed).

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2019-03-28 18:30:03 -04:00
Sebastien Awwad
4fb4d73093
minor: satisfy new pylint version by removing pass in class defs...
in tuf/exceptions.py, since those class definitions have docstrings,
and that is apparently sufficient in a class definition to make a
'pass' statement unnecessary.  pylint version 2.2.0 complains about
unnecessary pass statements in this situation, so this resolves that.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-11-28 10:18:49 -05:00
Sebastien Awwad
ec27630a48
minor: PR tweaks based on review: doc, casing, typos, updates
- two reversions to unnecessary changes
- some typo fixes
- capitalization of HTTP/S where reasonable
- commenting out code section with ''' rather than #

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-10-02 15:01:38 -04:00
Sebastien Awwad
a5416d4baa
Raise helpful error in download.py if cannot parse URL
to extract hostname. After commit
"use a different session per hostname",
the code no longer raises MissingSchema if a URL is malformed in
certain cases. Since it parses URLs to extract the hostname and
would have raised securesystemslib.exceptions.FormatError, so the
test would have to check for that error instead of requests's
MissingSchema.

However, it's best to use a different error type, since while that
would be, true enough, a formatting error, FormatError is customarily
reserved for the automatic detection based on schemas in formats.py
(using <SCHEMA>.check_match()), and in any case it is not a
securesystemslib error.

So this commit adds error type tuf.exceptions.URLParsingError and
raises it if the hostname cannot be isolated in a URL, and checks
for it in test_download.py.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-09-10 16:30:32 -04:00
Trishank K Kuppusamy
b9bc8602c2
Update TUF to handle HTTPS proxies
Signed-off-by: Trishank K Kuppusamy <trishank.kuppusamy@datadoghq.com>
2018-08-31 13:18:35 -04:00
Vladimir Diaz
8f65fa4154
Rename license files in modules
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-02-05 11:31:19 -05:00
Vladimir Diaz
3894bc4e31
Add copyright and license info to module files
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-11-30 13:23:38 -05:00
Vladimir Diaz
48ad359306
Resolve remaining warnings in exceptions
* Make sure to call base class's __init__()

Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-11-20 14:10:27 -05:00
Vladimir Diaz
3bfa9f68ed
Remove compression code from exceptions and update unit tests 2017-08-25 13:27:03 -04:00
Vladimir Diaz
f5a1c93a22 Add exceptions.py to TUF 2017-01-11 10:45:00 -05:00