Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / net / http / transport_security_state_unittest.cc
index 67e6f91..eb72050 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "base/base64.h"
 #include "base/files/file_path.h"
+#include "base/rand_util.h"
 #include "base/sha1.h"
 #include "base/strings/string_piece.h"
 #include "crypto/sha2.h"
@@ -38,7 +39,7 @@ namespace net {
 
 class TransportSecurityStateTest : public testing::Test {
  public:
-  virtual void SetUp() {
+  void SetUp() override {
 #if defined(USE_OPENSSL)
     crypto::EnsureOpenSSLInit();
 #else
@@ -92,6 +93,28 @@ TEST_F(TransportSecurityStateTest, MatchesCase1) {
   EXPECT_TRUE(state.GetDynamicDomainState("yahoo.com", &domain_state));
 }
 
+TEST_F(TransportSecurityStateTest, Fuzz) {
+  TransportSecurityState state;
+  TransportSecurityState::DomainState domain_state;
+
+  EnableStaticPins(&state);
+
+  for (size_t i = 0; i < 128; i++) {
+    std::string hostname;
+
+    for (;;) {
+      if (base::RandInt(0, 16) == 7) {
+        break;
+      }
+      if (i > 0 && base::RandInt(0, 7) == 7) {
+        hostname.append(1, '.');
+      }
+      hostname.append(1, 'a' + base::RandInt(0, 25));
+    }
+    state.GetStaticDomainState(hostname, &domain_state);
+  }
+}
+
 TEST_F(TransportSecurityStateTest, MatchesCase2) {
   TransportSecurityState state;
   TransportSecurityState::DomainState domain_state;