@@ -21,6 +21,10 @@ def get_client_cert():
21
21
return b"cert" , b"key"
22
22
23
23
24
+ def get_client_encrypted_cert ():
25
+ return "cert_path" , "key_path" , b"passphrase"
26
+
27
+
24
28
def test_constructor ():
25
29
26
30
options = client_options .ClientOptions (
@@ -31,6 +35,30 @@ def test_constructor():
31
35
assert options .client_cert_source () == (b"cert" , b"key" )
32
36
33
37
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
+
34
62
def test_from_dict ():
35
63
options = client_options .from_dict (
36
64
{"api_endpoint" : "foo.googleapis.com" , "client_cert_source" : get_client_cert }
@@ -57,6 +85,6 @@ def test_repr():
57
85
58
86
assert (
59
87
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'}"
62
90
)
0 commit comments