#7874 testcase test_commands.py::TestIPACommand::test_ssh_key_connection fails with some test configurations
Closed: fixed 5 years ago by frenaud. Opened 5 years ago by sorlov.

If name and external_hostname are different in test-config.yam, then test fails stacktrace:

self = <ipatests.test_integration.test_commands.TestIPACommand object at 0x7f6282ca5128>, tmpdir = local('/tmp/pytest-of-root/pytest-0/test_ssh_key_connection0')

    def test_ssh_key_connection(self, tmpdir):
        """
            Integration test for https://pagure.io/SSSD/sssd/issue/3747
            """

        test_user = 'test-ssh'
        master = self.master.hostname

        pub_keys = []

        for i in range(40):
            ssh_key_pair = tasks.generate_ssh_keypair()
            pub_keys.append(ssh_key_pair[1])
            with open(os.path.join(
                    tmpdir, 'ssh_priv_{}'.format(i)), 'w') as fp:
                fp.write(ssh_key_pair[0])

        tasks.kinit_admin(self.master)
        self.master.run_command(['ipa', 'user-add', test_user,
                                 '--first=tester', '--last=tester'])

        keys_opts = ' '.join(['--ssh "{}"'.format(k) for k in pub_keys])
        cmd = 'ipa user-mod {} {}'.format(test_user, keys_opts)
        self.master.run_command(cmd)

        # connect with first SSH key
        first_priv_key_path = os.path.join(tmpdir, 'ssh_priv_1')
        # change private key permission to comply with SS rules
        os.chmod(first_priv_key_path, 0o600)

        sshcon = paramiko.SSHClient()
        sshcon.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        # first connection attempt is a workaround for
        # https://pagure.io/SSSD/sssd/issue/3669
        try:
            sshcon.connect(master, username=test_user,
>                          key_filename=first_priv_key_path, timeout=1)

/usr/lib/python3.6/site-packages/ipatests/test_integration/test_commands.py:348: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.6/site-packages/paramiko/client.py:334: in connect
    to_try = list(self._families_and_addresses(hostname, port))
/usr/lib/python3.6/site-packages/paramiko/client.py:204: in _families_and_addresses
    hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

host = 'host-8-248-111.testrelm.test', port = 22, family = <AddressFamily.AF_UNSPEC: 0>, type = <SocketKind.SOCK_STREAM: 1>, proto = 0, flags = 0

    def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0):
        """Resolve host and port into list of address info entries.

        Translate the host/port argument into a sequence of 5-tuples that contain
        all the necessary arguments for creating a socket connected to that service.
        host is a domain name, a string representation of an IPv4/v6 address or
        None. port is a string service name such as 'http', a numeric port number or
        None. By passing None as the value of host and port, you can pass NULL to
        the underlying C API.

        The family, type and proto arguments can be optionally specified in order to
        narrow the list of addresses returned. Passing zero as a value for each of
        these arguments selects the full range of results.
        """
        # We override this function since we want to translate the numeric family
        # and socket type values to enum constants.
        addrlist = []
>       for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
E       socket.gaierror: [Errno -2] Name or service not known

/usr/lib64/python3.6/socket.py:745: gaierror

This happens because sshcon.connect uses self.master.hostname but should use self.master.external_hostname as this connection is being established from controller machine.


master:

  • 24c77bc ipatests: fix host name for ssh connection from controller to master

ipa-4-7:

  • f8d91b9 ipatests: fix host name for ssh connection from controller to master

Metadata Update from @frenaud:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

5 years ago

ipa-4-6:

  • 58d11af ipatests: fix host name for ssh connection from controller to master

Login to comment on this ticket.

Metadata