1041 Commits

Author SHA1 Message Date
Paweł Stołowski
16d858b20c Simplify TestBackstore test (thanks pedronis) 2021-07-13 12:05:22 +02:00
Paweł Stołowski
d9d09f1915 Add test for Backstore() function. 2021-07-13 09:05:11 +02:00
Paweł Stołowski
909e34c75a Check for conflicts when refreshing and commiting validation set assertions. 2021-07-12 11:13:20 +02:00
Samuele Pedroni
d9a4499dbf c/snap,asserts: create/delete-key external keypair manager interaction
at least initially we don't support using snap commands to create/delete
keys under an external keypair manager, organize things such that though
we can produce appropriate error messages and we can implement
supporting this later if required
2021-07-08 11:39:47 +02:00
Samuele Pedroni
f8b8615476 c/snap,asserts: introduce KeypairManager.List for "snap keys"
implement it in both GPGKeypairManager and ExternalKeypairManager
2021-07-01 16:53:28 +02:00
Michael Vogt
79a93de625 Merge pull request #10370 from pedronis/ext-keymgr-1
asserts: introduce ExternalKeypairManager
2021-07-01 16:47:37 +02:00
Samuele Pedroni
226ab58974 asserts: some small cleanups and clarifications
thanks @mvo
2021-06-29 18:01:04 +02:00
Samuele Pedroni
e05c79847f asserts: clearer error messages, more robust mock command
thanks @stolowski, @degville
2021-06-24 16:58:10 +02:00
Samuele Pedroni
f2cdb6dd92 asserts,interfaces,snap: fix imports order (according to gci) 2021-06-14 20:54:41 +02:00
Samuele Pedroni
c190fd2b05 asserts: test how ExternalKeypairManager.loadAllKeys is implemented 2021-06-10 13:48:22 +02:00
Samuele Pedroni
61d41d8d81 asserts: DER public keys are expected to be PKIX
that's the case with pkcs11-tool
2021-06-10 11:58:47 +02:00
Samuele Pedroni
a97126c78e asserts: implement ExternalKeypairManager.Export 2021-06-10 09:20:58 +02:00
Samuele Pedroni
716a951c5d asserts: full ExternalKeypairManager.Get implementation
also fix/improve key caching
2021-06-10 09:20:58 +02:00
Samuele Pedroni
895e560e48 asserts: introduce ExternalKeypairManager
this supports using an external program with a simple interface to
handle key management.

this starts with minimal support to be able to perform signing.
2021-06-09 20:30:54 +02: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
35c76d6f1a seed: ReadSystemEssentialAndBetterEarliestTime (#10005)
ReadSystemEssentialAndBetterEarliestTime retrieves in one go
information about the model and essential snaps of the given types
for the Core 20 recovery system seed specified by seedDir and label
(which cannot be empty).
It can operate even if current system time is unreliable by taking
a earliestTime lower bound for current time.
It returns as well an improved lower bound by considering appropriate
assertions in the seed.

* asserts: Batch.CommitToAndObserve

have a variant of CommitTo that supports a callback to consider each
assertion immediately after it has been added to the database, at
which point it also verified
2021-03-18 18:40:16 +01:00
Samuele Pedroni
1b4d6fe258 asserts: isValidAssumingCurTimeWithin earliest=time.Time{} tests
also fix some test comments
2021-03-12 14:33:31 +01:00
Samuele Pedroni
0109e8c283 asserts: fix some typos 2021-03-11 09:58:07 +01:00
Samuele Pedroni
f3d9f94d54 asserts: clarify/simplify AccountKey.isValidAssumingCurTimeWithin
simplify the code a bit, try to improve the name/comments

thanks @mvo and @stolowski
2021-03-10 14:14:54 +01: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
Paweł Stołowski
9861c37af9 Cleanup the tests to make them more consistent (thanks ijohnson),
simplify addToGrouping ifs.
2021-03-02 13:08:44 +00:00
Paweł Stołowski
37828afb66 Use Fetcher in AddSequenceToUpdate. Fix addUnresolvedSeq not returning error. 2021-03-02 13:08:03 +00:00
Pawel Stolowski
07b6ed2059 asserts: pool changes for validation-sets (#9930)
Support for sequence-forming assertions in pool.
2021-03-02 12:09:21 +01:00
Maciej Borzecki
0fb99cff8c asserts: include the assertion timestamp in error message when outside of signing key validity range
We occasionally get the following backtrace in the tests:

----------------------------------------------------------------------
PANIC: api_users_test.go:762: userSuite.TestPostCreateUserFromAssertionNoModel

... Panic: cannot add test assertions: model assertion timestamp outside of signing key validity (key valid since "2021-02-23 11:10:41 +0000 UTC") (PC=0x45CF4A)

/snap/go/2117/src/runtime/panic.go:491
  in gopanic
/home/runner/work/snapd/snapd/src/github.com/snapcore/snapd/overlord/assertstate/assertstatetest/add_many.go:38
  in AddMany
api_users_test.go:776
  in userSuite.TestPostCreateUserFromAssertionNoModel
/snap/go/2117/src/reflect/value.go:302
  in Value.Call
/snap/go/2117/src/runtime/asm_amd64.s:2337
  in goexit
OOPS: 439 passed, 1 skipped, 1 PANICKED
--- FAIL: Test (9.62s)
FAIL
coverage: 86.4% of statements
FAIL	github.com/snapcore/snapd/daemon	9.786s

Adding a timestamp of the assertion, will help it to debug the problem further.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-02-25 11:42:27 +01:00
Michael Vogt
95dfe3f77b Merge pull request #9880 from anonymouse64/feature/uc20-recover-repair-asserts-5.2
tests/lib/fakestore: support repair assertions too
2021-02-22 09:22:55 +01:00