1 // Copyright 2023 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 "net/proxy_resolution/proxy_server_util_mac.h"
6
7 #include <CoreFoundation/CoreFoundation.h>
8 #include <SystemConfiguration/SystemConfiguration.h>
9
10 #include "base/apple/scoped_cftyperef.h"
11 #include "net/base/proxy_server.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace net {
15
16 // Test convert ProxyDictionary To ProxyServer with invalid inputs.
17 // https://crbug.com/1478580
TEST(ProxyServerUtilMacTest,InvalidProxyDictionaryToProxyServer)18 TEST(ProxyServerUtilMacTest, InvalidProxyDictionaryToProxyServer) {
19 CFStringRef host_key = CFSTR("HttpHost");
20 CFStringRef port_key = CFSTR("HttpPort");
21 CFStringRef value = CFSTR("127.1110.0.1");
22 const void* keys[] = {host_key};
23 const void* values[] = {value};
24 base::apple::ScopedCFTypeRef<CFDictionaryRef> invalid_ip_dict(
25 CFDictionaryCreate(kCFAllocatorDefault, keys, values, 1,
26 &kCFTypeDictionaryKeyCallBacks,
27 &kCFTypeDictionaryValueCallBacks));
28 ProxyServer proxy_server = ProxyDictionaryToProxyServer(
29 ProxyServer::SCHEME_HTTP, invalid_ip_dict.get(), host_key, port_key);
30 EXPECT_FALSE(proxy_server.is_valid());
31 }
32
33 } // namespace net
34