chromium/third_party/crashpad/crashpad/util/net/http_transport_test.cc

// Copyright 2014 The Crashpad Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "util/net/http_transport.h"

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#include <memory>
#include <utility>
#include <vector>

#include "base/files/file_path.h"
#include "base/format_macros.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "test/multiprocess_exec.h"
#include "test/test_paths.h"
#include "util/file/file_io.h"
#include "util/misc/random_string.h"
#include "util/net/http_body.h"
#include "util/net/http_headers.h"
#include "util/net/http_multipart_builder.h"

namespace crashpad {
namespace test {
namespace {

#if BUILDFLAG(IS_WIN)
std::string ToUTF8IfWin(const std::wstring& x) {
  return base::WideToUTF8(x);
}
#else
std::string ToUTF8IfWin(const std::string& x) {}
#endif

class HTTPTransportTestFixture : public MultiprocessExec {};

constexpr char kMultipartFormData[] =;

void GetHeaderField(const std::string& request,
                    const std::string& header,
                    std::string* value) {}

void GetMultipartBoundary(const std::string& request,
                          std::string* multipart_boundary) {}

constexpr char kBoundaryEq[] =;

void ValidFormData(HTTPTransportTestFixture* fixture,
                   const std::string& request) {}

class HTTPTransport : public testing::TestWithParam<std::string> {};

TEST_P(HTTPTransport, ValidFormData) {}

TEST_P(HTTPTransport, ValidFormData_Gzip) {}

constexpr char kTextPlain[] =;

void ErrorResponse(HTTPTransportTestFixture* fixture,
                   const std::string& request) {}

TEST_P(HTTPTransport, ErrorResponse) {}

constexpr char kTextBody[] =;

void UnchunkedPlainText(HTTPTransportTestFixture* fixture,
                        const std::string& request) {}

TEST_P(HTTPTransport, UnchunkedPlainText) {}

void RunUpload33k(const std::string& scheme, bool has_content_length) {}

TEST_P(HTTPTransport, Upload33k) {}

TEST_P(HTTPTransport, Upload33k_LengthUnknown) {}

// This should be on for Fuchsia, but DX-382. Debug and re-enabled.
#if defined(CRASHPAD_USE_BORINGSSL) && !BUILDFLAG(IS_FUCHSIA)
// The test server requires BoringSSL or OpenSSL, so https in tests can only be
// enabled where that's readily available. Additionally on Linux, the bots fail
// lacking libcrypto.so.1.1, so disabled there for now. On Mac, they could also
// likely be enabled relatively easily, if HTTPTransportMac learned to respect
// the user-supplied cert.
//
// If tests with boringssl are failing because of expired certificates, try
// re-running generate_test_server_key.py.
INSTANTIATE_TEST_SUITE_P();
#else
INSTANTIATE_TEST_SUITE_P(HTTPTransport,
                         HTTPTransport,
                         testing::Values("http"),
                         [](const testing::TestParamInfo<std::string>& info) {
                           return info.param;
                         });
#endif

}  // namespace
}  // namespace test
}  // namespace crashpad