def test_implementsInterface(self): """ L{checkers.InMemorySSHKeyDB} implements L{checkers.IAuthorizedKeysDB} """ keydb = checkers.InMemorySSHKeyDB({'alice': ['key']}) verifyObject(checkers.IAuthorizedKeysDB, keydb)
def test_allKeysForAuthorizedUser(self): """ If the user is in the mapping provided to L{checkers.InMemorySSHKeyDB}, an iterator with all the keys is returned by L{checkers.InMemorySSHKeyDB.getAuthorizedKeys} """ keydb = checkers.InMemorySSHKeyDB({'alice': ['a', 'b']}) self.assertEqual(['a', 'b'], list(keydb.getAuthorizedKeys('alice')))
def test_noKeysForUnauthorizedUser(self): """ If the user is not in the mapping provided to L{checkers.InMemorySSHKeyDB}, an empty iterator is returned by L{checkers.InMemorySSHKeyDB.getAuthorizedKeys} """ keydb = checkers.InMemorySSHKeyDB({'alice': ['keys']}) self.assertEqual([], list(keydb.getAuthorizedKeys('bob')))
def conchTestPublicKeyChecker(): """ Produces a SSHPublicKeyChecker with an in-memory key mapping with a single use: 'testuser' @return: L{twisted.conch.checkers.SSHPublicKeyChecker} """ conchTestPublicKeyDB = checkers.InMemorySSHKeyDB( {'testuser': [keys.Key.fromString(publicDSA_openssh)]}) return checkers.SSHPublicKeyChecker(conchTestPublicKeyDB)