def test_encrypted_comments(self): nominee = Nominee.objects.get(email__person__name=COMMUNITY_USER) position = Position.objects.get(name='OAM') nomcom = position.nomcom # save the cert file in tmp nomcom.public_key.storage.location = tempfile.gettempdir() nomcom.public_key.save('cert', File(open(self.cert_file.name, 'r'))) comments = u'Plain text. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' feedback = Feedback.objects.create( nomcom=nomcom, comments=comments, type=FeedbackType.objects.get(slug='nomina')) feedback.positions.add(position) feedback.nominees.add(nominee) # to check feedback comments are saved like enrypted data self.assertNotEqual(feedback.comments, comments) self.assertEqual( check_comments(feedback.comments, comments, self.privatekey_file), True) os.unlink(self.privatekey_file.name) os.unlink(self.cert_file.name)
def test_edit_nomcom_view(self): r = self.access_chair_url(self.edit_nomcom_url) q = PyQuery(r.content) f = open(self.cert_file.name) response = self.client.post(self.edit_nomcom_url, { 'public_key': f, 'reminderdates_set-TOTAL_FORMS': q('input[name="reminderdates_set-TOTAL_FORMS"]').val(), 'reminderdates_set-INITIAL_FORMS': q('input[name="reminderdates_set-INITIAL_FORMS"]').val(), 'reminderdates_set-MAX_NUM_FORMS': q('input[name="reminderdates_set-MAX_NUM_FORMS"]').val(), }) f.close() self.assertEqual(response.status_code, 200) nominee = Nominee.objects.get(email__person__user__username=COMMUNITY_USER) position = Position.objects.get(name='OAM') comments = u'Plain text. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' nomcom = get_nomcom_by_year(self.year) feedback = Feedback.objects.create(nomcom=nomcom, comments=comments, type=FeedbackType.objects.get(slug='nomina')) feedback.positions.add(position) feedback.nominees.add(nominee) # to check feedback comments are saved like enrypted data self.assertNotEqual(feedback.comments, comments) self.assertEqual(check_comments(feedback.comments, comments, self.privatekey_file), True) self.client.logout()
def test_edit_nomcom_view(self): """Verify edit nomcom view""" self.access_chair_url(self.edit_nomcom_url) f = open(self.cert_file.name) response = self.client.post(self.edit_nomcom_url, {'public_key': f}) f.close() self.assertEqual(response.status_code, 200) nominee = Nominee.objects.get(email__person__name=COMMUNITY_USER) position = Position.objects.get(name='OAM') comments = u'Plain text. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' nomcom = get_nomcom_by_year(self.year) feedback = Feedback.objects.create( nomcom=nomcom, comments=comments, type=FeedbackType.objects.get(slug='nomina')) feedback.positions.add(position) feedback.nominees.add(nominee) # to check feedback comments are saved like enrypted data self.assertNotEqual(feedback.comments, comments) self.assertEqual( check_comments(feedback.comments, comments, self.privatekey_file), True) self.client.logout()
def test_edit_nomcom_view(self): """Verify edit nomcom view""" self.access_chair_url(self.edit_nomcom_url) f = open(self.cert_file.name) response = self.client.post(self.edit_nomcom_url, {'public_key': f}) f.close() self.assertEqual(response.status_code, 200) nominee = Nominee.objects.get(email__person__name=COMMUNITY_USER) position = Position.objects.get(name='OAM') comments = u'Plain text. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' nomcom = get_nomcom_by_year(self.year) feedback = Feedback.objects.create(nomcom=nomcom, comments=comments, type=FeedbackType.objects.get(slug='nomina')) feedback.positions.add(position) feedback.nominees.add(nominee) # to check feedback comments are saved like enrypted data self.assertNotEqual(feedback.comments, comments) self.assertEqual(check_comments(feedback.comments, comments, self.privatekey_file), True) self.client.logout()
def add_questionnaire(self, *args, **kwargs): public = kwargs.pop('public', False) nominee_email = kwargs.pop('nominee_email', u'*****@*****.**') nominator_email = kwargs.pop('nominator_email', "%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN)) position_name = kwargs.pop('position', 'IAOC') self.nominate_view(public=public, nominee_email=nominee_email, position=position_name, nominator_email=nominator_email) response = self.client.get(self.add_questionnaire_url) self.assertEqual(response.status_code, 200) nomcom = get_nomcom_by_year(self.year) if not nomcom.public_key: self.assertNotContains(response, "questionnnaireform") # save the cert file in tmp nomcom.public_key.storage.location = tempfile.gettempdir() nomcom.public_key.save('cert', File(open(self.cert_file.name, 'r'))) response = self.client.get(self.add_questionnaire_url) self.assertEqual(response.status_code, 200) self.assertContains(response, "questionnnaireform") position = Position.objects.get(name=position_name) nominee = Nominee.objects.get(email__address=nominee_email) comments = u'Test add questionnaire view. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' test_data = { 'comments': comments, 'nominee': '%s_%s' % (position.id, nominee.id) } response = self.client.post(self.add_questionnaire_url, test_data) self.assertEqual(response.status_code, 200) self.assertContains(response, "info-message-success") ## check objects feedback = Feedback.objects.filter( positions__in=[position], nominees__in=[nominee], type=FeedbackType.objects.get(slug='questio')).latest('id') ## to check feedback comments are saved like enrypted data self.assertNotEqual(feedback.comments, comments) self.assertEqual( check_comments(feedback.comments, comments, self.privatekey_file), True)
def add_questionnaire(self, *args, **kwargs): public = kwargs.pop('public', False) nominee_email = kwargs.pop('nominee_email', u'*****@*****.**') nominator_email = kwargs.pop('nominator_email', "%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN)) position_name = kwargs.pop('position', 'IAOC') self.nominate_view(public=public, nominee_email=nominee_email, position=position_name, nominator_email=nominator_email) response = self.client.get(self.add_questionnaire_url) self.assertEqual(response.status_code, 200) nomcom = get_nomcom_by_year(self.year) if not nomcom.public_key: self.assertNotContains(response, "questionnnaireform") # save the cert file in tmp nomcom.public_key.storage.location = tempfile.gettempdir() nomcom.public_key.save('cert', File(open(self.cert_file.name, 'r'))) response = self.client.get(self.add_questionnaire_url) self.assertEqual(response.status_code, 200) self.assertContains(response, "questionnnaireform") position = Position.objects.get(name=position_name) nominee = Nominee.objects.get(email__address=nominee_email) comments = u'Test add questionnaire view. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' test_data = {'comments': comments, 'nominee': '%s_%s' % (position.id, nominee.id)} response = self.client.post(self.add_questionnaire_url, test_data) self.assertEqual(response.status_code, 200) self.assertContains(response, "info-message-success") ## check objects feedback = Feedback.objects.filter(positions__in=[position], nominees__in=[nominee], type=FeedbackType.objects.get(slug='questio')).latest('id') ## to check feedback comments are saved like enrypted data self.assertNotEqual(feedback.comments, comments) self.assertEqual(check_comments(feedback.comments, comments, self.privatekey_file), True)
def test_encrypted_comments(self): nominee = Nominee.objects.get(email__person__user__username=COMMUNITY_USER) position = Position.objects.get(name='OAM') nomcom = position.nomcom # save the cert file in tmp nomcom.public_key.storage.location = tempfile.gettempdir() nomcom.public_key.save('cert', File(open(self.cert_file.name, 'r'))) comments = u'Plain text. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' feedback = Feedback.objects.create(nomcom=nomcom, comments=comments, type=FeedbackType.objects.get(slug='nomina')) feedback.positions.add(position) feedback.nominees.add(nominee) # to check feedback comments are saved like enrypted data self.assertNotEqual(feedback.comments, comments) self.assertEqual(check_comments(feedback.comments, comments, self.privatekey_file), True)
def feedback_view(self, *args, **kwargs): public = kwargs.pop('public', True) nominee_email = kwargs.pop('nominee_email', u'*****@*****.**') nominator_email = kwargs.pop('nominator_email', "%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN)) position_name = kwargs.pop('position', 'IAOC') self.nominate_view(public=public, nominee_email=nominee_email, position=position_name, nominator_email=nominator_email) feedback_url = self.public_feedback_url if not public: feedback_url = self.private_feedback_url response = self.client.get(feedback_url) self.assertEqual(response.status_code, 200) nomcom = get_nomcom_by_year(self.year) if not nomcom.public_key: self.assertNotContains(response, "feedbackform") # save the cert file in tmp nomcom.public_key.storage.location = tempfile.gettempdir() nomcom.public_key.save('cert', File(open(self.cert_file.name, 'r'))) response = self.client.get(feedback_url) self.assertEqual(response.status_code, 200) self.assertContains(response, "feedbackform") position = Position.objects.get(name=position_name) nominee = Nominee.objects.get(email__address=nominee_email) comments = u'Test feedback view. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' test_data = {'comments': comments, 'position_name': position.name, 'nominee_name': nominee.email.person.name, 'nominee_email': nominee.email.address} if public: test_data['nominator_email'] = nominator_email test_data['nominator_name'] = nominator_email feedback_url += "?nominee=%d&position=%d" % (nominee.id, position.id) nominee_position = NomineePosition.objects.get(nominee=nominee, position=position) state = nominee_position.state if not state.slug == 'accepted': response = self.client.post(feedback_url, test_data) self.assertEqual(response.status_code, 200) self.assertContains(response, "info-message-error") # accept nomination nominee_position.state = NomineePositionState.objects.get(slug='accepted') nominee_position.save() response = self.client.post(feedback_url, test_data) self.assertEqual(response.status_code, 200) self.assertContains(response, "info-message-success") ## check objects feedback = Feedback.objects.filter(positions__in=[position], nominees__in=[nominee], type=FeedbackType.objects.get(slug='comment')).latest('id') if public: self.assertEqual(feedback.author, nominator_email) ## to check feedback comments are saved like enrypted data self.assertNotEqual(feedback.comments, comments) self.assertEqual(check_comments(feedback.comments, comments, self.privatekey_file), True) # recovery state if state != nominee_position.state: nominee_position.state = state nominee_position.save()
def nominate_view(self, *args, **kwargs): public = kwargs.pop('public', True) nominee_email = kwargs.pop('nominee_email', u'*****@*****.**') nominator_email = kwargs.pop('nominator_email', "%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN)) position_name = kwargs.pop('position', 'IAOC') if public: nominate_url = self.public_nominate_url else: nominate_url = self.private_nominate_url response = self.client.get(nominate_url) self.assertEqual(response.status_code, 200) nomcom = get_nomcom_by_year(self.year) if not nomcom.public_key: self.assertNotContains(response, "nominateform") # save the cert file in tmp nomcom.public_key.storage.location = tempfile.gettempdir() nomcom.public_key.save('cert', File(open(self.cert_file.name, 'r'))) response = self.client.get(nominate_url) self.assertEqual(response.status_code, 200) self.assertContains(response, "nominateform") position = Position.objects.get(name=position_name) candidate_email = nominee_email candidate_name = u'nominee' comments = u'Test nominate view. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' candidate_phone = u'123456' test_data = {'candidate_name': candidate_name, 'candidate_email': candidate_email, 'candidate_phone': candidate_phone, 'position': position.id, 'comments': comments} if not public: test_data['nominator_email'] = nominator_email response = self.client.post(nominate_url, test_data) self.assertEqual(response.status_code, 200) self.assertContains(response, "info-message-success") # check objects email = Email.objects.get(address=candidate_email) Person.objects.get(name=candidate_name, address=candidate_email) nominee = Nominee.objects.get(email=email) NomineePosition.objects.get(position=position, nominee=nominee) feedback = Feedback.objects.filter(positions__in=[position], nominees__in=[nominee], type=FeedbackType.objects.get(slug='nomina')).latest('id') if public: self.assertEqual(feedback.author, nominator_email) # to check feedback comments are saved like enrypted data self.assertNotEqual(feedback.comments, comments) self.assertEqual(check_comments(feedback.comments, comments, self.privatekey_file), True) Nomination.objects.get(position=position, candidate_name=candidate_name, candidate_email=candidate_email, candidate_phone=candidate_phone, nominee=nominee, comments=feedback, nominator_email="%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN))
def feedback_view(self, *args, **kwargs): public = kwargs.pop('public', True) nominee_email = kwargs.pop('nominee_email', u'*****@*****.**') nominator_email = kwargs.pop('nominator_email', "%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN)) position_name = kwargs.pop('position', 'IAOC') self.nominate_view(public=public, nominee_email=nominee_email, position=position_name, nominator_email=nominator_email) feedback_url = self.public_feedback_url if not public: feedback_url = self.private_feedback_url response = self.client.get(feedback_url) self.assertEqual(response.status_code, 200) nomcom = get_nomcom_by_year(self.year) if not nomcom.public_key: self.assertNotContains(response, "feedbackform") # save the cert file in tmp nomcom.public_key.storage.location = tempfile.gettempdir() nomcom.public_key.save('cert', File(open(self.cert_file.name, 'r'))) response = self.client.get(feedback_url) self.assertEqual(response.status_code, 200) self.assertContains(response, "feedbackform") position = Position.objects.get(name=position_name) nominee = Nominee.objects.get(email__address=nominee_email) comments = u'Test feedback view. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' test_data = { 'comments': comments, 'position_name': position.name, 'nominee_name': nominee.email.person.name, 'nominee_email': nominee.email.address } if public: test_data['nominator_email'] = nominator_email test_data['nominator_name'] = nominator_email feedback_url += "?nominee=%d&position=%d" % (nominee.id, position.id) nominee_position = NomineePosition.objects.get(nominee=nominee, position=position) state = nominee_position.state if not state.slug == 'accepted': response = self.client.post(feedback_url, test_data) self.assertEqual(response.status_code, 200) self.assertContains(response, "info-message-error") # accept nomination nominee_position.state = NomineePositionState.objects.get( slug='accepted') nominee_position.save() response = self.client.post(feedback_url, test_data) self.assertEqual(response.status_code, 200) self.assertContains(response, "info-message-success") ## check objects feedback = Feedback.objects.filter( positions__in=[position], nominees__in=[nominee], type=FeedbackType.objects.get(slug='comment')).latest('id') if public: self.assertEqual(feedback.author, nominator_email) ## to check feedback comments are saved like enrypted data self.assertNotEqual(feedback.comments, comments) self.assertEqual( check_comments(feedback.comments, comments, self.privatekey_file), True) # recovery state if state != nominee_position.state: nominee_position.state = state nominee_position.save()
def nominate_view(self, *args, **kwargs): public = kwargs.pop('public', True) nominee_email = kwargs.pop('nominee_email', u'*****@*****.**') nominator_email = kwargs.pop('nominator_email', "%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN)) position_name = kwargs.pop('position', 'IAOC') if public: nominate_url = self.public_nominate_url else: nominate_url = self.private_nominate_url response = self.client.get(nominate_url) self.assertEqual(response.status_code, 200) nomcom = get_nomcom_by_year(self.year) if not nomcom.public_key: self.assertNotContains(response, "nominateform") # save the cert file in tmp nomcom.public_key.storage.location = tempfile.gettempdir() nomcom.public_key.save('cert', File(open(self.cert_file.name, 'r'))) response = self.client.get(nominate_url) self.assertEqual(response.status_code, 200) self.assertContains(response, "nominateform") position = Position.objects.get(name=position_name) candidate_email = nominee_email candidate_name = u'nominee' comments = u'Test nominate view. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.' candidate_phone = u'123456' test_data = { 'candidate_name': candidate_name, 'candidate_email': candidate_email, 'candidate_phone': candidate_phone, 'position': position.id, 'comments': comments } if not public: test_data['nominator_email'] = nominator_email response = self.client.post(nominate_url, test_data) self.assertEqual(response.status_code, 200) self.assertContains(response, "info-message-success") # check objects email = Email.objects.get(address=candidate_email) Person.objects.get(name=candidate_name, address=candidate_email) nominee = Nominee.objects.get(email=email) NomineePosition.objects.get(position=position, nominee=nominee) feedback = Feedback.objects.filter( positions__in=[position], nominees__in=[nominee], type=FeedbackType.objects.get(slug='nomina')).latest('id') if public: self.assertEqual(feedback.author, nominator_email) # to check feedback comments are saved like enrypted data self.assertNotEqual(feedback.comments, comments) self.assertEqual( check_comments(feedback.comments, comments, self.privatekey_file), True) Nomination.objects.get(position=position, candidate_name=candidate_name, candidate_email=candidate_email, candidate_phone=candidate_phone, nominee=nominee, comments=feedback, nominator_email="%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN))