# Path: paramiko/py3compat.py
# PY2 = sys.version_info[0] < 3
#         MAXSIZE = int((1 << 31) - 1)  # NOQA
#         MAXSIZE = int((1 << 63) - 1)  # NOQA
#     MAXSIZE = sys.maxsize  # NOQA
#     def bytestring(s):  # NOQA
#     def byte_mask(c, mask):
#     def b(s, encoding="utf8"):  # NOQA
#     def u(s, encoding="utf8"):  # NOQA
#     def b2s(s):
#     def is_callable(c):  # NOQA
#     def get_next(c):  # NOQA
#     def next(c):
#         def __len__(self):
#     def strftime(format, t):
#     def byte_ord(c):
#     def byte_chr(c):
#     def byte_mask(c, mask):
#     def b(s, encoding="utf8"):
#     def u(s, encoding="utf8"):
#     def b2s(s):
#     def is_callable(c):
#     def get_next(c):
#     class X(object):
#     class long(int):


from binascii import hexlify
from paramiko.py3compat import decodebytes
import os
import unittest
import paramiko
h0EKCWx2rf1IetyNsTxWrniA9I6HeDj65X1FyDkg6g8tvCnaNB8Xp/UUhuzHuGsMIipRxBxw9LF60\
8EqZcj1E3ytktoW5B5OcjrkEoz3xG7C+rpIjYvAAAAFQDwz4UnmsGiSNu5iqjn3uTzwUpshwAAAIE\
AkxfFeY8P2wZpDjX0MimZl5wkoFQDL25cPzGBuB4OnB8NoUk/yjAHIIpEShw8V+LzouMK5CTJQo5+\
Ngw3qIch/WgRmMHy4kBq1SsXMjQCte1So6HBMvBPIW5SiMTmjCfZZiw4AYHK+B/JaOwaG9yRg2Ejg\
4Ok10+XFDxlqZo8Y+wAAACARmR7CCPjodxASvRbIyzaVpZoJ/Z6x7dAumV+ysrV1BVYd0lYukmnjO\
1kKBWApqpH1ve9XDQYN8zgxM4b16L21kpoWQnZtXrY3GZ4/it9kUgyB7+NwacIBlXa8cMDL7Q/69o\
0d54U0X/NeX5QxuYR6OMJlrkQB7oiW/P/1mwjQgE="""


class HostKeysTest(unittest.TestCase):
    def setUp(self):
        with open("hostfile.temp", "w") as f:
            f.write(test_hosts_file)

    def tearDown(self):
        os.unlink("hostfile.temp")

    def test_load(self):
        hostdict = paramiko.HostKeys("hostfile.temp")
        self.assertEqual(2, len(hostdict))
        self.assertEqual(1, len(list(hostdict.values())[0]))
        self.assertEqual(1, len(list(hostdict.values())[1]))
        fp = hexlify(
            hostdict["secure.example.com"]["ssh-rsa"].get_fingerprint()
        ).upper()
        self.assertEqual(b"E6684DB30E109B67B70FF1DC5C7F1363", fp)

    def test_add(self):
        hostdict = paramiko.HostKeys("hostfile.temp")
        hh = "|1|BMsIC6cUIP2zBuXR3t2LRcJYjzM=|hpkJMysjTk/+zzUUzxQEa2ieq6c="

# Path: paramiko/py3compat.py
# PY2 = sys.version_info[0] < 3
#         MAXSIZE = int((1 << 31) - 1)  # NOQA
#         MAXSIZE = int((1 << 63) - 1)  # NOQA
#     MAXSIZE = sys.maxsize  # NOQA
#     def bytestring(s):  # NOQA
#     def byte_mask(c, mask):
#     def b(s, encoding="utf8"):  # NOQA
#     def u(s, encoding="utf8"):  # NOQA
#     def b2s(s):
#     def is_callable(c):  # NOQA
#     def get_next(c):  # NOQA
#     def next(c):
#         def __len__(self):
#     def strftime(format, t):
#     def byte_ord(c):
#     def byte_chr(c):
#     def byte_mask(c, mask):
#     def b(s, encoding="utf8"):
#     def u(s, encoding="utf8"):
#     def b2s(s):
#     def is_callable(c):
#     def get_next(c):
#     class X(object):
#     class long(int):


# Path: tests/test_hostkeys.py
from binascii import hexlify
from paramiko.py3compat import decodebytes
import os
import unittest
import paramiko

h0EKCWx2rf1IetyNsTxWrniA9I6HeDj65X1FyDkg6g8tvCnaNB8Xp/UUhuzHuGsMIipRxBxw9LF60\
8EqZcj1E3ytktoW5B5OcjrkEoz3xG7C+rpIjYvAAAAFQDwz4UnmsGiSNu5iqjn3uTzwUpshwAAAIE\
AkxfFeY8P2wZpDjX0MimZl5wkoFQDL25cPzGBuB4OnB8NoUk/yjAHIIpEShw8V+LzouMK5CTJQo5+\
Ngw3qIch/WgRmMHy4kBq1SsXMjQCte1So6HBMvBPIW5SiMTmjCfZZiw4AYHK+B/JaOwaG9yRg2Ejg\
4Ok10+XFDxlqZo8Y+wAAACARmR7CCPjodxASvRbIyzaVpZoJ/Z6x7dAumV+ysrV1BVYd0lYukmnjO\
1kKBWApqpH1ve9XDQYN8zgxM4b16L21kpoWQnZtXrY3GZ4/it9kUgyB7+NwacIBlXa8cMDL7Q/69o\
0d54U0X/NeX5QxuYR6OMJlrkQB7oiW/P/1mwjQgE="""


class HostKeysTest(unittest.TestCase):
    def setUp(self):
        with open("hostfile.temp", "w") as f:
            f.write(test_hosts_file)

    def tearDown(self):
        os.unlink("hostfile.temp")

    def test_load(self):
        hostdict = paramiko.HostKeys("hostfile.temp")
        self.assertEqual(2, len(hostdict))
        self.assertEqual(1, len(list(hostdict.values())[0]))
        self.assertEqual(1, len(list(hostdict.values())[1]))
        fp = hexlify(
            hostdict["secure.example.com"]["ssh-rsa"].get_fingerprint()
        ).upper()
        self.assertEqual(b"E6684DB30E109B67B70FF1DC5C7F1363", fp)

    def test_add(self):
        hostdict = paramiko.HostKeys("hostfile.temp")
        hh = "|1|BMsIC6cUIP2zBuXR3t2LRcJYjzM=|hpkJMysjTk/+zzUUzxQEa2ieq6c="

        key = paramiko.RSAKey(data=decodebytes(keyblob))