# Path: gmeutils/dkim.py
# class mydkim(_gmechild):
# 
# 	def __init__(self,parent,selector,domain,privkey):
# 		_gmechild.__init__(self,parent,filename=__file__)
# 		self.selector=selector
# 		self.domain=domain
# 		self.privkey=None
# 
# 		try:
# 			with open(os.path.expanduser(privkey),"rb") as f:
# 				self.privkey=f.read()
# 		except:
# 			self.log("Could not read DKIM key","e")
# 			self.log_traceback()
# 
# 	def sign_mail(self,mail):
# 		origmail=email.message_from_string(mail)
# 
# 		if "DKIM-Signature" in origmail:
# 			del origmail["DKIM-Signature"]
# 
# 		try:
# 			_res=dkim.sign(	mail.encode("UTF-8",unicodeerror),
# 						self.selector.encode("UTF-8",unicodeerror),
# 						self.domain.encode("UTF-8",unicodeerror),
# 						self.privkey).decode("UTF-8",unicodeerror)
# 			msg=_res.split(":",1)[1]
# 			origmail["DKIM-Signature"]=msg
# 			return origmail.as_string()
# 		except:
# 			self.log("Error executing dkim.sign_mail","e")
# 			self.log_traceback()
# 			return mail


import unittest,sys,tempfile
import gpgmailencrypt
import gmeutils.helpers
import gmeutils.archivemanagers
import gmeutils.virusscanners
import gmeutils.spamscanners
import gmeutils.gpgmailserver
import email
import filecmp
import glob
import os
import os.path
import shutil
import time
		import sqlite3
		import sqlite3
from   gmeutils.dkim	import mydkim
from multiprocessing import Process
		"virusscanner fprot not found")
	def test_fprotnovirus(self):
		virusdir="./smime"
		self.assertFalse(check_virus("fprot",virusdir))

	@unittest.skipIf(not has_scanner("sophos"),
		"virusscanner sophos not found")
	def test_sophosvirus(self):
		virusdir="./virus"
		self.assertTrue(check_virus("sophos",virusdir))

	@unittest.skipIf(not has_scanner("sophos"),
		"virusscanner sophos not found")
	def test_sophosnovirus(self):
		virusdir="./smime"
		self.assertFalse(check_virus("sophos",virusdir))

#########
#DKIMTEST
#########
class dkimtests(unittest.TestCase):

	def setUp(self):
		self.gme=gpgmailencrypt.gme()
		self.gme.set_configfile("./gmetest.conf")

	def tearDown(self):
		self.gme.close()

	def test_dkimsign(self):

# Path: gmeutils/dkim.py
# class mydkim(_gmechild):
# 
# 	def __init__(self,parent,selector,domain,privkey):
# 		_gmechild.__init__(self,parent,filename=__file__)
# 		self.selector=selector
# 		self.domain=domain
# 		self.privkey=None
# 
# 		try:
# 			with open(os.path.expanduser(privkey),"rb") as f:
# 				self.privkey=f.read()
# 		except:
# 			self.log("Could not read DKIM key","e")
# 			self.log_traceback()
# 
# 	def sign_mail(self,mail):
# 		origmail=email.message_from_string(mail)
# 
# 		if "DKIM-Signature" in origmail:
# 			del origmail["DKIM-Signature"]
# 
# 		try:
# 			_res=dkim.sign(	mail.encode("UTF-8",unicodeerror),
# 						self.selector.encode("UTF-8",unicodeerror),
# 						self.domain.encode("UTF-8",unicodeerror),
# 						self.privkey).decode("UTF-8",unicodeerror)
# 			msg=_res.split(":",1)[1]
# 			origmail["DKIM-Signature"]=msg
# 			return origmail.as_string()
# 		except:
# 			self.log("Error executing dkim.sign_mail","e")
# 			self.log_traceback()
# 			return mail


# Path: tests/gmeunittests.py
import unittest,sys,tempfile
import gpgmailencrypt
import gmeutils.helpers
import gmeutils.archivemanagers
import gmeutils.virusscanners
import gmeutils.spamscanners
import gmeutils.gpgmailserver
import email
import filecmp
import glob
import os
import os.path
import shutil
import time
		import sqlite3
		import sqlite3
from   gmeutils.dkim	import mydkim
from multiprocessing import Process

		"virusscanner fprot not found")
	def test_fprotnovirus(self):
		virusdir="./smime"
		self.assertFalse(check_virus("fprot",virusdir))

	@unittest.skipIf(not has_scanner("sophos"),
		"virusscanner sophos not found")
	def test_sophosvirus(self):
		virusdir="./virus"
		self.assertTrue(check_virus("sophos",virusdir))

	@unittest.skipIf(not has_scanner("sophos"),
		"virusscanner sophos not found")
	def test_sophosnovirus(self):
		virusdir="./smime"
		self.assertFalse(check_virus("sophos",virusdir))

#########
#DKIMTEST
#########
class dkimtests(unittest.TestCase):

	def setUp(self):
		self.gme=gpgmailencrypt.gme()
		self.gme.set_configfile("./gmetest.conf")

	def tearDown(self):
		self.gme.close()

	def test_dkimsign(self):

		dk=mydkim(	parent=self.gme,