Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_disallow_options(self):
file_obj = StringIO("""command="dump /home",no-pty,no-port-forwarding """ + DEFAULT_KEY)
self.assertRaises(InvalidOptionsError, AuthorizedKeysFile, file_obj, disallow_options=True)
file_obj.seek(0)
key_file = AuthorizedKeysFile(file_obj)
self.assertEqual(len(key_file.keys), 1)
def check_valid_file(self, file_str, valid_keys_count):
file_obj = StringIO(file_str)
key_file = AuthorizedKeysFile(file_obj)
for item in key_file.keys:
self.assertIsInstance(item, SSHKey)
self.assertEqual(len(key_file.keys), valid_keys_count)