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

Side by Side Diff: chrome/common/extensions/extension_unittest.cc

Issue 6804032: Add TLS-SRP (RFC 5054) support Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: use system srp and mpi libs, not local copies Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/common/extensions/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #if defined(TOOLKIT_GTK) 7 #if defined(TOOLKIT_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 762
763 extension = LoadManifest("effective_host_permissions", "empty.json"); 763 extension = LoadManifest("effective_host_permissions", "empty.json");
764 EXPECT_EQ(0u, extension->GetEffectiveHostPermissions().patterns().size()); 764 EXPECT_EQ(0u, extension->GetEffectiveHostPermissions().patterns().size());
765 EXPECT_FALSE(hosts.ContainsURL(GURL("http://www.google.com"))); 765 EXPECT_FALSE(hosts.ContainsURL(GURL("http://www.google.com")));
766 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts()); 766 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts());
767 767
768 extension = LoadManifest("effective_host_permissions", "one_host.json"); 768 extension = LoadManifest("effective_host_permissions", "one_host.json");
769 hosts = extension->GetEffectiveHostPermissions(); 769 hosts = extension->GetEffectiveHostPermissions();
770 EXPECT_TRUE(hosts.ContainsURL(GURL("http://www.google.com"))); 770 EXPECT_TRUE(hosts.ContainsURL(GURL("http://www.google.com")));
771 EXPECT_FALSE(hosts.ContainsURL(GURL("https://www.google.com"))); 771 EXPECT_FALSE(hosts.ContainsURL(GURL("https://www.google.com")));
772 EXPECT_FALSE(hosts.ContainsURL(GURL("httpsv://www.google.com")));
772 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts()); 773 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts());
773 774
774 extension = LoadManifest("effective_host_permissions", 775 extension = LoadManifest("effective_host_permissions",
775 "one_host_wildcard.json"); 776 "one_host_wildcard.json");
776 hosts = extension->GetEffectiveHostPermissions(); 777 hosts = extension->GetEffectiveHostPermissions();
777 EXPECT_TRUE(hosts.ContainsURL(GURL("http://google.com"))); 778 EXPECT_TRUE(hosts.ContainsURL(GURL("http://google.com")));
778 EXPECT_TRUE(hosts.ContainsURL(GURL("http://foo.google.com"))); 779 EXPECT_TRUE(hosts.ContainsURL(GURL("http://foo.google.com")));
779 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts()); 780 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts());
780 781
781 extension = LoadManifest("effective_host_permissions", "two_hosts.json"); 782 extension = LoadManifest("effective_host_permissions", "two_hosts.json");
782 hosts = extension->GetEffectiveHostPermissions(); 783 hosts = extension->GetEffectiveHostPermissions();
783 EXPECT_TRUE(hosts.ContainsURL(GURL("http://www.google.com"))); 784 EXPECT_TRUE(hosts.ContainsURL(GURL("http://www.google.com")));
784 EXPECT_TRUE(hosts.ContainsURL(GURL("http://www.reddit.com"))); 785 EXPECT_TRUE(hosts.ContainsURL(GURL("http://www.reddit.com")));
785 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts()); 786 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts());
786 787
787 extension = LoadManifest("effective_host_permissions", 788 extension = LoadManifest("effective_host_permissions",
788 "https_not_considered.json"); 789 "https_not_considered.json");
789 hosts = extension->GetEffectiveHostPermissions(); 790 hosts = extension->GetEffectiveHostPermissions();
790 EXPECT_TRUE(hosts.ContainsURL(GURL("http://google.com"))); 791 EXPECT_TRUE(hosts.ContainsURL(GURL("http://google.com")));
791 EXPECT_TRUE(hosts.ContainsURL(GURL("https://google.com"))); 792 EXPECT_TRUE(hosts.ContainsURL(GURL("https://google.com")));
793 EXPECT_TRUE(hosts.ContainsURL(GURL("httpsv://google.com")));
792 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts()); 794 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts());
793 795
794 extension = LoadManifest("effective_host_permissions", 796 extension = LoadManifest("effective_host_permissions",
795 "two_content_scripts.json"); 797 "two_content_scripts.json");
796 hosts = extension->GetEffectiveHostPermissions(); 798 hosts = extension->GetEffectiveHostPermissions();
797 EXPECT_TRUE(hosts.ContainsURL(GURL("http://google.com"))); 799 EXPECT_TRUE(hosts.ContainsURL(GURL("http://google.com")));
798 EXPECT_TRUE(hosts.ContainsURL(GURL("http://www.reddit.com"))); 800 EXPECT_TRUE(hosts.ContainsURL(GURL("http://www.reddit.com")));
799 EXPECT_TRUE(hosts.ContainsURL(GURL("http://news.ycombinator.com"))); 801 EXPECT_TRUE(hosts.ContainsURL(GURL("http://news.ycombinator.com")));
800 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts()); 802 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts());
801 803
802 extension = LoadManifest("effective_host_permissions", "all_hosts.json"); 804 extension = LoadManifest("effective_host_permissions", "all_hosts.json");
803 hosts = extension->GetEffectiveHostPermissions(); 805 hosts = extension->GetEffectiveHostPermissions();
804 EXPECT_TRUE(hosts.ContainsURL(GURL("http://test/"))); 806 EXPECT_TRUE(hosts.ContainsURL(GURL("http://test/")));
805 EXPECT_FALSE(hosts.ContainsURL(GURL("https://test/"))); 807 EXPECT_FALSE(hosts.ContainsURL(GURL("https://test/")));
808 EXPECT_FALSE(hosts.ContainsURL(GURL("httpsv://test/")));
806 EXPECT_TRUE(hosts.ContainsURL(GURL("http://www.google.com"))); 809 EXPECT_TRUE(hosts.ContainsURL(GURL("http://www.google.com")));
807 EXPECT_TRUE(extension->HasEffectiveAccessToAllHosts()); 810 EXPECT_TRUE(extension->HasEffectiveAccessToAllHosts());
808 811
809 extension = LoadManifest("effective_host_permissions", "all_hosts2.json"); 812 extension = LoadManifest("effective_host_permissions", "all_hosts2.json");
810 hosts = extension->GetEffectiveHostPermissions(); 813 hosts = extension->GetEffectiveHostPermissions();
811 EXPECT_TRUE(hosts.ContainsURL(GURL("http://test/"))); 814 EXPECT_TRUE(hosts.ContainsURL(GURL("http://test/")));
812 EXPECT_TRUE(hosts.ContainsURL(GURL("http://www.google.com"))); 815 EXPECT_TRUE(hosts.ContainsURL(GURL("http://www.google.com")));
813 EXPECT_TRUE(extension->HasEffectiveAccessToAllHosts()); 816 EXPECT_TRUE(extension->HasEffectiveAccessToAllHosts());
814 817
815 extension = LoadManifest("effective_host_permissions", "all_hosts3.json"); 818 extension = LoadManifest("effective_host_permissions", "all_hosts3.json");
816 hosts = extension->GetEffectiveHostPermissions(); 819 hosts = extension->GetEffectiveHostPermissions();
817 EXPECT_FALSE(hosts.ContainsURL(GURL("http://test/"))); 820 EXPECT_FALSE(hosts.ContainsURL(GURL("http://test/")));
818 EXPECT_TRUE(hosts.ContainsURL(GURL("https://test/"))); 821 EXPECT_TRUE(hosts.ContainsURL(GURL("https://test/")));
822 EXPECT_TRUE(hosts.ContainsURL(GURL("httpsv://test/")));
819 EXPECT_TRUE(hosts.ContainsURL(GURL("http://www.google.com"))); 823 EXPECT_TRUE(hosts.ContainsURL(GURL("http://www.google.com")));
820 EXPECT_TRUE(extension->HasEffectiveAccessToAllHosts()); 824 EXPECT_TRUE(extension->HasEffectiveAccessToAllHosts());
821 } 825 }
822 826
823 TEST(ExtensionTest, IsPrivilegeIncrease) { 827 TEST(ExtensionTest, IsPrivilegeIncrease) {
824 const struct { 828 const struct {
825 const char* base_name; 829 const char* base_name;
826 // Increase these sizes if you have more than 10. 830 // Increase these sizes if you have more than 10.
827 const char* granted_apis[10]; 831 const char* granted_apis[10];
828 const char* granted_hosts[10]; 832 const char* granted_hosts[10];
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 EXPECT_TRUE(Extension::GenerateId("test", &result)); 1280 EXPECT_TRUE(Extension::GenerateId("test", &result));
1277 EXPECT_EQ(result, "jpignaibiiemhngfjkcpokkamffknabf"); 1281 EXPECT_EQ(result, "jpignaibiiemhngfjkcpokkamffknabf");
1278 1282
1279 EXPECT_TRUE(Extension::GenerateId("_", &result)); 1283 EXPECT_TRUE(Extension::GenerateId("_", &result));
1280 EXPECT_EQ(result, "ncocknphbhhlhkikpnnlmbcnbgdempcd"); 1284 EXPECT_EQ(result, "ncocknphbhhlhkikpnnlmbcnbgdempcd");
1281 1285
1282 EXPECT_TRUE(Extension::GenerateId( 1286 EXPECT_TRUE(Extension::GenerateId(
1283 "this_string_is_longer_than_a_single_sha256_hash_digest", &result)); 1287 "this_string_is_longer_than_a_single_sha256_hash_digest", &result));
1284 EXPECT_EQ(result, "jimneklojkjdibfkgiiophfhjhbdgcfi"); 1288 EXPECT_EQ(result, "jimneklojkjdibfkgiiophfhjhbdgcfi");
1285 } 1289 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698