Beispiel #1
0
    def test_client(self):
        from kismon.client_rest import RestClient, RestClientThread, encode_cryptset, decode_cryptset

        client = RestClient()
        client.uri = "invalid:xyz"
        client.start()

        client = RestClient()
        errors = 0

        crypt_test = [
            (0, "none"),
            (2, "WEP"),
            (226, "WEP,TKIP,WPA,PSK"),
            (706, "WEP,WPA,PSK,AES_CCM"),
            (738, "WEP,TKIP,WPA,PSK,AES_CCM"),
        ]
        for cryptset, result in crypt_test:
            crypt_str = decode_cryptset(cryptset, True)
            if crypt_str != result:
                print("decode_cryptset error: %s\n%s!=%s" %
                      (cryptset, crypt_str, result))

            test_cryptset = encode_cryptset(crypt_str.lower().split(","))
            if test_cryptset != cryptset:
                print("encode_cryptset error: %s\n%s!=%s" %
                      (crypt_str, test_cryptset, cryptset))

        if errors != 0:
            sys.exit("client test failed, %s errors" % errors)

        client_thread = RestClientThread()
        client_thread.client = client
Beispiel #2
0
 def test_gui_channel_window(self):
     from kismon.gui import ChannelWindow
     from kismon.client_rest import RestClientThread
     sources = {
         "123": {
             "uuid": "123",
             "hop": 3,
             "name": "wlan0",
             "hop_rate": 3,
             "channel": 1
         },
         "234": {
             "uuid": "234",
             "hop": 0,
             "name": "wlan1",
             "hop_rate": 3,
             "channel": 6
         }
     }
     client_thread = RestClientThread()
     channel_window = ChannelWindow(sources, client_thread, parent=None)
     test_widget = TestWidget()
     channel_window.on_change_mode(test_widget, "123", "hop")
     channel_window.on_change_mode(test_widget, "123", "lock")
     channel_window.on_change_value(None, "123", "hop")
     channel_window.on_cancel(None)
     channel_window.on_apply(None)
Beispiel #3
0
    def test_datasources_window(self):
        from gi.repository import Gtk
        from kismon.gui import DatasourcesWindow
        from kismon.client_rest import RestClientThread

        test_networks = networks()

        def dummy_datasources():
            return kismon.test_data.available_datasources

        test_window = Gtk.Window()
        client_thread = RestClientThread(logger=logger)
        client_thread.client.get_available_datasources = dummy_datasources
        datasources_window = DatasourcesWindow(client_thread,
                                               parent=test_window)
        datasources_window.on_refresh()
        datasources_window.on_destroy()
Beispiel #4
0
    def test_gui_main_window(self):
        from gi.repository import Gtk
        from kismon.config import Config
        from kismon.map import Map
        from kismon.gui import MainWindow
        from kismon.client_rest import RestClientThread
        from kismon.tracks import Tracks

        def dummy(server_id):
            return

        test_widget = TestWidget()

        test_config = Config(None).default_config
        test_map = Map(test_config["map"])
        test_networks = networks()
        test_client_threads = {0: RestClientThread()}
        tmp_tracks_file = "%s%stest-tracks-%s.json" % (
            tempfile.gettempdir(), os.sep, int(time.time()))
        test_tracks = Tracks(tmp_tracks_file)
        main_window = MainWindow(test_config, dummy, dummy, test_map,
                                 test_networks, test_tracks, {
                                     0: None,
                                     1: None
                                 }, test_client_threads)
        main_window.network_list.crypt_cache = {}

        main_window.log_list.add("Kismon", "test")
        main_window.network_list.add_network('11:22:33:44:55:66')
        main_window.network_list.network_selected = '11:22:33:44:55:66'
        main_window.network_list.add_network('00:12:2A:03:B9:12')
        main_window.network_list.add_network('00:12:2A:03:B9:12')
        main_window.network_list.column_selected = 2
        main_window.network_list.on_copy_field(None)
        main_window.network_list.on_copy_network(None)
        main_window.network_list.on_comment_editing_done(test_widget)
        main_window.network_list.remove_network('00:12:2A:03:B9:12')
        main_window.server_tabs[0].update_info_table({
            "networks": 100,
            "packets": 200
        })
        main_window.server_tabs[0].update_gps_table(fix=3, lat=52.0, lon=13.0)
        sources = {
            "1": {
                "uuid": "1",
                "name": "test",
                "type": "bla",
                "channel": 11,
                "packets": 100
            }
        }
        main_window.server_tabs[0].update_sources_table(sources)
        main_window.on_configure_event(None, None)
        main_window.on_config_window(None)
        main_window.on_config_window(None)
        main_window.on_signal_graph(None)
        main_window.on_signal_graph_destroy(None, "11:22:33:44:55:66")
        main_window.fullscreen()
        main_window.fullscreen()
        main_window.on_map_window(None, True)
        main_window.on_map_window(None, False)
        main_window.on_map_widget(None, True)
        main_window.on_map_widget(None, False)
        # main_window.on_server_disconnect(None, 0)
        test_event = TestEvent()
        main_window.on_window_state(None, test_event)

        config_window = main_window.config_window

        main_window.on_file_import(None)

        test_widget.text = "Infrastructure"
        main_window.filter_tab.on_network_filter(test_widget, 'filter_type',
                                                 'infrastructure')
        main_window.filter_tab.on_toggle_limiter(test_widget, 'map', 'all')
Beispiel #5
0
    def test_gui_main_window(self):
        from gi.repository import Gtk
        from kismon.config import Config
        from kismon.map import Map
        from kismon.gui import MainWindow
        from kismon.client_rest import RestClientThread
        from kismon.tracks import Tracks

        def dummy(server_id):
            return

        test_widget = TestWidget()

        test_config = Config(None, logger=logger).default_config
        test_map = Map(test_config["map"], logger=logger)
        test_networks = networks()
        test_networks.networks['00:12:2A:03:B9:12'][
            'servers'] = "http://127.0.0.1:2501"
        test_client_threads = {0: RestClientThread(logger=logger)}
        tmp_tracks_file = "%s%stest-tracks-%s.json" % (
            tempfile.gettempdir(), os.sep, int(time.time()))
        test_tracks = Tracks(tmp_tracks_file)
        main_window = MainWindow(test_config,
                                 dummy,
                                 dummy,
                                 test_map,
                                 test_networks,
                                 test_tracks, {
                                     0: None,
                                     1: None
                                 },
                                 test_client_threads,
                                 logger=logger)
        main_window.network_list.crypt_cache = {}

        for x in range(1, 202):
            main_window.log_list.add("Kismon", "test %s" % x)
        main_window.log_list.cleanup()
        main_window.network_list.add_network('11:22:33:44:55:66')
        main_window.network_list.network_selected = '11:22:33:44:55:66'
        main_window.network_list.add_network('00:12:2A:03:B9:12')
        main_window.network_list.add_network('00:12:2A:03:B9:12')
        main_window.network_list.column_selected = 2
        main_window.network_list.on_copy_field(None)
        main_window.network_list.on_copy_network(None)
        main_window.network_list.on_comment_editing_done(test_widget)
        main_window.network_list.remove_network('00:12:2A:03:B9:12')
        main_window.network_list.remove_column('Ch')
        main_window.network_list.add_column('Ch')
        main_window.network_list.on_locate_marker(None)
        main_window.network_list.pause()
        main_window.network_list.resume()
        main_window.server_tabs[0].update_info_table({
            "networks": 100,
            "packets": 200
        })
        main_window.server_tabs[0].update_gps_table(fix=3, lat=52.0, lon=13.0)
        sources = {
            "1": {
                "uuid": "1",
                "name": "test",
                "type": "bla",
                "channel": 11,
                "packets": 100
            }
        }
        main_window.server_tabs[0].update_sources_table(sources)
        main_window.on_configure_event(None, None)
        main_window.on_config_window(None)
        main_window.on_config_window(None)
        main_window.on_signal_graph(None)
        main_window.on_signal_graph_destroy(None, "11:22:33:44:55:66")
        main_window.fullscreen()
        main_window.fullscreen()
        main_window.on_map_window(None, True)
        dummy_button = Gtk.Button()
        main_window.config_window.on_map_source(dummy_button, "custom")
        main_window.on_map_window(None, False)
        main_window.on_map_widget(None, True)
        main_window.config_window.on_map_source(dummy_button, "custom")
        main_window.on_map_widget(None, False)
        # main_window.on_server_disconnect(None, 0)
        test_event = TestEvent()
        main_window.on_window_state(None, test_event)

        main_window.on_file_import(None)

        main_window.networks_queue_progress()
        main_window.networks_queue_progress_update()

        test_widget.text = "Infrastructure"
        main_window.filter_tab.on_network_filter(test_widget, 'filter_type',
                                                 'infrastructure')
        main_window.filter_tab.on_toggle_limiter(test_widget, 'map', 'all')
        test_widget.text = 'something'
        main_window.filter_tab.on_regex_changed(test_widget, 'ssid')
        main_window.filter_tab.on_regex_changed(test_widget, 'ssid')