def accountant_mail(appstruct): """ this function returns a message object for the mailer it consists of a mail body and an attachment attached to it """ unencrypted = make_mail_body(appstruct) #print("accountant_mail: mail body: \n%s") % unencrypted #print("accountant_mail: type of mail body: %s") % type(unencrypted) encrypted = encrypt_with_gnupg(unencrypted) #print("accountant_mail: mail body (enc'd): \n%s") % encrypted #print("accountant_mail: type of mail body (enc'd): %s") % type(encrypted) message = Message(subject="[C3S] Yes! a new letter of intent", sender="*****@*****.**", recipients=["*****@*****.**"], body=encrypted) #print("accountant_mail: csv_payload: \n%s") % generate_csv(appstruct) #print( # "accountant_mail: type of csv_payload: \n%s" #) % type(generate_csv(appstruct)) csv_payload_encd = encrypt_with_gnupg(generate_csv(appstruct)) #print("accountant_mail: csv_payload_encd: \n%s") % csv_payload_encd #print( # "accountant_mail: type of csv_payload_encd: \n%s" #) % type(csv_payload_encd) attachment = Attachment("DOI.csv.gpg", "application/gpg-encryption", csv_payload_encd) message.attach(attachment) return message
def accountant_mail(appstruct): """ this function returns a message object for the mailer it consists of a mail body and an attachment attached to it """ unencrypted = make_mail_body(appstruct) #print("accountant_mail: mail body: \n%s") % unencrypted #print("accountant_mail: type of mail body: %s") % type(unencrypted) encrypted = encrypt_with_gnupg(unencrypted) #print("accountant_mail: mail body (enc'd): \n%s") % encrypted #print("accountant_mail: type of mail body (enc'd): %s") % type(encrypted) message = Message( subject="[C3S] Yes! a new letter of intent", sender="*****@*****.**", recipients=["*****@*****.**"], body=encrypted ) #print("accountant_mail: csv_payload: \n%s") % generate_csv(appstruct) #print( # "accountant_mail: type of csv_payload: \n%s" #) % type(generate_csv(appstruct)) csv_payload_encd = encrypt_with_gnupg(generate_csv(appstruct)) #print("accountant_mail: csv_payload_encd: \n%s") % csv_payload_encd #print( # "accountant_mail: type of csv_payload_encd: \n%s" #) % type(csv_payload_encd) attachment = Attachment( "DOI.csv.gpg", "application/gpg-encryption", csv_payload_encd) message.attach(attachment) return message
def accountant_mail(appstruct): unencrypted = u""" Yay! we got a declaration of intent through the form: \n firstname: \t\t %s lastname: \t\t %s email: \t\t %s street & no: \t\t %s address2: \t\t %s postcode: \t\t %s city: \t\t %s country: \t\t %s activities: \t\t %s created3: \t\t $s member of collecting society: %s understood declaration text: %s consider joining \t %s noticed data protection: \t %s that's it.. bye!""" % ( unicode(appstruct['firstname']), unicode(appstruct['lastname']), unicode(appstruct['email']), unicode(appstruct['address1']), unicode(appstruct['address2']), unicode(appstruct['postCode']), unicode(appstruct['city']), unicode(appstruct['country']), unicode(appstruct['at_least_three_works']), unicode(appstruct['member_of_colsoc']), unicode(appstruct['understood_declaration']), unicode(appstruct['consider_joining']), unicode(appstruct['noticed_dataProtection']), ) message = Message( subject="[c3s] Yes! a new letter of intent", sender="*****@*****.**", recipients=["*****@*****.**"], body=str(encrypt_with_gnupg((unencrypted))) ) attachment = Attachment("foo.gpg", "application/gpg-encryption", unicode(encrypt_with_gnupg(u"foo to the bar!"))) # TODO: make attachment contents a .csv with the data supplied. message.attach(attachment) return message
def accountant_mail(appstruct): unencrypted = make_mail_body(appstruct) message = Message(subject="[c3s] Yes! a new letter of intent", sender="*****@*****.**", recipients=["*****@*****.**"], body=unicode(encrypt_with_gnupg((unencrypted)))) attachment = Attachment("foo.gpg", "application/gpg-encryption", unicode(encrypt_with_gnupg(u"foo to the bar!"))) # TODO: make attachment contents a .csv with the data supplied. message.attach(attachment) return message
def test_encrypt_with_gnupg_import_key(self): from c3sintent.gnupg_encrypt import encrypt_with_gnupg os.unlink('keys/pubring.gpg') result = encrypt_with_gnupg('foo') #print ("the result: " + str(result)) self.assertTrue('-----BEGIN PGP MESSAGE-----' in str(result)) self.assertTrue('-----END PGP MESSAGE-----' in str(result))
def accountant_mail(appstruct): unencrypted = make_mail_body(appstruct) message = Message( subject="[c3s] Yes! a new letter of intent", sender="*****@*****.**", recipients=["*****@*****.**"], body=unicode(encrypt_with_gnupg((unencrypted))) ) attachment = Attachment("foo.gpg", "application/gpg-encryption", unicode(encrypt_with_gnupg(u"foo to the bar!"))) # TODO: make attachment contents a .csv with the data supplied. message.attach(attachment) return message
def test_encrypt_with_gnupg_import_key(self): """ test if encryption produces any result at all """ from c3sintent.gnupg_encrypt import encrypt_with_gnupg result = encrypt_with_gnupg('foo') #print ("the result: " + str(result)) self.assertTrue('-----BEGIN PGP MESSAGE-----' in str(result)) self.assertTrue('-----END PGP MESSAGE-----' in str(result))
def test_encrypt_with_gnupg_w_umlauts(self): """ test if unicode input is acceptable and digested """ from c3sintent.gnupg_encrypt import encrypt_with_gnupg result = encrypt_with_gnupg(u'f**k the umläuts') #print ("the result: " + str(result)) self.assertTrue('-----BEGIN PGP MESSAGE-----' in str(result)) self.assertTrue('-----END PGP MESSAGE-----' in str(result))
def test_encrypt_with_gnupg_w_umlauts(self): from c3sintent.gnupg_encrypt import encrypt_with_gnupg result = unicode(encrypt_with_gnupg(u'füöß')) #print ("the result: " + str(result)) self.assertTrue('-----BEGIN PGP MESSAGE-----' in str(result)) self.assertTrue('-----END PGP MESSAGE-----' in str(result))
def test_encrypt_with_gnupg(self): from c3sintent.gnupg_encrypt import encrypt_with_gnupg result = encrypt_with_gnupg('foo') #print ("the result: " + str(result)) self.assertTrue('-----BEGIN PGP MESSAGE-----' in str(result)) self.assertTrue('-----END PGP MESSAGE-----' in str(result))