Example #1
0
        def test_z_urllib2_opener(self):
            pid = self.start_server(self.args)
            try:
                ctx = SSL.Context()

                from M2Crypto import m2urllib2
                opener = m2urllib2.build_opener(ctx, m2urllib2.HTTPBasicAuthHandler())
                m2urllib2.install_opener(opener)
                req = m2urllib2.Request('https://%s:%s/' % (srv_host, self.srv_port))
                u = m2urllib2.urlopen(req)
                data = u.read()
                u.close()
            finally:
                self.stop_server(pid)
            self.failIf(string.find(data, 's_server -quiet -www') == -1)
Example #2
0
        def test_z_urllib2_opener(self):
            pid = self.start_server(self.args)
            try:
                ctx = SSL.Context()

                from M2Crypto import m2urllib2
                opener = m2urllib2.build_opener(ctx, m2urllib2.HTTPBasicAuthHandler())
                m2urllib2.install_opener(opener)
                req = m2urllib2.Request('https://%s:%s/' % (srv_host, srv_port))
                u = m2urllib2.urlopen(req)
                data = u.read()
                u.close()
            finally:
                self.stop_server(pid)
            self.failIf(string.find(data, 's_server -quiet -www') == -1)
Example #3
0
    def test_z_urllib2_opener(self):
        pid = self.start_server(self.args)
        try:
            ctx = SSL.Context()

            opener = m2urllib2.build_opener(
                ctx, m2urllib2.HTTPBasicAuthHandler())
            m2urllib2.install_opener(opener)
            req = m2urllib2.Request('https://%s:%s/' %
                                    (srv_host, self.srv_port))
            u = m2urllib2.urlopen(req)
            data = u.read()
            u.close()
        finally:
            self.stop_server(pid)
        self.assertIn(b's_server -quiet -www', data)
Example #4
0
    def test_z_urllib2_opener(self):
        pid = self.start_server(self.args)
        try:
            ctx = SSL.Context()

            opener = m2urllib2.build_opener(
                ctx, m2urllib2.HTTPBasicAuthHandler())
            m2urllib2.install_opener(opener)
            req = m2urllib2.Request('https://%s:%s/' %
                                    (srv_host, self.srv_port))
            u = m2urllib2.urlopen(req)
            data = u.read()
            u.close()
        finally:
            self.stop_server(pid)
        self.assertIn(b's_server -quiet -www', data)
    'success'          : 'https://login.m.o2online.de/ndm/?url=o2activehome&',
    'id13_hf_0'        : ''
}

login_data_encoded = m2urllib.urlencode(login_form_data)

ctx = SSL.Context()

# If you comment out the next 2 lines, the connection won't be secure
ctx.set_verify(SSL.verify_peer | SSL.verify_fail_if_no_peer_cert, depth=9)
ctx.load_verify_locations(O2_SSL_CERTIFICATE)
c = SSL.Connection(ctx)

cj = cookielib.CookieJar()
opener = m2urllib2.build_opener(ctx, m2urllib2.HTTPCookieProcessor(cj))
m2urllib2.install_opener(opener)

print "processing"
try:
    ctx.load_verify_locations(O2_SSL_CERTIFICATE)
    # login
    resp = opener.open(O2_LOGIN, login_data_encoded)
    ctx.load_verify_locations(O2_SSL_CERTIFICATE)

    # go to billing page
    resp = opener.open('http://m.o2online.de/vertrag/rechnung/aktuelle-rechnung')
    last_respone = resp.read();

    print "get billing page"

    parser = MyHtmlParser(