aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/google-auth/py3/tests/crypt/test__cryptography_rsa.py
diff options
context:
space:
mode:
authorAlexSm <alex@ydb.tech>2023-12-27 23:31:58 +0100
committerGitHub <noreply@github.com>2023-12-27 23:31:58 +0100
commitd67bfb4b4b7549081543e87a31bc6cb5c46ac973 (patch)
tree8674f2f1570877cb653e7ddcff37ba00288de15a /contrib/python/google-auth/py3/tests/crypt/test__cryptography_rsa.py
parent1f6bef05ed441c3aa2d565ac792b26cded704ac7 (diff)
downloadydb-d67bfb4b4b7549081543e87a31bc6cb5c46ac973.tar.gz
Import libs 4 (#758)
Diffstat (limited to 'contrib/python/google-auth/py3/tests/crypt/test__cryptography_rsa.py')
-rw-r--r--contrib/python/google-auth/py3/tests/crypt/test__cryptography_rsa.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/contrib/python/google-auth/py3/tests/crypt/test__cryptography_rsa.py b/contrib/python/google-auth/py3/tests/crypt/test__cryptography_rsa.py
index d19154b61b..2c4cebe0d7 100644
--- a/contrib/python/google-auth/py3/tests/crypt/test__cryptography_rsa.py
+++ b/contrib/python/google-auth/py3/tests/crypt/test__cryptography_rsa.py
@@ -14,6 +14,7 @@
import json
import os
+import pickle
from cryptography.hazmat.primitives.asymmetric import rsa
import pytest # type: ignore
@@ -23,8 +24,8 @@ from google.auth.crypt import _cryptography_rsa
from google.auth.crypt import base
-import yatest.common
-DATA_DIR = os.path.join(yatest.common.test_source_path(), "data")
+import yatest.common as yc
+DATA_DIR = os.path.join(os.path.dirname(yc.source_path(__file__)), "..", "data")
# To generate privatekey.pem, privatekey.pub, and public_cert.pem:
# $ openssl req -new -newkey rsa:1024 -x509 -nodes -out public_cert.pem \
@@ -160,3 +161,17 @@ class TestRSASigner(object):
assert signer.key_id == SERVICE_ACCOUNT_INFO[base._JSON_FILE_PRIVATE_KEY_ID]
assert isinstance(signer._key, rsa.RSAPrivateKey)
+
+ def test_pickle(self):
+ signer = _cryptography_rsa.RSASigner.from_service_account_file(
+ SERVICE_ACCOUNT_JSON_FILE
+ )
+
+ assert signer.key_id == SERVICE_ACCOUNT_INFO[base._JSON_FILE_PRIVATE_KEY_ID]
+ assert isinstance(signer._key, rsa.RSAPrivateKey)
+
+ pickled_signer = pickle.dumps(signer)
+ signer = pickle.loads(pickled_signer)
+
+ assert signer.key_id == SERVICE_ACCOUNT_INFO[base._JSON_FILE_PRIVATE_KEY_ID]
+ assert isinstance(signer._key, rsa.RSAPrivateKey)