Пример #1
0
    def test_serial_change(self) -> None:
        manager = self._get_manager()
        ip = "192.168.60.145"

        # Send an Inform
        ctx1 = get_spyne_context_with_ip(ip)
        inform_msg = Tr069MessageBuilder.get_inform('48BF74',
                                                    'BaiBS_RTS_3.1.6',
                                                    '120200002618AGP0001')
        resp1 = manager.handle_tr069_message(ctx1, inform_msg)
        self.assertTrue(isinstance(resp1, models.InformResponse),
                        'Should respond with an InformResponse')
        handler1 = manager.get_handler_by_ip(ip)

        # Send an Inform from the same serial, but different IP
        ctx2 = get_spyne_context_with_ip(ip)
        inform_msg = Tr069MessageBuilder.get_inform('48BF74',
                                                    'BaiBS_RTS_3.1.6',
                                                    '120200002618AGP0002')
        resp2 = manager.handle_tr069_message(ctx2, inform_msg)
        self.assertTrue(isinstance(resp2, models.InformResponse),
                        'Should respond with an InformResponse')
        handler2 = manager.get_handler_by_ip(ip)

        # Now check that the serial is associated with the second ip
        self.assertTrue((handler1 is not handler2),
                        'After an IP switch, the manager should have moved '
                        'the handler to a new IP')
Пример #2
0
    def test_handle_registered_enb(self):
        """
        When we have a config with eNB registered per serial, we should accept
        TR-069 sessions from any registered eNB, and ereject from unregistered
        eNB devices.
        """
        manager = self._get_manager_multi_enb()
        ip1 = "192.168.60.145"
        ctx1 = get_spyne_context_with_ip(ip1)
        inform_msg = Tr069MessageBuilder.get_inform('48BF74',
                                                    'BaiBS_RTS_3.1.6',
                                                    '120200002618AGP0003')
        resp1 = manager.handle_tr069_message(ctx1, inform_msg)
        self.assertTrue(isinstance(resp1, models.InformResponse),
                        'Should respond with an InformResponse')

        ip2 = "192.168.60.146"
        ctx2 = get_spyne_context_with_ip(ip2)
        inform_msg = Tr069MessageBuilder.get_inform('48BF74',
                                                    'BaiBS_RTS_3.1.6',
                                                    'unregistered_ip')

        resp2 = manager.handle_tr069_message(ctx2, inform_msg)
        self.assertTrue(isinstance(resp2, models.DummyInput),
                        'Should respond with an empty HTTP response')
Пример #3
0
    def test_get_service_status_old(self):
        manager = self._get_manager()
        status = get_service_status_old(manager)
        self.assertTrue(
            status['enodeb_connected'] == '0',
            'Should report no eNB connected',
        )

        ##### Start session for the first IP #####
        ctx1 = get_spyne_context_with_ip("192.168.60.145")
        # Send an Inform message, wait for an InformResponse
        inform_msg = Tr069MessageBuilder.get_inform(
            '48BF74',
            'BaiBS_RTS_3.1.6',
            '120200002618AGP0001',
        )
        manager.handle_tr069_message(ctx1, inform_msg)
        status = get_service_status_old(manager)
        self.assertTrue(
            status['enodeb_connected'] == '1',
            'Should report an eNB as conencted',
        )
        self.assertTrue(
            status['enodeb_serial'] == '120200002618AGP0001',
            'eNodeB serial should match the earlier Inform',
        )
Пример #4
0
    def test_serial_not_found(self):
        """
        Test that the SM manager doesn't crash if serial number is not found
        in an Inform message under any expected param path.
        """
        manager = self._get_manager()
        ctx = get_spyne_context_with_ip("192.168.60.145")
        inform_msg = models.Inform(
            DeviceId=models.DeviceIdStruct(
                Manufacturer='Unused',
                OUI='48BF74',
                ProductClass='Unused',
            ),
            Event=models.EventList(EventStruct=[]),
            ParameterList=models.ParameterValueList(ParameterValueStruct=[
                Tr069MessageBuilder.get_parameter_value_struct(
                    name='Device.DeviceInfo.HardwareVersion',
                    val_type='string',
                    data='VER.C',
                ),
                Tr069MessageBuilder.get_parameter_value_struct(
                    name='Device.DeviceInfo.ManufacturerOUI',
                    val_type='string',
                    data='48BF74',
                ),
                Tr069MessageBuilder.get_parameter_value_struct(
                    name='Device.DeviceInfo.SoftwareVersion',
                    val_type='string',
                    data='BaiBS_RTS_3.1.6',
                ),
            ]))

        # No exception should be thrown, and we should return an empty response
        resp = manager.handle_tr069_message(ctx, inform_msg)
        self.assertTrue(isinstance(resp, models.DummyInput))
Пример #5
0
    def test_handle_one_ip(self):
        manager = self._get_manager()

        # Send in an Inform message, and we should get an InformResponse
        ctx = get_spyne_context_with_ip()
        inform = Tr069MessageBuilder.get_inform()
        req = manager.handle_tr069_message(ctx, inform)
        self.assertTrue(isinstance(req, models.InformResponse),
                        'State machine handler should reply with an '
                        'InformResponse')
Пример #6
0
    def test_inform_from_baicells_qafb(self) -> None:
        manager = self._get_manager()
        ip = "192.168.60.145"

        # Send an Inform
        ctx1 = get_spyne_context_with_ip(ip)
        inform_msg = Tr069MessageBuilder.get_qafb_inform(
            '48BF74', 'BaiBS_QAFB_v1234', '120200002618AGP0001')
        resp1 = manager.handle_tr069_message(ctx1, inform_msg)
        self.assertTrue(isinstance(resp1, models.InformResponse),
                        'Should respond with an InformResponse')
Пример #7
0
    def test_inform_from_unrecognized(self) -> None:
        manager = self._get_manager()
        ip = "192.168.60.145"

        # Send an Inform
        ctx1 = get_spyne_context_with_ip(ip)
        inform_msg = Tr069MessageBuilder.get_qafb_inform(
            '48BF74', 'Unrecognized device', '120200002618AGP0001')
        resp1 = manager.handle_tr069_message(ctx1, inform_msg)
        self.assertTrue(
            isinstance(resp1, models.DummyInput),
            'Should end provisioninng session with empty response')
Пример #8
0
 def test_get_single_enb_status(self):
     manager = self._get_manager()
     ctx1 = get_spyne_context_with_ip("192.168.60.145")
     inform_msg = Tr069MessageBuilder.get_inform('48BF74',
                                                 'BaiBS_RTS_3.1.6',
                                                 '120200002618AGP0001')
     manager.handle_tr069_message(ctx1, inform_msg)
     status = get_single_enb_status('120200002618AGP0001', manager)
     self.assertEquals(status.connected,
                       SingleEnodebStatus.StatusProperty.Value('ON'),
                       'Status should be connected.')
     self.assertEquals(status.configured,
                       SingleEnodebStatus.StatusProperty.Value('OFF'),
                       'Status should be not configured.')
Пример #9
0
    def test_get_enodeb_all_status(self):
        manager = self._get_manager()

        ##### Test Empty #####
        enb_status_by_serial = get_all_enb_status(manager)
        self.assertTrue(enb_status_by_serial == {}, "No eNB connected")

        ##### Start session for the first IP #####
        ctx1 = get_spyne_context_with_ip("192.168.60.145")
        # Send an Inform message, wait for an InformResponse
        inform_msg = Tr069MessageBuilder.get_inform('48BF74',
                                                    'BaiBS_RTS_3.1.6',
                                                    '120200002618AGP0001')
        manager.handle_tr069_message(ctx1, inform_msg)
        enb_status_by_serial = get_all_enb_status(manager)
        enb_status = enb_status_by_serial.get('120200002618AGP0001')
        self.assertTrue(enb_status.enodeb_connected)
Пример #10
0
    def test_handle_two_ips(self):
        manager = self._get_manager()
        ctx1 = get_spyne_context_with_ip("192.168.60.145")
        ctx2 = get_spyne_context_with_ip("192.168.60.99")

        ##### Start session for the first IP #####
        # Send an Inform message, wait for an InformResponse
        inform_msg = Tr069MessageBuilder.get_inform('48BF74',
                                                    'BaiBS_RTS_3.1.6',
                                                    '120200002618AGP0001')
        resp1 = manager.handle_tr069_message(ctx1, inform_msg)
        self.assertTrue(isinstance(resp1, models.InformResponse),
                        'Should respond with an InformResponse')

        # Send an empty http request to kick off the rest of provisioning
        req1 = models.DummyInput()
        resp1 = manager.handle_tr069_message(ctx1, req1)

        # Expect a request for an optional parameter, three times
        self.assertTrue(isinstance(resp1, models.GetParameterValues),
                        'State machine should be requesting param values')
        req1 = Tr069MessageBuilder.get_fault()
        resp1 = manager.handle_tr069_message(ctx1, req1)
        self.assertTrue(isinstance(resp1, models.GetParameterValues),
                        'State machine should be requesting param values')

        ##### Start session for the second IP #####
        # Send an Inform message, wait for an InformResponse
        inform_msg = Tr069MessageBuilder.get_inform('48BF74',
                                                    'BaiBS_RTS_3.1.6',
                                                    '120200002618AGP0002')
        resp2 = manager.handle_tr069_message(ctx2, inform_msg)
        self.assertTrue(isinstance(resp2, models.InformResponse),
                        'Should respond with an InformResponse')

        ##### Continue session for the first IP #####
        req1 = Tr069MessageBuilder.get_fault()
        resp1 = manager.handle_tr069_message(ctx1, req1)
        self.assertTrue(isinstance(resp1, models.GetParameterValues),
                        'State machine should be requesting param values')
        req1 = Tr069MessageBuilder.get_fault()
        resp1 = manager.handle_tr069_message(ctx1, req1)
        # Expect a request for read-only params
        self.assertTrue(isinstance(resp1, models.GetParameterValues),
                        'State machine should be requesting param values')

        ##### Continue session for the second IP #####
        # Send an empty http request to kick off the rest of provisioning
        req2 = models.DummyInput()
        resp2 = manager.handle_tr069_message(ctx2, req2)
        # Expect a request for an optional parameter, three times
        self.assertTrue(isinstance(resp2, models.GetParameterValues),
                        'State machine should be requesting param values')
        req2 = Tr069MessageBuilder.get_fault()
        resp2 = manager.handle_tr069_message(ctx2, req2)
        self.assertTrue(isinstance(resp2, models.GetParameterValues),
                        'State machine should be requesting param values')
        req2 = Tr069MessageBuilder.get_fault()
        resp2 = manager.handle_tr069_message(ctx2, req2)
        self.assertTrue(isinstance(resp2, models.GetParameterValues),
                        'State machine should be requesting param values')
        req2 = Tr069MessageBuilder.get_fault()
        resp2 = manager.handle_tr069_message(ctx2, req2)
        # Expect a request for read-only params
        self.assertTrue(isinstance(resp2, models.GetParameterValues),
                        'State machine should be requesting param values')