diff options
author | arithmetic1728 <58957152+arithmetic1728@users.noreply.github.com> | 2020-05-27 16:07:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-27 16:07:49 -0700 |
commit | e4eaec0ff255114138d3715280f86d34d861a6fa (patch) | |
tree | 671fb072fa60eef4360a31902b41d378a238a4e0 /tests | |
parent | a82f2892b8f219b82e120e6ed9f4070869c28be7 (diff) | |
download | python-api-core-e4eaec0ff255114138d3715280f86d34d861a6fa.tar.gz |
feat: add client_encryped_cert_source to ClientOptions (#31)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_client_options.py | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/unit/test_client_options.py b/tests/unit/test_client_options.py index 7f17544..67c4f6b 100644 --- a/tests/unit/test_client_options.py +++ b/tests/unit/test_client_options.py @@ -21,6 +21,10 @@ def get_client_cert(): return b"cert", b"key" +def get_client_encrypted_cert(): + return "cert_path", "key_path", b"passphrase" + + def test_constructor(): options = client_options.ClientOptions( @@ -31,6 +35,30 @@ def test_constructor(): assert options.client_cert_source() == (b"cert", b"key") +def test_constructor_with_encrypted_cert_source(): + + options = client_options.ClientOptions( + api_endpoint="foo.googleapis.com", + client_encrypted_cert_source=get_client_encrypted_cert, + ) + + assert options.api_endpoint == "foo.googleapis.com" + assert options.client_encrypted_cert_source() == ( + "cert_path", + "key_path", + b"passphrase", + ) + + +def test_constructor_with_both_cert_sources(): + with pytest.raises(ValueError): + client_options.ClientOptions( + api_endpoint="foo.googleapis.com", + client_cert_source=get_client_cert, + client_encrypted_cert_source=get_client_encrypted_cert, + ) + + def test_from_dict(): options = client_options.from_dict( {"api_endpoint": "foo.googleapis.com", "client_cert_source": get_client_cert} @@ -57,6 +85,6 @@ def test_repr(): assert ( repr(options) - == "ClientOptions: {'api_endpoint': 'foo.googleapis.com', 'client_cert_source': None}" - or "ClientOptions: {'client_cert_source': None, 'api_endpoint': 'foo.googleapis.com'}" + == "ClientOptions: {'api_endpoint': 'foo.googleapis.com', 'client_cert_source': None, 'client_encrypted_cert_source': None}" + or "ClientOptions: {'client_encrypted_cert_source': None, 'client_cert_source': None, 'api_endpoint': 'foo.googleapis.com'}" ) |