def deobfuscate_invitation(user):
    try:
        Invitation.deobfuscate_email(user.email, user.first_name,
                                     user.last_name)
    except Exception as e:
        print 'Error Deobfuscation'
        print e
Exemple #2
0
    def reset_invitations(cls):

        for invit in Invitation.objects.all():
            invit.delete()

        cls.invitation = {
            'sender_email': '*****@*****.**',
            'sender_first_name': 'adam',
            'sender_last_name': 'sender',
            'receiver_email': '*****@*****.**',
            'receiver_first_name': 'adam',
            'receiver_last_name': 'receiver',
            'sender_verified': False
        }
        cls.invitation_2 = {
            'sender_email': '*****@*****.**',
            'sender_first_name': 'adam',
            'sender_last_name': 'sender',
            'receiver_email': '*****@*****.**',
            'receiver_first_name': 'adam',
            'receiver_last_name': 'receiver',
            'sender_verified': False
        }
        Invitation.create(**cls.invitation)
        Invitation.create(**cls.invitation_2)
Exemple #3
0
 def test5_invitation_debfuscation_exist(self):
     # assert should deobfuscate invitation
     Invitation.deobfuscate_email(self.invitation['sender_email'])
     invitation = Invitation.get_by_email(receiver_email=self.invitation['receiver_email'])
     self.assertEqual(
         invitation[0].__dict__['sender_email'],
         self.invitation['sender_email'],
         'Should deobfuscate provided email'
     )
Exemple #4
0
 def test6_invitation_debfuscation_doesnt_exist(self):
     # assert should deobfuscate invitation
     Invitation.deobfuscate_email('*****@*****.**')
     invitation = Invitation.get_by_email(receiver_email=self.invitation['receiver_email'])
     self.assertNotEqual(
         invitation[0].__dict__['sender_email'],
         self.invitation['sender_email'],
         'Should not deobfuscate provided email'
     )
Exemple #5
0
    def test8_invitation_debfuscation_first_name_only(self):
        # assert should deobfuscate first_name only
        self.reset_invitations()
        Invitation.deobfuscate_email(self.invitation['sender_email'], self.invitation['sender_first_name'])
        invitation = Invitation.get_by_email(sender_email=self.invitation['sender_email'])

        self.assertEqual(
            invitation[0].sender_first_name+invitation[0].sender_last_name,
            self.invitation['sender_first_name']+HashHelper.md5_hash(self.invitation['sender_last_name']),
            'Should deobfuscate first_name and last_name'
        )
Exemple #6
0
    def test7_invitation_debfuscation_first_and_last_name(self):
        # assert should deobfuscate first_name and last_name
        self.reset_invitations()
        Invitation.deobfuscate_email(self.invitation['sender_email'], self.invitation['sender_first_name'], self.invitation['sender_last_name'])
        invitation = Invitation.get_by_email(sender_email=self.invitation['sender_email'])

        self.assertEqual(
            invitation[0].sender_first_name+invitation[0].sender_last_name,
            self.invitation['sender_first_name']+self.invitation['sender_last_name'],
            'Should deobfuscate first_name and last_name'
        )
Exemple #7
0
 def test0_invitation_can_invite(self):
     # assert should return true if invitation does not exist
     self.assertTrue(
         Invitation.can_invite(
             sender_email=self.invitation['sender_email'],
             receiver_email='*****@*****.**'
         ),
         'Can invite function should return true if invitation does not exist'
     )
Exemple #8
0
 def test0_invitation_cannot_invite(self):
     # assert should return false if invitation exist
     self.assertFalse(
         Invitation.can_invite(
             sender_email=self.invitation['sender_email'],
             receiver_email=self.invitation['receiver_email']
         ),
         'Can invite should return return false if invitation exist'
     )
Exemple #9
0
 def test3_invitation_confirm_sender_doesnt_exist(self):
     # assert should not confirm invitation if invitation does not exist
     Invitation.confirm_sender(sender_email='*****@*****.**', receiver_email=self.invitation['receiver_email'])
     confirmed = Invitation.get_by_email(sender_email=self.invitation['sender_email'])
     self.assertFalse(confirmed[0].sender_verified, 'Invitation should not be confirmed with fake email')
Exemple #10
0
 def test2_invitation_confirm_sender_exist(self):
     # assert should confirm invitation if sender exist
     Invitation.confirm_sender(sender_email=self.invitation['sender_email'], receiver_email=self.invitation['receiver_email'])
     confirmed = Invitation.get_by_email(sender_email=self.invitation['sender_email'])
     self.assertTrue(confirmed[0].sender_verified, 'Invitation should be confirmed with existing sender and receiver emails')
Exemple #11
0
 def test0_invitation_search_by_email_not_obfuscated(self):
     # assert should find clear email providing clear email
     invitation = Invitation.objects.get(sender_email=HashHelper.md5_hash(self.invitation_2['sender_email']))
     invitation.sender_email = self.invitation_2['sender_email']
     invitation.save()
     self.assertGreater(len(Invitation.get_by_email(sender_email=self.invitation_2['sender_email'])), 0, 'Cannot find invitatiton by email')
Exemple #12
0
 def test0_invitation_search_by_email_obfuscated(self):
     # assert should find obfuscated email providing clear email
     self.assertGreater(len(Invitation.get_by_email(sender_email=self.invitation['sender_email'])), 0, 'Cannot find invitatiton by email')