@@ -21,6 +21,10 @@ def get_client_cert():
2121 return b"cert" , b"key"
2222
2323
24+ def get_client_encrypted_cert ():
25+ return "cert_path" , "key_path" , b"passphrase"
26+
27+
2428def test_constructor ():
2529
2630 options = client_options .ClientOptions (
@@ -31,6 +35,30 @@ def test_constructor():
3135 assert options .client_cert_source () == (b"cert" , b"key" )
3236
3337
38+ def test_constructor_with_encrypted_cert_source ():
39+
40+ options = client_options .ClientOptions (
41+ api_endpoint = "foo.googleapis.com" ,
42+ client_encrypted_cert_source = get_client_encrypted_cert ,
43+ )
44+
45+ assert options .api_endpoint == "foo.googleapis.com"
46+ assert options .client_encrypted_cert_source () == (
47+ "cert_path" ,
48+ "key_path" ,
49+ b"passphrase" ,
50+ )
51+
52+
53+ def test_constructor_with_both_cert_sources ():
54+ with pytest .raises (ValueError ):
55+ client_options .ClientOptions (
56+ api_endpoint = "foo.googleapis.com" ,
57+ client_cert_source = get_client_cert ,
58+ client_encrypted_cert_source = get_client_encrypted_cert ,
59+ )
60+
61+
3462def test_from_dict ():
3563 options = client_options .from_dict (
3664 {"api_endpoint" : "foo.googleapis.com" , "client_cert_source" : get_client_cert }
@@ -57,6 +85,6 @@ def test_repr():
5785
5886 assert (
5987 repr (options )
60- == "ClientOptions: {'api_endpoint': 'foo.googleapis.com', 'client_cert_source': None}"
61- or "ClientOptions: {'client_cert_source': None, 'api_endpoint': 'foo.googleapis.com'}"
88+ == "ClientOptions: {'api_endpoint': 'foo.googleapis.com', 'client_cert_source': None, 'client_encrypted_cert_source': None }"
89+ or "ClientOptions: {'client_encrypted_cert_source': None, ' client_cert_source': None, 'api_endpoint': 'foo.googleapis.com'}"
6290 )
0 commit comments