chromium/components/embedder_support/origin_trials/origin_trial_policy_impl_unittest.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/embedder_support/origin_trials/origin_trial_policy_impl.h"

#include <memory>
#include <vector>

#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h"
#include "base/test/scoped_feature_list.h"
#include "components/embedder_support/origin_trials/features.h"
#include "components/embedder_support/switches.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/origin_trials/origin_trials_settings_provider.h"
#include "third_party/blink/public/mojom/origin_trials/origin_trials_settings.mojom.h"

namespace embedder_support {

const blink::OriginTrialPublicKey kTestPublicKey1 =;

const blink::OriginTrialPublicKey kTestPublicKey2 =;

// Base64 encoding of the `kTestPublicKey1`.
const char kTestPublicKeyString[] =;

// Comma-separated Base64 encodings of `{kTestPublicKey1, kTestPublicKey2}`.
const char kTwoTestPublicKeysString[] =;

const char kBadEncodingPublicKeyString[] =;
// Base64-encoded, 31 bytes long
const char kTooShortPublicKeyString[] =;
// Base64-encoded, 33 bytes long
const char kTooLongPublicKeyString[] =;
// Comma-separated bad encoding key and good test key.
const char kTwoPublicKeysString_BadAndGood[] =;
// Comma-separated too short key and too long key.
const char kTwoBadPublicKeysString[] =;

const char kOneDisabledFeature[] =;
const char kTwoDisabledFeatures[] =;
const char kThreeDisabledFeatures[] =;
const char kSpacesInDisabledFeatures[] =;

// Various tokens, each provide the command (in tools/origin_trials) used for
// generation.
// generate_token.py example.com A --expire-timestamp=2000000000
const uint8_t kToken1Signature[] =;
const char kToken1SignatureEncoded[] =;
// generate_token.py example.com A --expire-timestamp=2500000000
const uint8_t kToken2Signature[] =;
const char kToken2SignatureEncoded[] =;
// generate_token.py example.com B --expire-timestamp=2000000000
const uint8_t kToken3Signature[] =;
const char kToken3SignatureEncoded[] =;
class OriginTrialPolicyImplTest : public testing::Test {};

TEST_F(OriginTrialPolicyImplTest, DefaultConstructor) {}

TEST_F(OriginTrialPolicyImplTest, DefaultKeysAreConsistent) {}

TEST_F(OriginTrialPolicyImplTest, OverridePublicKeys) {}

TEST_F(OriginTrialPolicyImplTest, OverridePublicKeysWithTwoKeys) {}

TEST_F(OriginTrialPolicyImplTest, OverrideKeysNotBase64) {}

TEST_F(OriginTrialPolicyImplTest, OverrideKeysTooShort) {}

TEST_F(OriginTrialPolicyImplTest, OverrideKeysTooLong) {}

TEST_F(OriginTrialPolicyImplTest, OverridePublicKeysWithBadAndGoodKey) {}

TEST_F(OriginTrialPolicyImplTest, OverridePublicKeysWithTwoBadKeys) {}

TEST_F(OriginTrialPolicyImplTest, NoDisabledFeatures) {}

TEST_F(OriginTrialPolicyImplTest, DisableOneFeature) {}

TEST_F(OriginTrialPolicyImplTest, DisableTwoFeatures) {}

TEST_F(OriginTrialPolicyImplTest, DisableThreeFeatures) {}

TEST_F(OriginTrialPolicyImplTest, DisableFeatureWithSpace) {}

TEST_F(OriginTrialPolicyImplTest, NoDisabledTokens) {}

TEST_F(OriginTrialPolicyImplTest, DisableOneToken) {}

TEST_F(OriginTrialPolicyImplTest, DisableTwoTokens) {}

TEST_F(OriginTrialPolicyImplTest, DisableThreeTokens) {}

TEST_F(OriginTrialPolicyImplTest, AllNonDeprecationTrialsAreDisabledByFlag) {}

TEST_F(OriginTrialPolicyImplTest, DisableFeatureForUser) {}

TEST_F(OriginTrialPolicyImplTest, DisableFeatureForUserAfterCheck) {}

// Tests for initialization from command line and settings
class OriginTrialPolicyImplInitializationTest
    : public OriginTrialPolicyImplTest {};

TEST_F(OriginTrialPolicyImplInitializationTest, PublicKeyInitialized) {}

TEST_F(OriginTrialPolicyImplInitializationTest, DisabledFeaturesInitialized) {}

TEST_F(OriginTrialPolicyImplInitializationTest, DisabledTokensInitialized) {}

}  // namespace embedder_support