This file is indexed.

/usr/lib/python3/dist-packages/wormhole/test/test_ssh.py is in magic-wormhole 0.10.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import os, io
import mock
from twisted.trial import unittest
from ..cli import cmd_ssh

OTHERS = ["config", "config~", "known_hosts", "known_hosts~"]

class FindPubkey(unittest.TestCase):
    def test_find_one(self):
        files = OTHERS + ["id_rsa.pub", "id_rsa"]
        pubkey_data = u"ssh-rsa AAAAkeystuff email@host\n"
        pubkey_file = io.StringIO(pubkey_data)
        with mock.patch("wormhole.cli.cmd_ssh.exists", return_value=True):
            with mock.patch("os.listdir", return_value=files) as ld:
                with mock.patch("wormhole.cli.cmd_ssh.open",
                                return_value=pubkey_file):
                    res = cmd_ssh.find_public_key()
        self.assertEqual(ld.mock_calls,
                         [mock.call(os.path.expanduser("~/.ssh/"))])
        self.assertEqual(len(res), 3, res)
        kind, keyid, pubkey = res
        self.assertEqual(kind, "ssh-rsa")
        self.assertEqual(keyid, "email@host")
        self.assertEqual(pubkey, pubkey_data)

    def test_find_none(self):
        files = OTHERS # no pubkey
        with mock.patch("wormhole.cli.cmd_ssh.exists", return_value=True):
            with mock.patch("os.listdir", return_value=files):
                e = self.assertRaises(cmd_ssh.PubkeyError,
                                      cmd_ssh.find_public_key)
        dot_ssh = os.path.expanduser("~/.ssh/")
        self.assertEqual(str(e), "No public keys in '{}'".format(dot_ssh))

    def test_bad_hint(self):
        with mock.patch("wormhole.cli.cmd_ssh.exists", return_value=False):
            e = self.assertRaises(cmd_ssh.PubkeyError,
                                  cmd_ssh.find_public_key,
                                  hint="bogus/path")
        self.assertEqual(str(e), "Can't find 'bogus/path'")


    def test_find_multiple(self):
        files = OTHERS + ["id_rsa.pub", "id_rsa", "id_dsa.pub", "id_dsa"]
        pubkey_data = u"ssh-rsa AAAAkeystuff email@host\n"
        pubkey_file = io.StringIO(pubkey_data)
        with mock.patch("wormhole.cli.cmd_ssh.exists", return_value=True):
            with mock.patch("os.listdir", return_value=files):
                responses = iter(["frog", "NaN", "-1", "0"])
                with mock.patch("click.prompt",
                                side_effect=lambda p: next(responses)):
                    with mock.patch("wormhole.cli.cmd_ssh.open",
                                    return_value=pubkey_file):
                        res = cmd_ssh.find_public_key()
        self.assertEqual(len(res), 3, res)
        kind, keyid, pubkey = res
        self.assertEqual(kind, "ssh-rsa")
        self.assertEqual(keyid, "email@host")
        self.assertEqual(pubkey, pubkey_data)