@@ -625,6 +625,7 @@ def test_use_privatekey(self):
625625 """
626626 `Context.use_privatekey` takes an `OpenSSL.crypto.PKey` instance.
627627 """
628+ # Mirrored at TestConnection.test_use_privatekey
628629 key = PKey ()
629630 key .generate_key (TYPE_RSA , 1024 )
630631 ctx = Context (SSLv23_METHOD )
@@ -709,6 +710,7 @@ def test_use_certificate(self):
709710 `Context.use_certificate` sets the certificate which will be
710711 used to identify connections created using the context.
711712 """
713+ # Mirrored at TestConnection.test_use_certificate
712714 # TODO
713715 # Hard to assert anything. But we could set a privatekey then ask
714716 # OpenSSL if the cert and key agree using check_privatekey. Then as
@@ -2206,6 +2208,31 @@ def test_type(self):
22062208 ctx = Context (SSLv23_METHOD )
22072209 assert is_consistent_type (Connection , "Connection" , ctx , None )
22082210
2211+ def test_use_privatekey (self ):
2212+ """
2213+ `Connection.use_privatekey` takes an `OpenSSL.crypto.PKey` instance.
2214+ """
2215+ # Mirrored from TestContext.test_use_privatekey
2216+ key = PKey ()
2217+ key .generate_key (TYPE_RSA , 1024 )
2218+ ctx = Context (SSLv23_METHOD )
2219+ connection = Connection (ctx , None )
2220+ connection .use_privatekey (key )
2221+ with pytest .raises (TypeError ):
2222+ connection .use_privatekey ("" )
2223+
2224+ def test_use_certificate (self ):
2225+ """
2226+ `Connection.use_certificate` sets the certificate which will be
2227+ used to identify connections created using the context.
2228+ """
2229+ # Mirrored from TestContext.test_use_certificate
2230+ ctx = Context (SSLv23_METHOD )
2231+ connection = Connection (ctx , None )
2232+ connection .use_certificate (
2233+ load_certificate (FILETYPE_PEM , root_cert_pem )
2234+ )
2235+
22092236 @pytest .mark .parametrize ("bad_context" , [object (), "context" , None , 1 ])
22102237 def test_wrong_args (self , bad_context ):
22112238 """
0 commit comments