def test_create_email(self): identity = IdentitiesManager().create_email("bob@localhost") identity._validation_token = "test_token" owner_key = VirgilKey(self.__context, self.__key_pair_alice.private_key) cm = CardManager(self.__context) card = cm.create(identity, owner_key) self.assertIsInstance(card, VirgilCard)
def test_find(self): cm = CardManager(self.__context) identity = IdentitiesManager().create_user("alice", "username") owner_key = VirgilKey(self.__context, self.__key_pair_alice.private_key) card = cm.create(identity, owner_key) try: cm.publish(card) finded = cm.find("alice") self.assertIn(card, finded) finally: try: self.__cleanup_cards(card) except Exception: pass
def test_publish(self): cm = CardManager(self.__context) identity = IdentitiesManager().create_user("alice", "username") owner_key = VirgilKey(self.__context, self.__key_pair_alice.private_key) card = cm.create(identity, owner_key) try: card.publish() self.assertIsInstance(cm.get(card.id), VirgilCard) self.assertEqual(cm.get(card.id).identity, card.identity) finally: try: self.__cleanup_cards(card) except Exception: pass
def test_find_multiply(self): cm = CardManager(self.__context) identity_alice = IdentitiesManager().create_user("alice", "username") identity_bob = IdentitiesManager().create_user("bob", "username") alice_key = VirgilKey(self.__context, self.__key_pair_alice.private_key) bob_key = VirgilKey(self.__context, self.__key_pair_bob.private_key) alice_card = cm.create(identity_alice, alice_key) bob_card = cm.create(identity_bob, bob_key) try: cm.publish(alice_card) cm.publish(bob_card) finded = cm.find(["alice", "bob"]) self.assertIn(alice_card, finded) and self.assertIn(bob_card, finded) finally: try: self.__cleanup_cards(alice_card) except Exception: pass
def test_create_app(self): identity = IdentitiesManager().create_app("someapp") owner_key = VirgilKey(self.__context, self.__key_pair_alice.private_key) cm = CardManager(self.__context) card = cm.create(identity, owner_key) self.assertIsInstance(card, VirgilCard)
def test_import_card_published_global(self): data = self.__compatibility_data["export_published_global_virgil_card"] cm = CardManager(self.__context) imported_card = cm.import_card(data["exported_card"]) self.assertEqual(imported_card, cm.get(data["card_id"]))
def test_import_card_unpublished_local_without_id(self): data = self.__compatibility_data["export_unpublished_local_virgil_card_without_id"] cm = CardManager(self.__context) imported_card = cm.import_card(data["exported_card"]) imported_card_id = self.__crypto.calculate_fingerprint(bytearray(imported_card._VirgilCard__card.snapshot)).to_hex self.assertEqual(imported_card_id, data["card_id"])
def test_import_card_unpublished_local(self): data = self.__compatibility_data["export_unpublished_local_virgil_card"] cm = CardManager(self.__context) imported_card = cm.import_card(data["exported_card"]) self.assertEqual(imported_card.id, data["card_id"])