@@ -576,6 +576,7 @@ def test_mongodb_x509_auth(self):
576
576
ssl = True ,
577
577
ssl_cert_reqs = ssl .CERT_NONE ,
578
578
ssl_certfile = CLIENT_PEM )
579
+ self .addCleanup (noauth .close )
579
580
580
581
self .assertRaises (OperationFailure , noauth .pymongo_test .test .count )
581
582
@@ -587,6 +588,7 @@ def test_mongodb_x509_auth(self):
587
588
ssl_cert_reqs = ssl .CERT_NONE ,
588
589
ssl_certfile = CLIENT_PEM ,
589
590
event_listeners = [listener ])
591
+ self .addCleanup (auth .close )
590
592
591
593
if client_context .version .at_least (3 , 3 , 12 ):
592
594
# No error
@@ -609,6 +611,7 @@ def test_mongodb_x509_auth(self):
609
611
ssl = True ,
610
612
ssl_cert_reqs = ssl .CERT_NONE ,
611
613
ssl_certfile = CLIENT_PEM )
614
+ self .addCleanup (client .close )
612
615
# No error
613
616
client .pymongo_test .test .find_one ()
614
617
@@ -617,6 +620,7 @@ def test_mongodb_x509_auth(self):
617
620
ssl = True ,
618
621
ssl_cert_reqs = ssl .CERT_NONE ,
619
622
ssl_certfile = CLIENT_PEM )
623
+ self .addCleanup (client .close )
620
624
if client_context .version .at_least (3 , 3 , 12 ):
621
625
# No error
622
626
client .pymongo_test .test .find_one ()
@@ -625,13 +629,16 @@ def test_mongodb_x509_auth(self):
625
629
with self .assertRaises (ConfigurationError ):
626
630
client .pymongo_test .test .find_one ()
627
631
632
+ # No error
633
+ client .pymongo_test .test .find_one ()
628
634
# Auth should fail if username and certificate do not match
629
635
uri = ('mongodb://%s@%s:%d/?authMechanism='
630
636
'MONGODB-X509' % (
631
637
quote_plus ("not the username" ), host , port ))
632
638
633
639
bad_client = MongoClient (
634
640
uri , ssl = True , ssl_cert_reqs = "CERT_NONE" , ssl_certfile = CLIENT_PEM )
641
+ self .addCleanup (bad_client .close )
635
642
636
643
with self .assertRaises (OperationFailure ):
637
644
bad_client .pymongo_test .test .find_one ()
@@ -643,6 +650,7 @@ def test_mongodb_x509_auth(self):
643
650
ssl = True ,
644
651
ssl_cert_reqs = ssl .CERT_NONE ,
645
652
ssl_certfile = CLIENT_PEM )
653
+ self .addCleanup (bad_client .close )
646
654
647
655
with self .assertRaises (OperationFailure ):
648
656
bad_client .pymongo_test .test .find_one ()
0 commit comments