def setUp(self): try: self.user = User.objects.create_user( username='******', email='*****@*****.**', password='******') except: self.user = User.objects.first() self.institution = create_institution(self.user) create_url(self.institution, url=self.URL_NOTIFICATION) create_url(self.institution) self.request_client = HTTPClient(APIClient()) self.settings = Settings() self.settings.fva_server_url = '' self.client = PersonClient(settings=self.settings, request_client=self.request_client) self.person = self.client.get_identification() self.IDENTIFICATION = self.person person_user = self.get_person_user(self.person) auth_cert = self.client.get_certificates()['authentication'] self.person_obj, _ = Person.objects.get_or_create( user=person_user, identification=self.person) self.person_obj.authenticate_certificate = auth_cert self.person_obj.save() self.client.register()
def setUp(self): self.user = User.objects.create_user(username='******', email='*****@*****.**', password='******') self.institution = create_institution(self.user) create_url(self.institution, url=self.URL_NOTIFICATION) create_url(self.institution) self.client = APIClient()
def test_check_wrong_sign(self): """if all credential are well but data is encrypted with other private key""" institution2 = create_institution(self.user) url = "https://institution2.com/notify" create_url(institution2, url=url) response = self.authenticate( institution=str(institution2.code), url=url, public_certificate=institution2.public_certificate) response = decrypt(institution2.private_key, response.data['data']) self.check_wrong_sign_test(response)
def test_check_wrong_encrypt_authenticate(self): """if all credential are well but data is encrypted with other private key""" institution2 = create_institution(self.user) # url = "https://institution2.com/notify" # create_url(institution2, url=url) def edata_fun(str_data, etype='sign'): return self.dummy_encrypt(str_data, institution2.public_key) response = self.own_authenticate( edata=edata_fun, public_certificate=institution2.public_certificate) self.check_wrong_sign_test(response)
def test_check_wrong_sign(self): """if all credential are well but data is encrypted with other private key""" if self.DOCUMENT is None: return institution2 = create_institution(self.user) url = "https://institution2.com/notify" create_url(institution2, url=url) response = self.sign_check( institution=str(institution2.code), url=url, public_certificate=institution2.public_certificate, request_url=self.BASE_URL % (self.data['id_transaction'], )) response = decrypt(institution2.private_key, response.data['data']) self.check_wrong_sign_test(response)
def test_check_wrong_sign(self): """if all credential are well but data is encrypted with other private key""" institution2 = create_institution(self.user) url = "https://institution2.com/notify" create_url(institution2, url=url) response = self.authenticate(institution=str(institution2.code), url=url, public_certificate=institution2.public_certificate, request_url=self.BASE_URL % ( self.data['id_transaction'],) ) response = decrypt(institution2.private_key, response.data['data']) self.check_result(response, False) self.assertIsNotNone(AuthenticateDataRequest.objects.filter( id_transaction=self.data['id_transaction']).first())