Esempio n. 1
0
 def test_ignores_leading_whitespace_and_empty_lines(self):
     """
     L{readAuthorizedKeyFile} ignores leading whitespace in lines, as well
     as empty lines
     """
     fileobj = StringIO("""
                        # ignore
                        not ignored
                        """)
     result = readAuthorizedKeyFile(fileobj, parsekey=lambda x: x)
     self.assertEqual(['not ignored'], list(result))
Esempio n. 2
0
 def test_ignores_comments(self):
     """
     L{readAuthorizedKeyFile} does not attempt to turn
     comments into keys
     """
     fileobj = StringIO('# this comment is ignored\n'
                        'this is not\n'
                        '# this is again\n'
                        'and this is not')
     result = readAuthorizedKeyFile(fileobj, lambda x: x)
     self.assertEqual(['this is not', 'and this is not'], list(result))
Esempio n. 3
0
 def test_ignores_leading_whitespace_and_empty_lines(self):
     """
     L{readAuthorizedKeyFile} ignores leading whitespace in lines, as well
     as empty lines
     """
     fileobj = StringIO("""
                        # ignore
                        not ignored
                        """)
     result = readAuthorizedKeyFile(fileobj, parsekey=lambda x: x)
     self.assertEqual(['not ignored'], list(result))
Esempio n. 4
0
 def test_ignores_comments(self):
     """
     L{readAuthorizedKeyFile} does not attempt to turn
     comments into keys
     """
     fileobj = StringIO('# this comment is ignored\n'
                        'this is not\n'
                        '# this is again\n'
                        'and this is not')
     result = readAuthorizedKeyFile(fileobj, lambda x: x)
     self.assertEqual(['this is not', 'and this is not'], list(result))
Esempio n. 5
0
    def test_returns_ignores_unparsable_keys(self):
        """
        L{readAuthorizedKeyFile} does not raise an exception
        when a key fails to parse, but rather just keeps going
        """
        def fail_on_some(line):
            if line.startswith('f'):
                raise Exception('failed to parse')
            return line

        fileobj = StringIO('failed key\ngood key')
        result = readAuthorizedKeyFile(fileobj, parsekey=fail_on_some)
        self.assertEqual(['good key'], list(result))
Esempio n. 6
0
    def test_returns_ignores_unparsable_keys(self):
        """
        L{readAuthorizedKeyFile} does not raise an exception
        when a key fails to parse, but rather just keeps going
        """
        def fail_on_some(line):
            if line.startswith('f'):
                raise Exception('failed to parse')
            return line

        fileobj = StringIO('failed key\ngood key')
        result = readAuthorizedKeyFile(fileobj,
                                                parsekey=fail_on_some)
        self.assertEqual(['good key'], list(result))