1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <memory>
6 #include <string>
7
8 #include "net/base/network_isolation_key.h"
9 #include "net/dns/mock_host_resolver.h"
10 #include "net/http/http_auth_handler.h"
11 #include "net/http/http_auth_handler_basic.h"
12 #include "net/log/net_log_with_source.h"
13 #include "net/ssl/ssl_info.h"
14 #include "url/gurl.h"
15 #include "url/scheme_host_port.h"
16
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)17 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
18 std::string input(reinterpret_cast<const char*>(data), size);
19 std::string challenge = "Basic " + input;
20
21 // Dummies
22 net::SSLInfo null_ssl_info;
23 url::SchemeHostPort scheme_host_port(GURL("https://foo.test/"));
24 auto host_resolver = std::make_unique<net::MockHostResolver>();
25 std::unique_ptr<net::HttpAuthHandler> basic;
26
27 net::HttpAuthHandlerBasic::Factory factory;
28 factory.CreateAuthHandlerFromString(
29 challenge, net::HttpAuth::AUTH_SERVER, null_ssl_info,
30 net::NetworkAnonymizationKey(), scheme_host_port, net::NetLogWithSource(),
31 host_resolver.get(), &basic);
32 return 0;
33 }
34