def startOpenportItProcess (self, path):
        share = Share()
        share.filePath = path
        app_dir = self.os_interaction.get_application_dir()
        if self.os_interaction.is_compiled():
            share.restart_command = [os.path.join(app_dir, 'openportit.exe'), path]
        else:
            share.restart_command = ['python', os.path.join(app_dir, 'apps/openportit.py'), path]

        self.os_interaction.start_openport_process(share, hide_message=False, no_clipboard=False)
Exemple #2
0
    def test_as_dict(self):
        share = Share()
        share.account_id = 6
        share.key_id = 14
        share.local_port = 2022
        share.id = -1
        share.server_session_token = 'abcd'

        share.server = 'a.openport.io'
        share.server_port = 1234
        share.pid = 234
        share.active = True
        share.restart_command = ['restart', 'command']
        share.http_forward = True
        share.http_forward_address = 'http://jan.u.openport.io'
        share.open_port_for_ip_link = 'http//openport.io/l/1234/zerazer'

        share2 = Share().from_dict(share.as_dict())

        self.assertEquals(share.id, share2.id)
        self.assertEquals(share.server, share2.server)
        self.assertEquals(share.server_port, share2.server_port)
        self.assertEquals(share.pid, share2.pid)
        self.assertEquals(share.active, share2.active)
        self.assertEquals(share.account_id, share2.account_id)
        self.assertEquals(share.key_id, share2.key_id)
        self.assertEquals(share.local_port, share2.local_port)
        self.assertEquals(share.server_session_token,
                          share2.server_session_token)
        self.assertEquals(share.restart_command, share2.restart_command)
        self.assertEquals(share.http_forward, share2.http_forward)
        self.assertEquals(share.http_forward_address,
                          share2.http_forward_address)
        self.assertEquals(share.open_port_for_ip_link,
                          share2.open_port_for_ip_link)
Exemple #3
0
    def test_start_openport_process(self):
        os.chdir(os.path.dirname(os.path.dirname(__file__)))

        command = [
            'sudo', '-u', 'pi', '/usr/bin/openport', '2025',
            '--restart-on-reboot', '--request-port', '31261',
            '--request-token', 'WkSXfYyksNy4vN2h', '--start-manager', 'False'
        ]
        share = Share()
        share.restart_command = command

        method = self.os_interaction.start_process
        self.os_interaction.start_process = Mock(return_value='')
        try:
            self.os_interaction.start_openport_process(share)
            self.os_interaction.start_process.assert_has_calls([
                call([
                    'env/bin/python', 'apps/openport_app.py', '2025',
                    '--restart-on-reboot', '--request-port', '31261',
                    '--request-token', 'WkSXfYyksNy4vN2h', '--start-manager',
                    'False'
                ])
            ])
        finally:
            self.os_interaction.start_process = method
Exemple #4
0
    def test_save_share(self):
        share = Share()
        share.account_id = 6
        share.key_id = 14
        share.local_port = 2022
        share.id = -1
        share.server_session_token = 'abcd'

        share.server = 'a.openport.io'
        share.server_port = 1234
        share.pid = 234
        share.active = True
        share.restart_command = ['restart', 'command']
        share.http_forward = True
        share.http_forward_address = 'http://jan.u.openport.io'
        share.app_management_port = 43122
        share.open_port_for_ip_link = 'http//openport.io/l/1234/zerazer'

        self.dbhandler.add_share(share)

        self.assertNotEqual(-1, share.id)

        share2 = self.dbhandler.get_share(share.id)

        self.assertEquals(share.id, share2.id)
        self.assertEquals(share.server, share2.server)
        self.assertEquals(share.server_port, share2.server_port)
        self.assertEquals(share.pid, share2.pid)
        self.assertEquals(share.active, share2.active)
        self.assertEquals(share.account_id, share2.account_id)
        self.assertEquals(share.key_id, share2.key_id)
        self.assertEquals(share.local_port, share2.local_port)
        self.assertEquals(share.server_session_token, share2.server_session_token)
        self.assertEquals(share.restart_command, share2.restart_command)
        self.assertEquals(share.http_forward, share2.http_forward)
        self.assertEquals(share.http_forward_address, share2.http_forward_address)
        self.assertEquals(share.app_management_port, share2.app_management_port)
        self.assertEquals(share.open_port_for_ip_link, share2.open_port_for_ip_link)