126 Commits

Author SHA1 Message Date
Miguel Pires
438424b702 asserts: improve time range formatting
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-07-08 10:56:01 +01:00
Miguel Pires
24c876c8ce asserts: add more context to key expiry error
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-07-06 15:13:49 +01:00
Paweł Stołowski
5245cd1ba8 Fix ineffectual assignment in the test. 2022-04-15 17:18:11 +02:00
Samuele Pedroni
491ff56795 asserts: export MockOptionalPrimaryKey for usage in other packages 2022-04-06 14:17:12 +02:00
Samuele Pedroni
98de63ac23 asserts: support optional primary keys in Find family
change PrimaryKeyFromHeaders to allow for omitted optional primary
keys
2022-04-06 14:17:12 +02:00
Samuele Pedroni
331724d76d asserts: minimal changes to disable authority-delegation before full revert
authority-delegation might have been premature, disable until we might
decide for a full revert
2022-03-14 18:47:04 +01:00
Samuele Pedroni
d5c752b103 asserts: drop wrong and unnecessary type in fixture headers 2022-02-14 15:20:10 +01:00
Samuele Pedroni
078cb5f74c asserts: first-class support for formatting/encoding signatory-id
together with checks for it
2022-02-11 15:24:41 +01:00
Samuele Pedroni
d59e2e8f47 asserts: fix error message and test
thanks @MiguelPires and @stolowski
2022-02-04 17:22:50 +01:00
Samuele Pedroni
e3b23eef45 asserts: implementent Check*Delegation*
these implement the logic to validate delegation
if needed
2022-02-04 17:22:50 +01:00
Samuele Pedroni
130242ee7e asserts: start supporting delegation when validating signatures
* start of basic test (failing here)
* start of signatory-id support
2022-02-03 11:22:12 +01:00
Michael Vogt
856cd41c7f asserts: rename "white box" to "clear box" (woke checker)
First PR to fix an error from the "woke" checker [1].

[1] https://github.com/get-woke/woke
2021-11-22 10:08:19 +01:00
Alberto Mardegan
37e83765f3 asserts: fix errors reported by linter
Besides some trivial fixes, this also adds the (previously unused) class
`isUnacceptedUpdateSuite` to the tests suite.
2021-05-05 10:16:20 +03:00
Samuele Pedroni
0409b0d0e9 asserts: mode where Database only assumes cur time >= earliest time
if current system time is unreliable have a mode where Database checks
for key expiry just based on assuming that current time is >= known
earliest time

this is set up via Database.SetEarliestTime

internally a new predicate AccountKey.isKeyValidAbout(earliest,
latest) is used to support this
2021-03-05 09:27:12 +01:00
Samuele Pedroni
8eff2997ae asserts: repeat the authority cross-check in CheckSignature as well
findAccountKey was alread checking this but
this is an additional defense and makes CheckSignature a more
robust standalone helper if used that way
2021-02-12 18:29:30 +01:00
Samuele Pedroni
237c0103ac asserts: implement Database.FindSequence
FindSequence finds a sequence-forming assertion based the given
headers. Provided headers must contain a prefix of the primary key
for the assertion type except for the sequence header.
Th assertion is the first in the sequence under the prefix with
sequential number > after.
If after is -1 it returns instead the assertion with the largest
sequential number.
2020-06-29 14:14:28 +02:00
Samuele Pedroni
d1e2afcbb1 introduce asserts.Database.WithStackedBackstore 2019-07-19 09:37:15 +02:00
Samuele Pedroni
3c5f9613b6 many: switch to account validation: unproven|verified (#5419) 2018-06-28 08:56:48 +02:00
Samuele Pedroni
97e3ef21a3 many: introduce asserts.NotFoundError replacing both ErrNotFound and store.AssertionNotFoundError (#3893)
This converts the singleton asserts.ErrNotFound to a richer asserts.NotFoundError struct carrying Type and optionally PrimaryKey, similar to store.AssertionNotFoundError which then gets folded with this.

This means code doesn't have to worry anymore which is which or to convert between the two. And when possible there is more information around. Though Backstores can continue to return minimal information (Type but not Headers in the new error).

A helper asserts.IsNotFound is also added to cover the simple old ==/!= asserts.ErrNotFound needs.

This also fixes/adjust some error handling to usually not repeat the richer information twice.
2017-09-12 16:34:53 +02:00
Samuele Pedroni
392fbba353 improve errors 2017-08-10 16:02:25 +02:00
Samuele Pedroni
103f98f17e support predefined assertions that don't establish foundational trust 2017-08-09 12:55:23 +02:00
Samuele Pedroni
4a0547ee90 add some tests that as per design we don't accept chains of assertions founded on a self-signed key coming externally 2017-07-04 11:10:09 +02:00
Samuele Pedroni
ad12f1c854 asserts: implement FindManyTrusted as well (#3516) 2017-06-23 11:16:55 +02:00
Samuele Pedroni
01ed3c86c1 implement a SuggestedFormat helper to help avoid specifying the wrong format iteration for an assertion 2017-01-20 16:55:42 +01:00
Zygmunt Krynicki
ed6ef8c710 asserts: fix ineffectual assignment to headers
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2016-11-22 15:48:48 +01:00