Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: net/http/http_server_properties_impl_unittest.cc

Issue 2070203002: Remove unused HttpServerProperites::ClearAlternativeServices (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@AltSvcClear
Patch Set: fix Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | net/http/http_server_properties_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_server_properties_impl.h" 5 #include "net/http/http_server_properties_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 // Check Alt-Svc list should not be set for |https_server|. 769 // Check Alt-Svc list should not be set for |https_server|.
770 url::SchemeHostPort https_server("https", "foo", 80); 770 url::SchemeHostPort https_server("https", "foo", 80);
771 EXPECT_EQ(0u, impl_.GetAlternativeServices(https_server).size()); 771 EXPECT_EQ(0u, impl_.GetAlternativeServices(https_server).size());
772 772
773 // Set Alt-Svc list for |https_server|. 773 // Set Alt-Svc list for |https_server|.
774 impl_.SetAlternativeServices(https_server, alternative_service_info_vector); 774 impl_.SetAlternativeServices(https_server, alternative_service_info_vector);
775 EXPECT_EQ(2u, impl_.GetAlternativeServices(https_server).size()); 775 EXPECT_EQ(2u, impl_.GetAlternativeServices(https_server).size());
776 EXPECT_EQ(2u, impl_.GetAlternativeServices(http_server).size()); 776 EXPECT_EQ(2u, impl_.GetAlternativeServices(http_server).size());
777 777
778 // Clear Alt-Svc list for |http_server|. 778 // Clear Alt-Svc list for |http_server|.
779 impl_.ClearAlternativeServices(http_server); 779 impl_.SetAlternativeServices(http_server, AlternativeServiceInfoVector());
780
780 EXPECT_EQ(0u, impl_.GetAlternativeServices(http_server).size()); 781 EXPECT_EQ(0u, impl_.GetAlternativeServices(http_server).size());
781 EXPECT_EQ(2u, impl_.GetAlternativeServices(https_server).size()); 782 EXPECT_EQ(2u, impl_.GetAlternativeServices(https_server).size());
782 } 783 }
783 784
784 TEST_F(AlternateProtocolServerPropertiesTest, ClearAlternativeServices) { 785 TEST_F(AlternateProtocolServerPropertiesTest, ClearAlternativeServices) {
785 AlternativeServiceInfoVector alternative_service_info_vector; 786 AlternativeServiceInfoVector alternative_service_info_vector;
786 const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo", 443); 787 const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo", 443);
787 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 788 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
788 alternative_service_info_vector.push_back( 789 alternative_service_info_vector.push_back(
789 AlternativeServiceInfo(alternative_service1, expiration)); 790 AlternativeServiceInfo(alternative_service1, expiration));
790 const AlternativeService alternative_service2(NPN_HTTP_2, "bar", 1234); 791 const AlternativeService alternative_service2(NPN_HTTP_2, "bar", 1234);
791 alternative_service_info_vector.push_back( 792 alternative_service_info_vector.push_back(
792 AlternativeServiceInfo(alternative_service2, expiration)); 793 AlternativeServiceInfo(alternative_service2, expiration));
793 url::SchemeHostPort test_server("http", "foo", 80); 794 url::SchemeHostPort test_server("http", "foo", 80);
794 impl_.SetAlternativeServices(test_server, alternative_service_info_vector); 795 impl_.SetAlternativeServices(test_server, alternative_service_info_vector);
795 796
796 const net::AlternativeServiceMap& map = impl_.alternative_service_map(); 797 const net::AlternativeServiceMap& map = impl_.alternative_service_map();
797 net::AlternativeServiceMap::const_iterator it = map.begin(); 798 net::AlternativeServiceMap::const_iterator it = map.begin();
798 EXPECT_TRUE(it->first.Equals(test_server)); 799 EXPECT_TRUE(it->first.Equals(test_server));
799 ASSERT_EQ(2u, it->second.size()); 800 ASSERT_EQ(2u, it->second.size());
800 EXPECT_EQ(alternative_service1, it->second[0].alternative_service); 801 EXPECT_EQ(alternative_service1, it->second[0].alternative_service);
801 EXPECT_EQ(alternative_service2, it->second[1].alternative_service); 802 EXPECT_EQ(alternative_service2, it->second[1].alternative_service);
802 803
803 impl_.ClearAlternativeServices(test_server); 804 impl_.SetAlternativeServices(test_server, AlternativeServiceInfoVector());
804 EXPECT_TRUE(map.empty()); 805 EXPECT_TRUE(map.empty());
805 } 806 }
806 807
807 // A broken alternative service in the mapping carries meaningful information, 808 // A broken alternative service in the mapping carries meaningful information,
808 // therefore it should not be ignored by SetAlternativeService(). In 809 // therefore it should not be ignored by SetAlternativeService(). In
809 // particular, an alternative service mapped to an origin shadows alternative 810 // particular, an alternative service mapped to an origin shadows alternative
810 // services of canonical hosts. 811 // services of canonical hosts.
811 TEST_F(AlternateProtocolServerPropertiesTest, BrokenShadowsCanonical) { 812 TEST_F(AlternateProtocolServerPropertiesTest, BrokenShadowsCanonical) {
812 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443); 813 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443);
813 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443); 814 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
(...skipping 16 matching lines...) Expand all
830 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service)); 831 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service));
831 } 832 }
832 833
833 TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) { 834 TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) {
834 url::SchemeHostPort test_server("http", "foo", 80); 835 url::SchemeHostPort test_server("http", "foo", 80);
835 const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443); 836 const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443);
836 SetAlternativeService(test_server, alternative_service); 837 SetAlternativeService(test_server, alternative_service);
837 impl_.MarkAlternativeServiceBroken(alternative_service); 838 impl_.MarkAlternativeServiceBroken(alternative_service);
838 ASSERT_TRUE(HasAlternativeService(test_server)); 839 ASSERT_TRUE(HasAlternativeService(test_server));
839 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service)); 840 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service));
840 // ClearAlternativeServices should leave a broken alternative service marked 841 // SetAlternativeServices should leave a broken alternative service marked
841 // as such. 842 // as such.
842 impl_.ClearAlternativeServices(test_server); 843 impl_.SetAlternativeServices(test_server, AlternativeServiceInfoVector());
843 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service)); 844 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service));
844 } 845 }
845 846
846 TEST_F(AlternateProtocolServerPropertiesTest, MarkRecentlyBroken) { 847 TEST_F(AlternateProtocolServerPropertiesTest, MarkRecentlyBroken) {
847 url::SchemeHostPort server("http", "foo", 80); 848 url::SchemeHostPort server("http", "foo", 80);
848 const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443); 849 const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443);
849 SetAlternativeService(server, alternative_service); 850 SetAlternativeService(server, alternative_service);
850 851
851 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service)); 852 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service));
852 EXPECT_FALSE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service)); 853 EXPECT_FALSE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 impl_.GetCanonicalSuffix(canonical_server.host())); 902 impl_.GetCanonicalSuffix(canonical_server.host()));
902 } 903 }
903 904
904 TEST_F(AlternateProtocolServerPropertiesTest, ClearCanonical) { 905 TEST_F(AlternateProtocolServerPropertiesTest, ClearCanonical) {
905 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443); 906 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443);
906 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443); 907 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
907 AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com", 908 AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com",
908 1234); 909 1234);
909 910
910 SetAlternativeService(canonical_server, canonical_alternative_service); 911 SetAlternativeService(canonical_server, canonical_alternative_service);
911 impl_.ClearAlternativeServices(canonical_server); 912 impl_.SetAlternativeServices(canonical_server,
913 AlternativeServiceInfoVector());
912 EXPECT_FALSE(HasAlternativeService(test_server)); 914 EXPECT_FALSE(HasAlternativeService(test_server));
913 } 915 }
914 916
915 TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBroken) { 917 TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBroken) {
916 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443); 918 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443);
917 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443); 919 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
918 AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com", 920 AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com",
919 1234); 921 1234);
920 922
921 SetAlternativeService(canonical_server, canonical_alternative_service); 923 SetAlternativeService(canonical_server, canonical_alternative_service);
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id))); 1526 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id)));
1525 1527
1526 impl_.Clear(); 1528 impl_.Clear();
1527 EXPECT_EQ(0u, impl_.quic_server_info_map().size()); 1529 EXPECT_EQ(0u, impl_.quic_server_info_map().size());
1528 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id)); 1530 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id));
1529 } 1531 }
1530 1532
1531 } // namespace 1533 } // namespace
1532 1534
1533 } // namespace net 1535 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | net/http/http_server_properties_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698