forked from pypi/warehouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: TUF Initialization using python-tuf 1.0.0
This work refactors the [Draft PR](pypi#7488) by @ woodruffw, to build a new repository tool on top of the Python-TUF Metadata API, and use it instead of the Python-TUF repository tool that was deprecated in v1.0.0. Part of pypi#10672 Signed-off-by: Kairo de Araujo <[email protected]>
- Loading branch information
Kairo de Araujo
committed
Aug 22, 2022
1 parent
25317ae
commit e84ef31
Showing
37 changed files
with
1,522 additions
and
700 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import pretend | ||
|
||
from zope.interface.verify import verifyClass | ||
|
||
from warehouse.tuf.interfaces import IKeyService | ||
from warehouse.tuf.services import LocalKeyService | ||
|
||
|
||
class TestLocalLocalKeyService: | ||
def test_verify_service(self): | ||
assert verifyClass(IKeyService, LocalKeyService) | ||
|
||
def test_create_service(self): | ||
request = pretend.stub( | ||
registry=pretend.stub(settings={"tuf.key.path": "/tuf/key/path/"}) | ||
) | ||
service = LocalKeyService.create_service(None, request) | ||
assert service._key_path == "/tuf/key/path/" | ||
|
||
def test_basic_init(self, db_request): | ||
service = LocalKeyService("/opt/warehouse/src/dev/tufkeys", db_request) | ||
assert service._key_path == "/opt/warehouse/src/dev/tufkeys" | ||
|
||
def test_get_private_key(self, db_request, monkeypatch): | ||
service = LocalKeyService("/opt/warehouse/src/dev/tufkeys", db_request) | ||
|
||
expected_priv_key_dict = { | ||
"keytype": "ed25519", | ||
"scheme": "ed25519", | ||
"keyval": {"public": "720a9a588deefd5...4d08984e87bfc5a18f34618e438434c7"}, | ||
"keyid": "2de4eb9afe9fb73...2235d3418bd63f4214d3ba7d23b516f23e", | ||
"keyid_hash_algorithms": ["sha256", "sha512"], | ||
} | ||
db_request.registry.settings["tuf.root.secret"] = "tuf.root.secret" | ||
monkeypatch.setattr( | ||
"warehouse.tuf.services.import_ed25519_privatekey_from_file", | ||
lambda *a, **kw: expected_priv_key_dict, | ||
) | ||
|
||
root_keyid = service.get("root", "private") | ||
|
||
assert root_keyid == [expected_priv_key_dict] |
Oops, something went wrong.