"\x6f\x02\x4a\xd7\xeb\x92\x45\xfc\xd4\xe4\x37\xa1\x55\x2b\x13\x8a";
using ::testing::InSequence;
+using ::testing::Mock;
using ::testing::SaveArg;
using ::testing::_;
EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
}
+TEST_F(AutoEnrollmentClientTest, NetworkFailureThenRequireUpdatedModulus) {
+ // This test verifies that if the first request fails due to a network
+ // problem then the second request will correctly handle an updated
+ // modulus request from the server.
+
+ ServerWillFail(DM_STATUS_REQUEST_FAILED);
+ client_->Start();
+ EXPECT_FALSE(client_->should_auto_enroll());
+ // Don't invoke the callback if there was a network failure.
+ EXPECT_EQ(0, completion_callback_count_);
+ EXPECT_FALSE(HasCachedDecision());
+ Mock::VerifyAndClearExpectations(service_.get());
+
+ InSequence sequence;
+ // The default client uploads 4 bits. Make the server ask for 5.
+ ServerWillReply(1 << 5, false, false);
+ EXPECT_CALL(*service_, StartJob(_, _, _, _, _, _, _));
+ // Then reply with a valid response and include the hash.
+ ServerWillReply(-1, true, true);
+ EXPECT_CALL(*service_, StartJob(_, _, _, _, _, _, _));
+
+ // Trigger a network change event.
+ client_->OnNetworkChanged(net::NetworkChangeNotifier::CONNECTION_ETHERNET);
+ EXPECT_TRUE(client_->should_auto_enroll());
+ EXPECT_EQ(1, completion_callback_count_);
+ EXPECT_TRUE(HasCachedDecision());
+ Mock::VerifyAndClearExpectations(service_.get());
+}
+
} // namespace
} // namespace policy