# Path: tests/base_test.py
# class SSH2TestCase(unittest.TestCase):
# 
#     @classmethod
#     def setUpClass(cls):
#         _mask = int('0600') if version_info <= (2,) else 0o600
#         os.chmod(PKEY_FILENAME, _mask)
#         cls.server = OpenSSHServer()
#         cls.server.start_server()
# 
#     @classmethod
#     def tearDownClass(cls):
#         cls.server.stop()
#         del cls.server
# 
#     def setUp(self):
#         self.host = '127.0.0.1'
#         self.port = 2222
#         self.cmd = 'echo me'
#         self.resp = u'me'
#         self.user_key = PKEY_FILENAME
#         self.user_pub_key = PUB_FILE
#         self.user = pwd.getpwuid(os.geteuid()).pw_name
#         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#         sock.connect((self.host, self.port))
#         self.sock = sock
#         self.session = Session()
#         self.session.handshake(self.sock)
# 
#     def tearDown(self):
#         self.session.disconnect()
#         self.sock.close()
# 
#     def _auth(self):
#         return self.session.userauth_publickey_fromfile(
#             self.user, self.user_key)


import os
import socket
from unittest import skipUnless
from .base_test import SSH2TestCase
from ssh2.session import Session, LIBSSH2_HOSTKEY_HASH_MD5, \
    LIBSSH2_HOSTKEY_HASH_SHA1
from ssh2.agent import Agent
from ssh2.exceptions import AuthenticationError, AgentAuthenticationError, \
    SCPProtocolError, RequestDeniedError, InvalidRequestError, \
    SocketSendError, FileError, PublickeyUnverifiedError
from ssh2.utils import wait_socket

# from ssh2.sftp import SFTP
# from ssh2.error_codes import LIBSSH2_ERROR_EAGAIN


class SessionTestCase(SSH2TestCase):

    def test_agent_pyobject(self):
        agent = Agent(self.session)
        self.assertIsInstance(agent, Agent)

    def test_agent_get_identities(self):
        agent = Agent(self.session)
        agent.connect()
        ids = agent.get_identities()
        self.assertIsInstance(ids, list)
        agent.disconnect()

    def test_agent_id_path(self):
        agent = Agent(self.session)
        agent.connect()
        _path = b'my_path'

# Path: tests/base_test.py
# class SSH2TestCase(unittest.TestCase):
# 
#     @classmethod
#     def setUpClass(cls):
#         _mask = int('0600') if version_info <= (2,) else 0o600
#         os.chmod(PKEY_FILENAME, _mask)
#         cls.server = OpenSSHServer()
#         cls.server.start_server()
# 
#     @classmethod
#     def tearDownClass(cls):
#         cls.server.stop()
#         del cls.server
# 
#     def setUp(self):
#         self.host = '127.0.0.1'
#         self.port = 2222
#         self.cmd = 'echo me'
#         self.resp = u'me'
#         self.user_key = PKEY_FILENAME
#         self.user_pub_key = PUB_FILE
#         self.user = pwd.getpwuid(os.geteuid()).pw_name
#         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#         sock.connect((self.host, self.port))
#         self.sock = sock
#         self.session = Session()
#         self.session.handshake(self.sock)
# 
#     def tearDown(self):
#         self.session.disconnect()
#         self.sock.close()
# 
#     def _auth(self):
#         return self.session.userauth_publickey_fromfile(
#             self.user, self.user_key)


# Path: tests/test_agent.py
import os
import socket
from unittest import skipUnless
from .base_test import SSH2TestCase
from ssh2.session import Session, LIBSSH2_HOSTKEY_HASH_MD5, \
    LIBSSH2_HOSTKEY_HASH_SHA1
from ssh2.agent import Agent
from ssh2.exceptions import AuthenticationError, AgentAuthenticationError, \
    SCPProtocolError, RequestDeniedError, InvalidRequestError, \
    SocketSendError, FileError, PublickeyUnverifiedError
from ssh2.utils import wait_socket


# from ssh2.sftp import SFTP
# from ssh2.error_codes import LIBSSH2_ERROR_EAGAIN


class SessionTestCase(SSH2TestCase):

    def test_agent_pyobject(self):
        agent = Agent(self.session)
        self.assertIsInstance(agent, Agent)

    def test_agent_get_identities(self):
        agent = Agent(self.session)
        agent.connect()
        ids = agent.get_identities()
        self.assertIsInstance(ids, list)
        agent.disconnect()

    def test_agent_id_path(self):
        agent = Agent(self.session)
        agent.connect()
        _path = b'my_path'

        agent.set_identity_path(_path)