Beispiel #1
0
    def curl_upload_and_verify(self, fname, options=None):
        url = TestEnv.mkurl("https", "cgi", "/upload.py")
        fpath = os.path.join(TestEnv.GEN_DIR, fname)
        r = TestEnv.curl_upload(url, fpath, options=options)
        assert r["rv"] == 0
        assert r["response"]["status"] >= 200 and r["response"]["status"] < 300

        r2 = TestEnv.curl_get( r["response"]["header"]["location"])
        assert r2["rv"] == 0
        assert r2["response"]["status"] == 200 
        with open(TestEnv.e2e_src( fpath ), mode='rb') as file:
            src = file.read()
        assert src == r2["response"]["body"]
Beispiel #2
0
    def curl_upload_and_verify(self, fname, options=None):
        url = TestEnv.mkurl("https", "cgi", "/upload.py")
        fpath = os.path.join(TestEnv.GEN_DIR, fname)
        r = TestEnv.curl_upload(url, fpath, options=options)
        assert r["rv"] == 0
        assert r["response"]["status"] >= 200 and r["response"]["status"] < 300

        r2 = TestEnv.curl_get(r["response"]["header"]["location"])
        assert r2["rv"] == 0
        assert r2["response"]["status"] == 200
        with open(TestEnv.e2e_src(fpath), mode='rb') as file:
            src = file.read()
        assert src == r2["response"]["body"]
Beispiel #3
0
    def curl_upload_and_verify(self, fname, options=None):
        url = TestEnv.mkurl("https", "cgi", "/proxy/upload.py")
        fpath = os.path.join(TestEnv.GEN_DIR, fname)
        r = TestEnv.curl_upload(url, fpath, options=options)
        assert r["rv"] == 0
        assert 200 <= r["response"]["status"] < 300

        # why is the scheme wrong?
        r2 = TestEnv.curl_get(
            re.sub(r'http:', 'https:', r["response"]["header"]["location"]))
        assert r2["rv"] == 0
        assert r2["response"]["status"] == 200
        with open(TestEnv.e2e_src(fpath), mode='rb') as file:
            src = file.read()
        assert src == r2["response"]["body"]
Beispiel #4
0
        def post_and_verify(fname, options=None):
            url = TestEnv.mkurl("https", "cgi", "/h2test/echo")
            fpath = os.path.join(TestEnv.GEN_DIR, fname)
            r = TestEnv.curl_upload(url, fpath, options=options)
            assert r["rv"] == 0
            assert r["response"]["status"] >= 200 and r["response"][
                "status"] < 300

            ct = r["response"]["header"]["content-type"]
            mail_hd = "Content-Type: " + ct + "\r\nMIME-Version: 1.0\r\n\r\n"
            mime_msg = mail_hd.encode() + r["response"]["body"]
            # this MIME API is from hell
            body = email.parser.BytesParser().parsebytes(mime_msg)
            assert body
            assert body.is_multipart()
            filepart = None
            for part in body.walk():
                if fname == part.get_filename():
                    filepart = part
            assert filepart
            with open(TestEnv.e2e_src(fpath), mode='rb') as file:
                src = file.read()
            assert src == filepart.get_payload(decode=True)