Changeset 94d9511 for protocols/skype
- Timestamp:
- 2013-02-17T19:51:11Z (12 years ago)
- Branches:
- master
- Children:
- 9754c2f
- Parents:
- 130f7b8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/skype/test.py
r130f7b8 r94d9511 9 9 import hashlib 10 10 11 def openssl(args): 12 with open(os.devnull, "w") as devnull: 13 proc = subprocess.Popen(['openssl'] + args, stdin=subprocess.PIPE, stderr=devnull) 14 for i in range(6): 15 proc.stdin.write("\n") 16 proc.stdin.close() 17 proc.communicate() 18 def setupSkyped(): 19 try: 20 shutil.rmtree("t/skyped") 21 except OSError: 22 pass 23 os.makedirs("t/skyped") 24 cwd = os.getcwd() 25 os.chdir("t/skyped") 26 try: 27 shutil.copyfile("../../skyped.cnf", "skyped.cnf") 28 openssl(['req', '-new', '-x509', '-days', '365', '-nodes', '-config', 'skyped.cnf', '-out', 'skyped.cert.pem', '-keyout', 'skyped.key.pem']) 29 with open("skyped.conf", "w") as sock: 30 sock.write("[skyped]\n") 31 sock.write("username = alice\n") 32 sock.write("password = %s\n" % hashlib.sha1("foo").hexdigest()) 33 sock.write("cert = %s/skyped.cert.pem\n" % os.getcwd()) 34 sock.write("key = %s/skyped.key.pem\n" % os.getcwd()) 35 sock.write("port = 2727\n") 36 finally: 37 os.chdir(cwd) 38 11 39 class Test(unittest.TestCase): 12 def openssl(self, args):13 with open(os.devnull, "w") as devnull:14 proc = subprocess.Popen(['openssl'] + args, stdin=subprocess.PIPE, stderr=devnull)15 for i in range(6):16 proc.stdin.write("\n")17 proc.stdin.close()18 proc.communicate()19 40 def mock(self, name): 20 41 with open("t/skyped.log", "w") as skyped_log,\ … … 58 79 pass 59 80 os.makedirs("t/bitlbee") 60 61 try:62 shutil.rmtree("t/skyped")63 except OSError:64 pass65 os.makedirs("t/skyped")66 cwd = os.getcwd()67 os.chdir("t/skyped")68 try:69 shutil.copyfile("../../skyped.cnf", "skyped.cnf")70 self.openssl(['req', '-new', '-x509', '-days', '365', '-nodes', '-config', 'skyped.cnf', '-out', 'skyped.cert.pem', '-keyout', 'skyped.key.pem'])71 with open("skyped.conf", "w") as sock:72 sock.write("[skyped]\n")73 sock.write("username = alice\n")74 sock.write("password = %s\n" % hashlib.sha1("foo").hexdigest())75 sock.write("cert = %s/skyped.cert.pem\n" % os.getcwd())76 sock.write("key = %s/skyped.key.pem\n" % os.getcwd())77 sock.write("port = 2727\n")78 finally:79 os.chdir(cwd)80 81 81 82 82 def testMsg(self): … … 129 129 130 130 if __name__ == '__main__': 131 setupSkyped() 131 132 unittest.main()
Note: See TracChangeset
for help on using the changeset viewer.