Example #1
0
class TestEncryption(DCSATestCase):
    def test_group_creator_should_be_able_to_enable_encryption_on_group_creation(self):
        self.c = Chat((Chat.DEFAULT_LISTEN_IP, getUnusedListenPort()))
        self.c.start()
        self._registerStartedChatSession(self.c)
        self.c.createGroup()
        self.c.turnOnEncryption()
       
        
    def test_should_create_cert_and_key_files(self):
        self.test_group_creator_should_be_able_to_enable_encryption_on_group_creation()
               
       
    def test_should_be_able_to_send_commands_to_other_peers_by_encryption_if_encryption_flag_enabled(self):
        self.test_group_creator_should_be_able_to_enable_encryption_on_group_creation()
        
        self.c2 = Chat((Chat.DEFAULT_LISTEN_IP, getUnusedListenPort()))
        self.c2.start()
        self.c2.turnOnEncryption()
        self._registerStartedChatSession(self.c2)
        self.c.addUser(self.c2.getListenAddress())
        time.sleep(0.2)
        self.c2_total_msgs = len(self.c2.getChannel().getMessages())
        self.c.sendMessage('hi')
       
        
    def test_should_be_able_to_receive_and_decode_commands_from_other_peers_by_encryption_if_encryption_flag_enabled(self):
        self.test_should_be_able_to_send_commands_to_other_peers_by_encryption_if_encryption_flag_enabled()
        time.sleep(0.1)
        self.assertEqual(self.c2_total_msgs + 1, len(self.c2.getChannel().getMessages()))