@@ -965,100 +965,5 @@ def test_ssl_verified(self):
965
965
client .shutdown ()
966
966
967
967
968
- @unittest .skipUnless (
969
- support .is_resource_enabled ('network' ), 'network resource disabled' )
970
- @unittest .skip ('cyrus.andrew.cmu.edu blocks connections' )
971
- class RemoteIMAPTest (unittest .TestCase ):
972
- host = 'cyrus.andrew.cmu.edu'
973
- port = 143
974
- username = 'anonymous'
975
- password = 'pass'
976
- imap_class = imaplib .IMAP4
977
-
978
- def setUp (self ):
979
- with socket_helper .transient_internet (self .host ):
980
- self .server = self .imap_class (self .host , self .port )
981
-
982
- def tearDown (self ):
983
- if self .server is not None :
984
- with socket_helper .transient_internet (self .host ):
985
- self .server .logout ()
986
-
987
- def test_logincapa (self ):
988
- with socket_helper .transient_internet (self .host ):
989
- for cap in self .server .capabilities :
990
- self .assertIsInstance (cap , str )
991
- self .assertIn ('LOGINDISABLED' , self .server .capabilities )
992
- self .assertIn ('AUTH=ANONYMOUS' , self .server .capabilities )
993
- rs = self .server .login (self .username , self .password )
994
- self .assertEqual (rs [0 ], 'OK' )
995
-
996
- def test_logout (self ):
997
- with socket_helper .transient_internet (self .host ):
998
- rs = self .server .logout ()
999
- self .server = None
1000
- self .assertEqual (rs [0 ], 'BYE' , rs )
1001
-
1002
-
1003
- @unittest .skipUnless (ssl , "SSL not available" )
1004
- @unittest .skipUnless (
1005
- support .is_resource_enabled ('network' ), 'network resource disabled' )
1006
- @unittest .skip ('cyrus.andrew.cmu.edu blocks connections' )
1007
- class RemoteIMAP_STARTTLSTest (RemoteIMAPTest ):
1008
-
1009
- def setUp (self ):
1010
- super ().setUp ()
1011
- with socket_helper .transient_internet (self .host ):
1012
- rs = self .server .starttls ()
1013
- self .assertEqual (rs [0 ], 'OK' )
1014
-
1015
- def test_logincapa (self ):
1016
- for cap in self .server .capabilities :
1017
- self .assertIsInstance (cap , str )
1018
- self .assertNotIn ('LOGINDISABLED' , self .server .capabilities )
1019
-
1020
-
1021
- @unittest .skipUnless (ssl , "SSL not available" )
1022
- @unittest .skip ('cyrus.andrew.cmu.edu blocks connections' )
1023
- class RemoteIMAP_SSLTest (RemoteIMAPTest ):
1024
- port = 993
1025
- imap_class = IMAP4_SSL
1026
-
1027
- def setUp (self ):
1028
- pass
1029
-
1030
- def tearDown (self ):
1031
- pass
1032
-
1033
- def create_ssl_context (self ):
1034
- ssl_context = ssl .SSLContext (ssl .PROTOCOL_TLS_CLIENT )
1035
- ssl_context .check_hostname = False
1036
- ssl_context .verify_mode = ssl .CERT_NONE
1037
- ssl_context .load_cert_chain (CERTFILE )
1038
- return ssl_context
1039
-
1040
- def check_logincapa (self , server ):
1041
- try :
1042
- for cap in server .capabilities :
1043
- self .assertIsInstance (cap , str )
1044
- self .assertNotIn ('LOGINDISABLED' , server .capabilities )
1045
- self .assertIn ('AUTH=PLAIN' , server .capabilities )
1046
- rs = server .login (self .username , self .password )
1047
- self .assertEqual (rs [0 ], 'OK' )
1048
- finally :
1049
- server .logout ()
1050
-
1051
- def test_logincapa (self ):
1052
- with socket_helper .transient_internet (self .host ):
1053
- _server = self .imap_class (self .host , self .port )
1054
- self .check_logincapa (_server )
1055
-
1056
- def test_logout (self ):
1057
- with socket_helper .transient_internet (self .host ):
1058
- _server = self .imap_class (self .host , self .port )
1059
- rs = _server .logout ()
1060
- self .assertEqual (rs [0 ], 'BYE' , rs )
1061
-
1062
-
1063
968
if __name__ == "__main__" :
1064
969
unittest .main ()
0 commit comments