src/net/http/transport_security_persister_unittest.cc
// Tests that dynamic Expect-CT state is serialized and deserialized correctly.
Tests that dynamic Expect-CT state is serialized and deserialized correctly.
Tests that dynamic Expect - CT state is serialized and deserialized correctly .
TEST_F(TransportSecurityPersisterTest, ExpectCT) {
  base::test::ScopedFeatureList feature_list;
  feature_list.InitAndEnableFeature(
      TransportSecurityState::kDynamicExpectCTFeature);
  const GURL report_uri(kReportUri);
  TransportSecurityState::ExpectCTState expect_ct_state;
  static const char kTestDomain[] = "example.test";
  EXPECT_FALSE(state_.GetDynamicExpectCTState(kTestDomain, &expect_ct_state));
  const base::Time current_time(base::Time::Now());
  const base::Time expiry = current_time + base::TimeDelta::FromSeconds(1000);
  state_.AddExpectCT(kTestDomain, expiry, true , GURL());
  std::string serialized;
  EXPECT_TRUE(persister_->SerializeData(&serialized));
  bool dirty;
  EXPECT_TRUE(persister_->LoadEntries(serialized, &dirty));
  TransportSecurityState::ExpectCTState new_expect_ct_state;
  EXPECT_TRUE(
      state_.GetDynamicExpectCTState(kTestDomain, &new_expect_ct_state));
  EXPECT_TRUE(new_expect_ct_state.enforce);
  EXPECT_TRUE(new_expect_ct_state.report_uri.is_empty());
  EXPECT_EQ(expiry, new_expect_ct_state.expiry);
  state_.AddExpectCT(kTestDomain, expiry, false , report_uri);
  EXPECT_TRUE(persister_->SerializeData(&serialized));
  EXPECT_TRUE(persister_->LoadEntries(serialized, &dirty));
  EXPECT_TRUE(
      state_.GetDynamicExpectCTState(kTestDomain, &new_expect_ct_state));
  EXPECT_FALSE(new_expect_ct_state.enforce);
  EXPECT_EQ(report_uri, new_expect_ct_state.report_uri);
  EXPECT_EQ(expiry, new_expect_ct_state.expiry);
}
TEST_F ( TransportSecurityPersisterTest , ExpectCT ) { base :: test :: ScopedFeatureList feature_list ; feature_list . InitAndEnableFeature ( TransportSecurityState :: kDynamicExpectCTFeature ) ; const GURL report_uri ( kReportUri ) ; TransportSecurityState :: ExpectCTState expect_ct_state ; static const char kTestDomain [ ] = " " ; EXPECT_FALSE ( state_ . GetDynamicExpectCTState ( kTestDomain , & expect_ct_state ) ) ; const base :: Time current_time ( base :: Time :: Now ( ) ) ; const base :: Time expiry = current_time + base :: TimeDelta :: FromSeconds ( 1000 ) ; state_ . AddExpectCT ( kTestDomain , expiry , true , GURL ( ) ) ; std :: string serialized ; EXPECT_TRUE ( persister_ -> SerializeData ( & serialized ) ) ; bool dirty ; EXPECT_TRUE ( persister_ -> LoadEntries ( serialized , & dirty ) ) ; TransportSecurityState :: ExpectCTState new_expect_ct_state ; EXPECT_TRUE ( state_ . GetDynamicExpectCTState ( kTestDomain , & new_expect_ct_state ) ) ; EXPECT_TRUE ( new_expect_ct_state . enforce ) ; EXPECT_TRUE ( new_expect_ct_state . report_uri . is_empty ( ) ) ; EXPECT_EQ ( expiry , new_expect_ct_state . expiry ) ; state_ . AddExpectCT ( kTestDomain , expiry , false , report_uri ) ; EXPECT_TRUE ( persister_ -> SerializeData ( & serialized ) ) ; EXPECT_TRUE ( persister_ -> LoadEntries ( serialized , & dirty ) ) ; EXPECT_TRUE ( state_ . GetDynamicExpectCTState ( kTestDomain , & new_expect_ct_state ) ) ; EXPECT_FALSE ( new_expect_ct_state . enforce ) ; EXPECT_EQ ( report_uri , new_expect_ct_state . report_uri ) ; EXPECT_EQ ( expiry , new_expect_ct_state . expiry ) ; }
Tests that dynamic Expect-CT state is serialized and deserialized correctly.
Tests that dynamic Expect - CT state is serialized and deserialized correctly .
/* enforce */ // LoadEntries() clears existing dynamic data before loading entries from // |serialized|. // Update the state for the domain and check that it is // serialized/deserialized correctly. /* enforce */