#include "components/media_router/common/providers/cast/channel/cast_auth_util.h"
#include <string>
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "components/media_router/common/providers/cast/certificate/cast_cert_reader.h"
#include "components/media_router/common/providers/cast/certificate/cast_cert_test_helpers.h"
#include "components/media_router/common/providers/cast/certificate/cast_cert_validator.h"
#include "components/media_router/common/providers/cast/certificate/cast_crl.h"
#include "components/media_router/common/providers/cast/channel/cast_auth_util.h"
#include "components/media_router/common/providers/cast/channel/cast_channel_enum.h"
#include "net/cert/x509_certificate.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/boringssl/src/pki/trust_store_in_memory.h"
#include "third_party/openscreen/src/cast/common/certificate/proto/test_suite.pb.h"
#include "third_party/openscreen/src/cast/common/channel/proto/cast_channel.pb.h"
SHA1;
SHA256;
namespace cast_channel {
namespace {
constexpr CastChannelFlags kFlagsCRLMissing = …;
constexpr CastChannelFlags kFlagsSHA1AndCRLMissing = …;
constexpr CastChannelFlags kFlagsInvalidCRL = …;
constexpr CastChannelFlags kFlagsInvalidFallbackCRL = …;
constexpr CastChannelFlags kFlagsAcceptedByFallbackCRL = …;
constexpr CastChannelFlags kFlagsExpiredFallbackCRL = …;
class CastAuthUtilTest : public testing::Test { … };
TEST_F(CastAuthUtilTest, VerifySuccess) { … }
TEST_F(CastAuthUtilTest, VerifyBadCA) { … }
TEST_F(CastAuthUtilTest, VerifyBadClientAuthCert) { … }
TEST_F(CastAuthUtilTest, VerifyBadSignature) { … }
TEST_F(CastAuthUtilTest, VerifyEmptySignature) { … }
TEST_F(CastAuthUtilTest, VerifyUnsupportedDigest) { … }
TEST_F(CastAuthUtilTest, VerifyBackwardsCompatibleDigest) { … }
TEST_F(CastAuthUtilTest, VerifyCrlRequiredWithFallback) { … }
TEST_F(CastAuthUtilTest, VerifyCrlOptionalWithFallback) { … }
TEST_F(CastAuthUtilTest, VerifyCrlRequiredWithExpiredFallback) { … }
TEST_F(CastAuthUtilTest, VerifyCrlRequiredWithNotExpiredFallback) { … }
TEST_F(CastAuthUtilTest, FeatureFlagVerifyCrlRequiredWithFallbackCRL) { … }
TEST_F(CastAuthUtilTest, VerifyCrlRequiredWithInvalidFallbackCRL) { … }
TEST_F(CastAuthUtilTest,
VerifyInvalidCRLWithFeatureFlagEnforceRevocationChecking) { … }
TEST_F(CastAuthUtilTest,
VerifyMissingCRLWithoutFeatureFlagEnforceRevocationChecking) { … }
TEST_F(CastAuthUtilTest,
VerifyParsingErrorWithFeatureFlagEnforceRevocationChecking) { … }
TEST_F(CastAuthUtilTest,
VerifyParsingErrorWithoutFeatureFlagEnforceRevocationChecking) { … }
TEST_F(CastAuthUtilTest, VerifyCrlOptionalWithInvalidFallbackCRL) { … }
TEST_F(CastAuthUtilTest, VerifyBadPeerCert) { … }
TEST_F(CastAuthUtilTest, VerifySenderNonceMatch) { … }
TEST_F(CastAuthUtilTest, VerifySenderNonceMismatch) { … }
TEST_F(CastAuthUtilTest, VerifySenderNonceMissing) { … }
TEST_F(CastAuthUtilTest, VerifyTLSCertificateSuccess) { … }
TEST_F(CastAuthUtilTest, VerifyTLSCertificateTooEarly) { … }
TEST_F(CastAuthUtilTest, VerifyTLSCertificateTooLate) { … }
enum TestStepResult { … };
AuthResult TestVerifyRevocation(
const std::vector<std::string>& certificate_chain,
const std::string& crl_bundle,
const base::Time& verification_time,
bool crl_required,
bssl::TrustStore* crl_trust_store) { … }
bool RunTest(const openscreen::cast::proto::DeviceCertTest& test_case) { … }
void RunTestSuite(const std::string& test_suite_file_name) { … }
TEST_F(CastAuthUtilTest, CRLTestSuite) { … }
}
}