#include "chrome/browser/enterprise/connectors/device_trust/navigation_throttle.h"
#include <memory>
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/enterprise/connectors/device_trust/common/common_types.h"
#include "chrome/browser/enterprise/connectors/device_trust/common/device_trust_constants.h"
#include "chrome/browser/enterprise/connectors/device_trust/common/metrics_utils.h"
#include "chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service.h"
#include "chrome/browser/enterprise/connectors/device_trust/fake_device_trust_connector_service.h"
#include "chrome/browser/enterprise/connectors/device_trust/mock_device_trust_service.h"
#include "chrome/browser/enterprise/signals/user_permission_service_factory.h"
#include "chrome/browser/ui/device_signals_consent/mock_consent_requester.h"
#include "chrome/test/base/testing_profile.h"
#include "components/device_signals/core/browser/mock_user_permission_service.h"
#include "components/device_signals/core/browser/pref_names.h"
#include "components/device_signals/core/browser/user_permission_service.h"
#include "components/device_signals/core/common/signals_features.h"
#include "components/enterprise/connectors/core/connectors_prefs.h"
#include "components/policy/core/common/policy_pref_names.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/mock_navigation_handle.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/web_contents_tester.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
NavigationThrottle;
_;
Invoke;
Return;
namespace enterprise_connectors {
namespace {
const base::TimeDelta kTimeoutTime = …;
constexpr char kTrustedUrl[] = …;
constexpr char kChallenge[] = …;
constexpr char kChallengeResponse[] = …;
constexpr char kLatencyHistogramName[] = …;
constexpr char kFunnelHistogramName[] = …;
constexpr char kHandshakeResultHistogram[] = …;
constexpr char kPolicyLevelsHistogramName[] = …;
const std::set<DTCPolicyLevel> kUserPolicyLevel = …;
class MockDeviceTrustNavigationHandle : public content::MockNavigationHandle { … };
base::Value::List GetTrustedUrls() { … }
scoped_refptr<net::HttpResponseHeaders> GetHeaderChallenge(
const std::string& challenge) { … }
scoped_refptr<net::HttpResponseHeaders> GetRedirectedHeader() { … }
}
class DeviceTrustNavigationThrottleTest : public testing::Test { … };
TEST_F(DeviceTrustNavigationThrottleTest, ExpectHeaderDeviceTrustOnRequest) { … }
TEST_F(DeviceTrustNavigationThrottleTest,
ExpectHeaderDeviceTrustOnRedirectedRequest) { … }
TEST_F(DeviceTrustNavigationThrottleTest, NullDeviceTrustService) { … }
TEST_F(DeviceTrustNavigationThrottleTest, NullUserPermissionService) { … }
TEST_F(DeviceTrustNavigationThrottleTest, DTCPolicyDisabled) { … }
TEST_F(DeviceTrustNavigationThrottleTest,
DTCPolicyEnabled_CannotCollectSignals) { … }
TEST_F(DeviceTrustNavigationThrottleTest, NoHeaderDeviceTrustOnRequest) { … }
TEST_F(DeviceTrustNavigationThrottleTest, InvalidURL) { … }
TEST_F(DeviceTrustNavigationThrottleTest, BuildChallengeResponseFromHeader) { … }
TEST_F(DeviceTrustNavigationThrottleTest, TestReplyValidChallengeResponse) { … }
TEST_F(DeviceTrustNavigationThrottleTest,
TestReplyEmptyChallengeResponseUnknownError) { … }
TEST_F(DeviceTrustNavigationThrottleTest,
TestReplyChallengeResponseAttestationFailure) { … }
TEST_F(DeviceTrustNavigationThrottleTest, TestChallengeNotFromIdp) { … }
TEST_F(DeviceTrustNavigationThrottleTest, TestTimeout) { … }
TEST_F(DeviceTrustNavigationThrottleTest,
ExpectHeaderDeviceTrustOnRequestWithConsentDialog) { … }
TEST_F(DeviceTrustNavigationThrottleTest, BlockedByConsentDialog) { … }
TEST_F(DeviceTrustNavigationThrottleTest,
NullDeviceTrustServiceWithConsentDialog) { … }
TEST_F(DeviceTrustNavigationThrottleTest,
NoHeaderDeviceTrustOnRequestWithConsentDialog) { … }
TEST_F(DeviceTrustNavigationThrottleTest, NavigationNoUserGesture) { … }
TEST_F(DeviceTrustNavigationThrottleTest, NavigationNotInMainFrame) { … }
}