Esempio n. 1
0
 def test_regcommand_login_pass_no_session(self):
     message = {"class": "login_pass",
                "hashedpassword": "******"}
     cti_command = Command(self.conn, message)
     cti_command.ipbxid = 1
     cti_command.userid = 2
     self.assertEquals("login_password", cti_command.regcommand_login_pass())
Esempio n. 2
0
 def test_regcommand_login_pass_no_session(self):
     message = {"class": "login_pass", "hashedpassword": "******"}
     cti_command = Command(self.conn, message)
     cti_command.ipbxid = 1
     cti_command.userid = 2
     self.assertEquals("login_password",
                       cti_command.regcommand_login_pass())
Esempio n. 3
0
    def test_regcommand_getqueuesstats_one_queue(self, mock_queue):
        message = {
            "class": "getqueuesstats",
            "commandid": 1234,
            "on": {
                "3": {
                    "window": "3600",
                    "xqos": "60"
                }
            }
        }
        queueStatistics = Mock(QueueStatisticsManager)
        encoder = Mock(QueueStatisticsEncoder)
        cti_command = Command(self.conn, message)
        cti_command._queue_statistics_manager = queueStatistics
        cti_command._queue_statistics_encoder = encoder
        mock_queue.get_name_from_id.return_value = 'service'

        queueStatistics.get_statistics.return_value = queueStatistics
        statisticsToEncode = {'3': queueStatistics}

        encoder.encode.return_value = {
            'return value': {
                'value1': 'first stat'
            }
        }

        reply = cti_command.regcommand_getqueuesstats()
        self.assertEqual(reply, {'return value': {'value1': 'first stat'}})

        queueStatistics.get_statistics.assert_called_with('service', 60, 3600)
        encoder.encode.assert_called_with(statisticsToEncode)
Esempio n. 4
0
 def test_regcommand_login_pass_wrong_password(self):
     message = {"class": "login_pass",
                "hashedpassword": "******"}
     self.conn.connection_details = {'prelogin': {'sessionid': '1234'}}
     cti_command = Command(self.conn, message)
     cti_command.ipbxid = 1
     cti_command.userid = 2
     self._ctiserver.safe.user_get_hashed_password.return_value = "efgh"
     self.assertEquals("login_password", cti_command.regcommand_login_pass())
Esempio n. 5
0
 def test_regcommand_login_pass_wrong_password(self):
     message = {"class": "login_pass", "hashedpassword": "******"}
     self.conn.connection_details = {'prelogin': {'sessionid': '1234'}}
     cti_command = Command(self.conn, message)
     cti_command.ipbxid = 1
     cti_command.userid = 2
     self._ctiserver.safe.user_get_hashed_password.return_value = "efgh"
     self.assertEquals("login_password",
                       cti_command.regcommand_login_pass())
Esempio n. 6
0
 def test_regcommand_login_pass_no_profile(self, mock_get_profile):
     user_id = 2
     cti_profile_id = None
     message = {"class": "login_pass",
                "hashedpassword": "******"}
     self.conn.connection_details = {'prelogin': {'sessionid': '1234'}}
     cti_command = Command(self.conn, message)
     cti_command.ipbxid = 1
     cti_command.userid = user_id
     cti_command.user_keeplist = {
         'cti_profile_id': cti_profile_id
     }
     self._ctiserver.safe.user_get_hashed_password.return_value = "abcd"
     mock_get_profile.return_value = None
     self.assertEquals("capaid_undefined", cti_command.regcommand_login_pass())
Esempio n. 7
0
    def test_regcommand_getqueuesstats_one_queue(self, mock_queue):
        message = {"class": "getqueuesstats",
                   "commandid": 1234,
                   "on": {"3": {"window": "3600", "xqos": "60"}}}
        queueStatistics = Mock(QueueStatisticsManager)
        encoder = Mock(QueueStatisticsEncoder)
        cti_command = Command(self.conn, message)
        cti_command._queue_statistics_manager = queueStatistics
        cti_command._queue_statistics_encoder = encoder
        mock_queue.get_name_from_id.return_value = 'service'

        queueStatistics.get_statistics.return_value = queueStatistics
        statisticsToEncode = {'3': queueStatistics}

        encoder.encode.return_value = {'return value': {'value1': 'first stat'}}

        reply = cti_command.regcommand_getqueuesstats()
        self.assertEqual(reply, {'return value': {'value1': 'first stat'}})

        queueStatistics.get_statistics.assert_called_with('service', 60, 3600)
        encoder.encode.assert_called_with(statisticsToEncode)
Esempio n. 8
0
 def test_regcommand_login_pass_success(self, mock_get_profile):
     user_id = 2
     cti_profile_id = 3
     message = {"class": "login_pass", "hashedpassword": "******"}
     self.conn.connection_details = {'prelogin': {'sessionid': '1234'}}
     cti_command = Command(self.conn, message)
     cti_command.ipbxid = 1
     cti_command.userid = user_id
     cti_command.user_keeplist = {'cti_profile_id': cti_profile_id}
     self._ctiserver.safe.user_get_hashed_password.return_value = "abcd"
     mock_get_profile.return_value = cti_profile_id
     self.assertEquals({'capalist': [cti_profile_id]},
                       cti_command.regcommand_login_pass())
Esempio n. 9
0
 def test_regcommand_getqueuesstats_no_result(self):
     message = {}
     cti_command = Command(self.conn, message)
     self.assertEqual(cti_command.regcommand_getqueuesstats(), {},
                      'Default return an empty dict')
Esempio n. 10
0
 def test_regcommand_getqueuesstats_no_result(self):
     message = {}
     cti_command = Command(self.conn, message)
     self.assertEqual(cti_command.regcommand_getqueuesstats(), {},
                      'Default return an empty dict')