コード例 #1
0
def device_gen(chain, urls):
    """Device object generator."""
    itr = iter(urls)
    last = next(itr)
    for url in itr:
        yield Device(chain, make_hop_info_from_url(last), driver_name='jumphost', is_target=False)
        last = url
    yield Device(chain, make_hop_info_from_url(last), driver_name='generic', is_target=True)
コード例 #2
0
ファイル: url_test.py プロジェクト: kstaniek/condoor
 def test_url_ssh_no_password(self):
     url = "ssh://[email protected]:2048"
     hop_info = make_hop_info_from_url(url)
     assert hop_info.protocol == 'ssh'
     assert hop_info.username == 'user'
     assert hop_info.password is None
     assert hop_info.hostname == '1.1.1.1'
     assert hop_info.port == 2048
コード例 #3
0
ファイル: url_test.py プロジェクト: kstaniek/condoor
 def test_url_ssh(self):
     url = "ssh://*****:*****@1.1.1.1"
     hop_info = make_hop_info_from_url(url)
     assert hop_info.protocol == 'ssh'
     assert hop_info.username == 'user'
     assert hop_info.password == 'pass'
     assert hop_info.hostname == '1.1.1.1'
     assert hop_info.port == 22
コード例 #4
0
ファイル: url_test.py プロジェクト: kstaniek/condoor
 def test_url_telnet_empty_password(self):
     url = "telnet://user:@1.1.1.1:2048"
     hop_info = make_hop_info_from_url(url)
     assert hop_info.protocol == 'telnet'
     assert hop_info.username == 'user'
     assert hop_info.password == ''
     assert hop_info.hostname == '1.1.1.1'
     assert hop_info.port == 2048
コード例 #5
0
ファイル: url_test.py プロジェクト: kstaniek/condoor
 def test_url_telnet_no_user_password(self):
     url = "telnet://1.1.1.1:2048"
     hop_info = make_hop_info_from_url(url)
     assert hop_info.protocol == 'telnet'
     assert hop_info.username is None
     assert hop_info.password is None
     assert hop_info.hostname == '1.1.1.1'
     assert hop_info.port == 2048
コード例 #6
0
ファイル: url_test.py プロジェクト: kstaniek/condoor
 def test_url_ssh_empty_user_password(self):
     url = "ssh://:@1.1.1.1:2048"
     hop_info = make_hop_info_from_url(url)
     assert hop_info.protocol == 'ssh'
     assert hop_info.username == ''
     assert hop_info.password == ''
     assert hop_info.hostname == '1.1.1.1'
     assert hop_info.port == 2048
コード例 #7
0
ファイル: url_test.py プロジェクト: kstaniek/condoor
 def test_url_telnet(self):
     url = "telnet://*****:*****@1.1.1.1"
     hop_info = make_hop_info_from_url(url)
     assert hop_info.protocol == 'telnet'
     assert hop_info.username == 'user'
     assert hop_info.password == 'pass'
     assert hop_info.hostname == '1.1.1.1'
     assert hop_info.port == 23
コード例 #8
0
    def test_url_ssh_empty_password(self):
        url = "ssh://user:@1.1.1.1:2048"
        hop_info = make_hop_info_from_url(url)

        self.assertEqual(hop_info.protocol, "ssh")
        self.assertEqual(hop_info.username, "user")
        self.assertEqual(hop_info.password, "")
        self.assertEqual(hop_info.hostname, "1.1.1.1")
        self.assertEqual(hop_info.port, 2048)
コード例 #9
0
ファイル: url_test.py プロジェクト: kstaniek/condoor
 def test_url_telnet_two_ip(self):
     url = "telnet://1.1.1.1,2.2.2.2:23,34/!@#$%^&*()1/2345678asdfgh"
     hop_info = make_hop_info_from_url(url)
     assert hop_info.protocol == 'telnet'
     assert hop_info.username is None
     assert hop_info.password is None
     assert hop_info.hostname == '1.1.1.1,2.2.2.2'
     assert hop_info.port == 23, 24
     assert hop_info.enable_password == "!@#$%^&*()1/2345678asdfgh"
コード例 #10
0
ファイル: url_test.py プロジェクト: kstaniek/condoor
 def test_url_telnet_no_user_password_and_enable_no_port(self):
     url = "telnet://1.1.1.1/!@#$%^&*()1/2345678asdfgh"
     hop_info = make_hop_info_from_url(url)
     assert hop_info.protocol == 'telnet'
     assert hop_info.username is None
     assert hop_info.password is None
     assert hop_info.hostname == '1.1.1.1'
     assert hop_info.port == 23
     assert hop_info.enable_password == "!@#$%^&*()1/2345678asdfgh"
コード例 #11
0
    def test_url_telnet_empty_user_password(self):
        url = "telnet://:@1.1.1.1:2048"
        hop_info = make_hop_info_from_url(url)

        self.assertEqual(hop_info.protocol, "telnet")
        self.assertEqual(hop_info.username, "")
        self.assertEqual(hop_info.password, "")
        self.assertEqual(hop_info.hostname, "1.1.1.1")
        self.assertEqual(hop_info.port, 2048)
コード例 #12
0
    def test_url_ssh_no_user_password(self):
        url = "ssh://1.1.1.1:2048"
        hop_info = make_hop_info_from_url(url)

        self.assertEqual(hop_info.protocol, "ssh")
        self.assertEqual(hop_info.username, None)
        self.assertEqual(hop_info.password, None)
        self.assertEqual(hop_info.hostname, "1.1.1.1")
        self.assertEqual(hop_info.port, 2048)
コード例 #13
0
    def test_url_telnet_no_password(self):
        url = "telnet://[email protected]:2048"
        hop_info = make_hop_info_from_url(url)

        self.assertEqual(hop_info.protocol, "telnet")
        self.assertEqual(hop_info.username, "user")
        self.assertEqual(hop_info.password, None)
        self.assertEqual(hop_info.hostname, "1.1.1.1")
        self.assertEqual(hop_info.port, 2048)
コード例 #14
0
    def test_url_telnet(self):
        url = "telnet://*****:*****@1.1.1.1"
        hop_info = make_hop_info_from_url(url)

        self.assertEqual(hop_info.protocol, "telnet")
        self.assertEqual(hop_info.username, "user")
        self.assertEqual(hop_info.password, "pass")
        self.assertEqual(hop_info.hostname, "1.1.1.1")
        self.assertEqual(hop_info.port, 23)
コード例 #15
0
    def test_url_telnet_no_user_password_and_enable_no_port_not_quoted(self):
        url = "telnet://1.1.1.1/?enable_password=!@#$%^&*()1/2345678asdfgh"
        hop_info = make_hop_info_from_url(url)

        self.assertEqual(hop_info.protocol, "telnet")
        self.assertEqual(hop_info.username, None)
        self.assertEqual(hop_info.password, None)
        self.assertEqual(hop_info.hostname, "1.1.1.1")
        self.assertEqual(hop_info.port, 23)
        self.assertNotEqual(hop_info.enable_password,
                            "!@#$%^&*()1/2345678asdfgh")
コード例 #16
0
    def test_url_telnet_no_user_password_and_enable_no_port_quoted(self):
        password = """\|;':"!@#$%^&*()+{}:"<>?`,<>~./1234567890zxcvbnmasdfghjklqwertyuiopZXCVBNMASDFGHJKLQWERTYUIOP"""
        password_q = quote(password, safe="")
        url = "telnet://1.1.1.1/?enable_password={password}".format(
            password=password_q)
        hop_info = make_hop_info_from_url(url)

        self.assertEqual(hop_info.protocol, "telnet")
        self.assertEqual(hop_info.username, None)
        self.assertEqual(hop_info.password, None)
        self.assertEqual(hop_info.hostname, "1.1.1.1")
        self.assertEqual(hop_info.port, 23)
        self.assertEqual(hop_info.enable_password, password)
コード例 #17
0
    def test_url_telnet_complex_user_pass(self):
        username = """\|;':"!@#$%^&*()+{}:"<>?`,<>~./1234567890zxcvbnmasdfghjklqwertyuiopZXCVBNMASDFGHJKLQWERTYUIOP"""
        password = """\|;':"!@#$%^&*()+{}:"<>?`,<>~./1234567890zxcvbnmasdfghjklqwertyuiopZXCVBNMASDFGHJKLQWERTYUIOP"""

        username_q = quote(username, safe="")
        password_q = quote(password, safe="")
        url = "telnet://{username}:{password}@1.1.1.1".format(
            username=username_q, password=password_q)
        hop_info = make_hop_info_from_url(url)

        self.assertEqual(hop_info.protocol, "telnet")
        self.assertEqual(hop_info.username, username)
        self.assertEqual(hop_info.password, password)
        self.assertEqual(hop_info.hostname, "1.1.1.1")
        self.assertEqual(hop_info.port, 23)