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_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_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_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)