1208 Commits

Author SHA1 Message Date
Spyros Seimenis
fa9cf5aada asserts: add support for integrity stanza in snap revision assertions
Address comments:

- Rename Integrity to SnapIntegrity
- Export SHA3_384 and Size field of SnapIntegrity
- Add What variants for checkDigest and checkUint helpers
2023-05-09 09:59:56 +02:00
Philip Meulengracht
c715c2fd85 asserts,seed/seedwriter: support for validation sets in seedwriter (#12571)
* asserts,seed/seedwriter: support for validation sets when writing the image seed.

* seed/seedwriter: simplify writer code

* seed/seedwriter: updatethe docs for Start

* asserts,seed/seedwriter: review feedback

Add unit tests for AtSequence, ensure CheckValidationSets cannot be called unless download step has completed

* seed/seedwriter: review feedback

add unit test for CheckValidationSets to early call, reuse checkStepCompleted in checkSnapsAccessor
2023-04-04 09:55:44 +02:00
Philip Meulengracht
c5bc938f80 image,seed: refactor RefAssertsFetcher (#12667)
* asserts,seed/seedwriter: refactor RefAssertsFetcher into a SeedAssertionFetcher with support for FetchSequence, and its own set of unit tests.

* seed/seedwriter: review feedback

Removed the TODO and updated docs for Writer.Start

* seed/seedwriter: review feedback

remove a line of the docs for SeedAssertionFetcher

* seed/seedwriter: review feedback

add additional case for calling FetchSequence with the default fetcher
2023-03-29 07:48:31 +02:00
Philip Meulengracht
7ec1160e91 asserts: add code for Fetcher to support the fetching of sequence-forming assertions (#12654)
* multiple: add code for Fetcher to support the fetching of sequence-forming assertions
* asserts: obviously not a typo as I read it
* asserts: add new SeqFetcher interface
* asserts: add docs to NewSeqFetcher
* asserts: remove ResolveLatest and open another PR
* asserts: cleanup some doc comments, make sure they fit their use-cases. Include Fetcher interface in SequenceFormingFetcher. Rename SeqFetcher to SequenceFormingFetcher and the new function. Do some additional renaming. Reuse some code between FetchSequence and Fetch.
* asserts: add an additional unit test to document current behavior of multiple sequences of same assertion.
* asserts: update docs for NewSequenceFormingFetcher, readd a line I had removed accidently, the sequence number must be set back to 2 after testing with sequence 4
* asserts: add docs for the multiple-sequence behavior, add missing doc line for SequenceFormingFetcher.
* asserts: add unit tests for detecting circular references, clarify some of the terminology around sequences

---------

Co-authored-by: Michael Vogt <mvo@ubuntu.com>
2023-03-22 11:28:25 +01:00
Philip Meulengracht
d1f1074adf asserts: review feedback
add Optional to the sequence check, change error for wrongly formatted validation-set entry
2023-03-10 07:22:44 +01:00
Philip Meulengracht
6c167b9ab6 asserts: review feedback
clarify error description if specifying an invalid sequence
2023-03-10 07:22:44 +01:00
Philip Meulengracht
9a006ce79d asserts: review feedback
dont allow 0 in sequence, remove checkDefaultIntWhat as its not needed anymore, add unit test for the 0 case
2023-03-10 07:22:44 +01:00
Philip Meulengracht
77c9bfb609 asserts: review feedback
improve error messages, add missing unit test cases for these errors
2023-03-10 07:22:43 +01:00
Philip Meulengracht
080f154631 asserts: review feedback
use 'what' methods instead to provide error context when data members are invalid, change certain error messages to align with the rest, and introduce a What variant of checkIntWithDefault
2023-03-10 07:22:43 +01:00
Philip Meulengracht
b3f15803d1 asserts: remove monitor as a mode 2023-03-10 07:22:43 +01:00
Philip Meulengracht
1f903f7524 asserts: default to brand ID when account ID is not set 2023-03-10 07:22:42 +01:00
Philip Meulengracht
b18a7aab80 asserts: support validation-sets in model assertion 2023-03-10 07:22:42 +01:00
Philip Meulengracht
ae6489f798 golang: remove deadcode linter 2023-03-09 14:43:47 +01:00
Zeyad Yasser
12ad23f53a fix infinite recursion in errors.Is(err, &NotFoundError{}) 2023-02-09 16:02:40 +00:00
Zeyad Yasser
54c6a1d8c3 refactor: replace IsNotFound usages for errors.Is(err, &NotFoundError{}) 2023-02-09 16:02:40 +00:00
Miguel Pires
d097436c1c many: fix formatting w/ gofmt 1.19
Go 1.19 includes some changes to gofmt which intend to make lists and
heading clearer when rendered (https://go.dev/doc/go1.19). This commit
is the result of running the new gofmt and manually fixing some of it.
This was necessary because the new gofmt assumed lines beginning w/ tabs
to start lists or examples. While this is often true in our codebase,
we occasionally also use tabs to indent the lines after a TODO or FIXME
prefix or in yaml (e.g., excerpts of a snap.yaml). This meant that a lot of the
reformatted comments were broken and had to be fixed manually.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-01-16 14:23:11 +01:00
Philip Meulengracht
99302b1ad3 asserts: review feedback
update maxSupportedFormat to 2, update test, add check that UserExpiration is empty by default
2022-10-19 10:38:34 +02:00
Philip Meulengracht
2afc347391 asserts: reverse logic check 2022-10-19 09:26:01 +02:00
Philip Meulengracht
957f45b5af asserts: review feedback
update doc and error text, update unit tests
2022-10-19 09:13:29 +02:00
Philip Meulengracht
30cbadccf5 asserts: require header format 2 to use the new user-presence variable 2022-10-19 09:10:36 +02:00
Philip Meulengracht
ae9eee9ee5 asserts: rename user-valid-for to user-presence, add unit test specifically to verify that the member is optional, fix current logic determining this 2022-10-18 08:29:06 +02:00
Philip Meulengracht
14d7b7fb4f asserts: move the possitive test into TestDecodeOK 2022-10-13 12:48:18 +02:00
Philip Meulengracht
a22d1b8b41 asserts: review feedback
remove the duration part of the functionality after discussions on this subject. This cleans up a bit a code. Folded all unit tests into the DecodeOK/Invalid
2022-10-13 12:47:56 +02:00
Philip Meulengracht
bc6f4eac85 asserts: corrections to error messages, and corrections to docs 2022-10-10 09:18:41 +02:00
Philip Meulengracht
b0c7ae1e69 asserts: add support in system user assertion for keyword 'user-valid-for' 2022-10-10 09:10:14 +02:00