Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_ftplib.TestTLS_FTPClass Class Reference
Inheritance diagram for test.test_ftplib.TestTLS_FTPClass:
Inheritance graph
[legend]
Collaboration diagram for test.test_ftplib.TestTLS_FTPClass:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def tearDown
def test_control_connection
def test_data_connection
def test_login
def test_auth_issued_twice
def test_auth_ssl
def test_context

Public Attributes

 server
 client

Detailed Description

Specific TLS_FTP class tests.

Definition at line 686 of file test_ftplib.py.


Member Function Documentation

Definition at line 689 of file test_ftplib.py.

00689 
00690     def setUp(self):
00691         self.server = DummyTLS_FTPServer((HOST, 0))
00692         self.server.start()
00693         self.client = ftplib.FTP_TLS(timeout=10)
00694         self.client.connect(self.server.host, self.server.port)

Here is the caller graph for this function:

Definition at line 695 of file test_ftplib.py.

00695 
00696     def tearDown(self):
00697         self.client.close()
00698         self.server.stop()

Here is the caller graph for this function:

Definition at line 730 of file test_ftplib.py.

00730 
00731     def test_auth_issued_twice(self):
00732         self.client.auth()
00733         self.assertRaises(ValueError, self.client.auth)

Here is the call graph for this function:

Definition at line 734 of file test_ftplib.py.

00734 
00735     def test_auth_ssl(self):
00736         try:
00737             self.client.ssl_version = ssl.PROTOCOL_SSLv3
00738             self.client.auth()
00739             self.assertRaises(ValueError, self.client.auth)
00740         finally:
00741             self.client.ssl_version = ssl.PROTOCOL_TLSv1

Here is the call graph for this function:

Definition at line 742 of file test_ftplib.py.

00742 
00743     def test_context(self):
00744         self.client.quit()
00745         ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
00746         self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE,
00747                           context=ctx)
00748         self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
00749                           context=ctx)
00750         self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
00751                           keyfile=CERTFILE, context=ctx)
00752 
00753         self.client = ftplib.FTP_TLS(context=ctx, timeout=10)
00754         self.client.connect(self.server.host, self.server.port)
00755         self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
00756         self.client.auth()
00757         self.assertIs(self.client.sock.context, ctx)
00758         self.assertIsInstance(self.client.sock, ssl.SSLSocket)
00759 
00760         self.client.prot_p()
00761         with self.client.transfercmd('list') as sock:
00762             self.assertIs(sock.context, ctx)
00763             self.assertIsInstance(sock, ssl.SSLSocket)
00764 

Here is the call graph for this function:

Definition at line 699 of file test_ftplib.py.

00699 
00700     def test_control_connection(self):
00701         self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
00702         self.client.auth()
00703         self.assertIsInstance(self.client.sock, ssl.SSLSocket)

Here is the call graph for this function:

Definition at line 704 of file test_ftplib.py.

00704 
00705     def test_data_connection(self):
00706         # clear text
00707         with self.client.transfercmd('list') as sock:
00708             self.assertNotIsInstance(sock, ssl.SSLSocket)
00709         self.assertEqual(self.client.voidresp(), "226 transfer complete")
00710 
00711         # secured, after PROT P
00712         self.client.prot_p()
00713         with self.client.transfercmd('list') as sock:
00714             self.assertIsInstance(sock, ssl.SSLSocket)
00715         self.assertEqual(self.client.voidresp(), "226 transfer complete")
00716 
00717         # PROT C is issued, the connection must be in cleartext again
00718         self.client.prot_c()
00719         with self.client.transfercmd('list') as sock:
00720             self.assertNotIsInstance(sock, ssl.SSLSocket)
00721         self.assertEqual(self.client.voidresp(), "226 transfer complete")

Here is the call graph for this function:

Definition at line 722 of file test_ftplib.py.

00722 
00723     def test_login(self):
00724         # login() is supposed to implicitly secure the control connection
00725         self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
00726         self.client.login()
00727         self.assertIsInstance(self.client.sock, ssl.SSLSocket)
00728         # make sure that AUTH TLS doesn't get issued again
00729         self.client.login()

Here is the call graph for this function:


Member Data Documentation

Definition at line 692 of file test_ftplib.py.

Definition at line 690 of file test_ftplib.py.


The documentation for this class was generated from the following file: