def test_server_auth_methods(self): """Test server auth methods""" with self.subTest('No auth methods'): server_conn = _AuthServerStub() self.assertEqual(get_server_auth_methods(server_conn), []) server_conn.close() with self.subTest('All auth methods'): gss_host = '1' if gss_available else None server_conn = _AuthServerStub(gss_host=gss_host, public_key_auth=True, password_auth=True, kbdint_auth=True) if gss_available: # pragma: no branch self.assertEqual(get_server_auth_methods(server_conn), [b'gssapi-keyex', b'gssapi-with-mic', b'publickey', b'keyboard-interactive', b'password']) else: # pragma: no cover self.assertEqual(get_server_auth_methods(server_conn), [b'publickey', b'keyboard-interactive', b'password']) server_conn.close() with self.subTest('Unknown auth method'): server_conn = _AuthServerStub() self.assertEqual(lookup_server_auth(server_conn, 'user', b'xxx', SSHPacket(b'')), None) server_conn.close()
def test_server_auth_methods(self): """Test server auth methods""" with self.subTest('No auth methods'): server_conn = _AuthServerStub() self.assertEqual(get_server_auth_methods(server_conn), []) server_conn.close() with self.subTest('All auth methods'): gss_host = '1' if gss_available else None server_conn = _AuthServerStub(gss_host=gss_host, host_based_auth=True, public_key_auth=True, password_auth=True, kbdint_auth=True) if gss_available: # pragma: no branch self.assertEqual(get_server_auth_methods(server_conn), [b'gssapi-keyex', b'gssapi-with-mic', b'hostbased', b'publickey', b'keyboard-interactive', b'password']) else: # pragma: no cover self.assertEqual(get_server_auth_methods(server_conn), [b'hostbased', b'publickey', b'keyboard-interactive', b'password']) server_conn.close() with self.subTest('Unknown auth method'): server_conn = _AuthServerStub() self.assertEqual(lookup_server_auth(server_conn, 'user', b'xxx', SSHPacket(b'')), None) server_conn.close()
def test_server_auth_methods(self): """Test server auth methods""" with self.subTest('No auth methods'): server_conn = _AuthServerStub() self.assertEqual(get_server_auth_methods(server_conn), []) server_conn.close() with self.subTest('All auth methods'): server_conn = _AuthServerStub(public_key_auth=True, password_auth=True, kbdint_auth=True) self.assertEqual(get_server_auth_methods(server_conn), [b'publickey', b'keyboard-interactive', b'password']) server_conn.close() with self.subTest('Unknown auth method'): server_conn = _AuthServerStub() self.assertEqual(lookup_server_auth(server_conn, 'user', b'xxx', SSHPacket(b'')), None) server_conn.close()
def test_server_auth_methods(self): """Test server auth methods""" with self.subTest('No auth methods'): server_conn = _AuthServerStub() self.assertEqual(get_server_auth_methods(server_conn), []) server_conn.close() with self.subTest('All auth methods'): server_conn = _AuthServerStub(public_key_auth=True, password_auth=True, kbdint_auth=True) self.assertEqual( get_server_auth_methods(server_conn), [b'publickey', b'keyboard-interactive', b'password']) server_conn.close() with self.subTest('Unknown auth method'): server_conn = _AuthServerStub() self.assertEqual( lookup_server_auth(server_conn, 'user', b'xxx', SSHPacket(b'')), None) server_conn.close()