Commit Graph

103 Commits

Author SHA1 Message Date
Ying Li 9252d9d892 Update client.Target to include a RoleName, so we know where the target is when listed.
Signed-off-by: Ying Li <ying.li@docker.com>
2016-01-04 10:49:54 -08:00
Diogo Mónica ffca6fb522 Merge pull request #388 from docker/cleanup
Rebased cleanup/remove PEM headers
2015-12-23 11:36:25 -08:00
Ying Li 0465365fb6 Return an error if unable to encrypt a key as a valid PEM file
Also address review comments and fix semantic conflict after rebase.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-23 09:44:51 -08:00
David Lawrence fa788cb2a9 make x509 certs viable as delegated public key object
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-23 09:41:03 -08:00
David Lawrence e516dd88f2 cleaning up tests by converting t.Fatal to assert.___
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-23 09:41:03 -08:00
Riyaz Faizullabhoy 9b0ae29427 ErrRepoNotInitialized test
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2015-12-22 16:53:31 -08:00
Ying Li 332621607e Add more comments and assertions as per review.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-22 16:29:28 -08:00
Ying Li 6423c16233 Test pushing an uninitialized repo as well.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-22 16:29:28 -08:00
Ying Li ebac6b158a Refactor tests to cover corrupt root/targets/delegations.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-22 16:29:28 -08:00
Ying Li ab97f9e12e Refactor some of the code to reduce creating temp notary repo directory boilerplate.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-22 16:23:19 -08:00
Ying Li d6234e5ef0 Add some simple failure cases where data is corrupt or we can't get server keys.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-22 16:23:19 -08:00
Ying Li c1eb344b89 Rotation tests now test reading from other (non-publishing) clients.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-22 16:23:19 -08:00
Ying Li f794193382 Address review comments (renaming, extra code left in, etc.)
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-22 15:32:05 -08:00
Ying Li 66384edfc3 Add some more publishing tests.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-22 00:44:50 -08:00
Ying Li dcef24996e Add more delegation writing/publishing tests.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-22 00:23:32 -08:00
Ying Li 34055f8cf7 Code cleanups as per review, and after rebasing.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-18 16:51:48 -08:00
Ying Li a1cbe5d43c Add test for, and fix bug with, publishing a bare repo not sending the targets file.
It should always be published the first time, like the root.json.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-18 16:37:24 -08:00
Ying Li c12958af36 Do not sign the actual targets metadata unless it's dirty.
Previously we were always signing it, but we can't do that anymore
because then delegated users won't be able to publish ever (they
probably don't have the target key).

Some other related changes: when role keys are rotated, that role
needs to be marked as dirty now in order to be re-signed and
published.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-18 16:37:24 -08:00
Ying Li f1761afc25 Fallback on the parent role if the role to add a target to doesn't exist.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-18 16:37:24 -08:00
Ying Li 9f04ca66f7 Add tests for publishing targets to delegations, and delegations themselves.
This involved a refactor test helper function assertPublishSucceeds to
take roles and expected published-to-roles.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-18 16:37:24 -08:00
David Lawrence d3a54cab25 the empty string should be used in delegation Paths to indicate a role can sign anything
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-18 16:10:43 -08:00
David Lawrence d49228ad70 fixing copy paste bad var name
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-18 11:54:01 -08:00
David Lawrence a2a4870512 adding comment about priority ordering and updating test for ListTargets with delegates to hit default no roles passed case
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-18 11:21:12 -08:00
David Lawrence 574b4d543d updating ListTargets delegate test to check iteration of children and correct (lack of) overwriting.
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-17 21:28:52 -08:00
David Lawrence 9307692b52 reverse priority order or roles for ListTargets and GetTargetsByName
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-17 16:33:52 -08:00
David Lawrence 4243b258b3 making GetTargetsByName work with delegations
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-17 10:46:41 -08:00
David Lawrence 4a9ebb8bc8 adding test for ListTargets with delegation
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-17 10:09:34 -08:00
David Lawrence 377b72a54f updating list targets to list across multiple roles
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-17 10:09:34 -08:00
Ying Li 15ad91eea3 Add tests for not being able to write changefiles when changing delegations.
This involves refactoring some of the previous write error code.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-16 18:29:54 -08:00
Ying Li c917c0b884 Split AddDelegation test so more more levels
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-16 17:54:50 -08:00
Ying Li 351d5483b7 Implement RemoveDelegation for NotaryRepository.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-16 16:01:17 -08:00
Ying Li c72934794a Implement AddDelegation for NotaryRepository.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-16 16:00:45 -08:00
Ying Li 0bec06eb9b RemoveTarget now takes an optional variadic list of roles to remove from.
If none are provided, it defaults to the targets role, as before.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-16 13:18:40 -08:00
Ying Li 19c49cf7ce AddTarget now takes an optional variadic list of roles to add target to.
If none are provided, it defaults to the targets role, as before.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-16 13:18:40 -08:00
Ying Li 2c7e632925 Amend rotation tests to assert old keys are removed after rotation.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-14 17:44:28 -08:00
Ying Li 8521ea5b6d Convert NotaryRepository.RotateKeys to RotateKey(role, serverManages bool)
This should make it possible to delegate snapshot key management
to the server for existing repos, or switching back to user managing
snapshot keys.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-14 17:17:23 -08:00
Ying Li c0bf1a4a68 Fix semantic merge conflict.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-11 17:37:29 -08:00
Ying Li 9d2590ffb5 Only allow publishing if there is no snapshot.json, not if it's corrupt
or unreadable.

This also modifies tuf/store/filestore to return ErrMetaNotFound if the
metadata file does not exist.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-11 15:04:08 -08:00
Ying Li 8b9cc4c3f6 Minor review comment changes:
- add a specific error type when the server is requested to manage
  an unsupported key type
- variable name change

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-10 17:16:53 -08:00
Ying Li 5717258931 When publishing, if no snapshot data exists, create it and then try to sign.
This supports the case of a user intializing a repo so that the server
signs the snapshot, and then changing their minds and rotating the keys
so that they now sign the snapshot, but all before publishing a single
thing.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-10 16:28:20 -08:00
Ying Li a89bdaa9bf Just propogate server error if server can't sign snapshot.
The errors returned by the server aren't great right now, so it's hard
to try to be clever in synthesizing a signed.ErrNoKeys{}.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-10 10:16:39 -08:00
Ying Li a924ca172f When initializing a repo, create local keys before getting remote keys.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-10 10:16:39 -08:00
Ying Li 39d79d9844 NotaryRepository.Publish supports server managing snapshot keys.
When publishing, do not sign and send the snapshot metadata if the
client does not have the snapshot key.  If the server sends back
an error, then it also does not have a snapshot key and the
client should propogate the no signing key error.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-10 10:16:39 -08:00
Ying Li 4b46a34524 NotaryRepository.Intialize supports server managing snapshot keys.
If configured to have the server manage the snapshot key, the snapshot
key is not generated and there will be no snapshot metadata.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-10 10:16:39 -08:00
Miloslav Trmač 57a15112c8 Fix error handling on invalid root passphrase
When the user insists on an invalid passphrase (or aborts the
operation), CryptoService.GetPrivateKey will try the correct root
location first, correctly failing, and then try to look for the root key
in the $gun subdirectory, and so will return the last error, a confusing
”open $path: no such file or directory”.

So, recognize the passphrase-related errors and fail with them directly.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2015-12-09 19:58:02 +01:00
Ying Li e3cee0cdbd Refactor the client TestInitRepo test into reusable helper functions.
Also, eliminate the timestamp JSON constant and just generate a new
one for the tests.

The client test now also uses KeyFileStore and certs.Manager to
verify the keys and certs on disk, rather than directly manipulating
the files themselves.  This way, if the exact implementation of
KeyFileStore or certs.Manager changes, this test won't fail so long
as KeyFileStore and certs.Manager are self-consistent.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-03 17:52:22 -08:00
Ying Li dbcb56b3bf Renamed keystoremanager to certs, and KeyStoreManager to Manager.
Since it no longer depends upon KeyStore, nor does it manipulate keys
in any way.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-11-23 17:19:26 -05:00
Ying Li 517763a26d Merge pull request #280 from docker/remove-get-root
Remove KeyStoreManager's dependency on a KeyStore.
2015-11-13 15:51:42 -08:00
Ying Li edf0520c9b Remove KeyStoreManager's dependency on a KeyStore.
The root generation code is handled by CryptoService now.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-11-13 15:00:45 -08:00
Ying Li 8432f9db07 Fixes client to report problems contacting the remote server.
Currently, when listing, publishing, or getting a particular target,
if the remote server errors, the client attempts to load it from a
local cache.  However, if there is no local cache, it just returns
Metadata Not Found for listing and getting.  Have it report the
remote the original remote error instead of Metadata Not Found
locally.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-11-13 05:26:00 -08:00