sogo/Tests/Integration/sogoLogin.py
Wolfgang Sourdeau 4e13c0b73c Monotone-Parent: 7ee997ad520d61e48d2f051e02d433791c47fd08
Monotone-Revision: c37895534ea03712cf65f5760bc535177a041d99

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2011-04-01T19:43:11
Monotone-Branch: ca.inverse.sogo
2011-04-01 19:43:11 +00:00

30 lines
734 B
Python

#!/usr/bin/python
from config import hostname, port, username, password
import webdavlib
import urllib
import urllib2
import base64
import simplejson
import cookielib
def getAuthCookie(hostname, port, username, password) :
cjar = cookielib.CookieJar();
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cjar))
urllib2.install_opener(opener)
creds = urllib.urlencode([("userName",username), ("password", password)])
req = urllib2.Request("http://%s/SOGo/connect" % hostname, creds)
fd = urllib2.urlopen(req)
#print fd.info()
for cookie in cjar :
if cookie.name == "0xHIGHFLYxSOGo":
authinfo = cookie.value
break
return "0xHIGHFLYxSOGo="+authinfo
if __name__ == "__main__" :
getAuthCookie()