diff options
author | drebs <drebs@leap.se> | 2016-09-06 14:55:27 -0400 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2016-09-06 14:55:27 -0400 |
commit | dd9c8278379df9f41c5a40dc6bccd2901cf4db10 (patch) | |
tree | 87175df9156a493f74ca3ad68829246af5ebb9e2 /bench/keymanager/conftest.py | |
parent | 1f6f24540bae5b21cabb69b4f50cca7cddb8f784 (diff) |
[test] add speed tests for gpg/wrapper init/enc/dec
this is a port of commit 2d9bec78f in the legacy keymanager repo.
Additionally, I'm here separating benchmarking tests from the main tox
run.
In my machine several of these benchmarking tests seem to be broken, due
to issue https://github.com/isislovecruft/python-gnupg/issues/157
Diffstat (limited to 'bench/keymanager/conftest.py')
-rw-r--r-- | bench/keymanager/conftest.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/bench/keymanager/conftest.py b/bench/keymanager/conftest.py new file mode 100644 index 00000000..b7d8b507 --- /dev/null +++ b/bench/keymanager/conftest.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +# conftest.py +# Copyright (C) 2016 LEAP Encryption Acess Project +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +""" +Fixtures for the benchmarks for leap.bitmask.keymanager +""" + +import pytest + +from leap.bitmask.keymanager.keys import build_key_from_dict +from leap.bitmask.keymanager.wrapper import TempGPGWrapper + +from common import ADDRESS +from common import KEY_FINGERPRINT +from common import PUBLIC_KEY +from common import PRIVATE_KEY +from common import ADDRESS_2 +from common import KEY_FINGERPRINT_2 +from common import PUBLIC_KEY_2 +from common import PRIVATE_KEY_2 + + +@pytest.fixture +def wrapper(keys=None): + return TempGPGWrapper(keys=keys) + + +def _get_key(address, key_fingerprint, key_data, private): + kdict = { + 'uids': [address], + 'fingerprint': key_fingerprint, + 'key_data': key_data, + 'private': private, + 'length': 4096, + 'expiry_date': 0, + 'refreshed_at': 1311239602, + } + key = build_key_from_dict(kdict) + return key + + +@pytest.fixture +def public_key(): + return _get_key(ADDRESS, KEY_FINGERPRINT, PUBLIC_KEY, False) + + +@pytest.fixture +def public_key_2(): + return _get_key(ADDRESS_2, KEY_FINGERPRINT_2, PUBLIC_KEY_2, False) + + +@pytest.fixture +def openpgp_keys(): + return [ + _get_key(ADDRESS, KEY_FINGERPRINT, PUBLIC_KEY, False), + _get_key(ADDRESS_2, KEY_FINGERPRINT_2, PUBLIC_KEY_2, False), + _get_key(ADDRESS, KEY_FINGERPRINT, PRIVATE_KEY, True), + _get_key(ADDRESS_2, KEY_FINGERPRINT_2, PRIVATE_KEY_2, True), + ] |