chromium/chrome/browser/enterprise/connectors/device_trust/key_management/installer/management_service/rotate_util_unittest.cc

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

#include "chrome/browser/enterprise/connectors/device_trust/key_management/installer/management_service/rotate_util.h"

#include <memory>
#include <optional>
#include <string>
#include <utility>

#include "base/base64.h"
#include "base/command_line.h"
#include "base/memory/raw_ptr.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/core/network/mock_key_network_delegate.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence/mock_key_persistence_delegate.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence/scoped_key_persistence_delegate_factory.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/core/shared_command_constants.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/installer/key_rotation_manager.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/installer/key_rotation_types.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/installer/management_service/metrics_utils.h"
#include "components/version_info/channel.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

MockKeyNetworkDelegate;
MockKeyPersistenceDelegate;
ScopedKeyPersistenceDelegateFactory;
HttpResponseCode;

_;
Invoke;
Return;

namespace {

constexpr char kChromeManagementServiceStatusHistogramName[] =;
constexpr char kNonce[] =;
constexpr char kEncodedNonce[] =;
constexpr char kFakeDMToken[] =;
constexpr char kEncodedFakeDMToken[] =;
constexpr char kFakeDmServerUrl[] =;
constexpr char kInvalidDmServerUrl[] =;
constexpr HttpResponseCode kSuccessCode =;
constexpr HttpResponseCode kFailureCode =;
constexpr HttpResponseCode kConflictCode =;

}  // namespace

namespace enterprise_connectors {

class RotateUtilTest : public testing::Test {};

// Tests when the chrome management services key rotation was successful.
TEST_F(RotateUtilTest, RotateDTKeySuccess) {}

// Tests when the chrome management services key rotation failed due to
// an invalid dm token.
TEST_F(RotateUtilTest, RotateDTKeyFailure_InvalidDmToken) {}

// Tests when the chrome management services key rotation failed due to
// an incorrectly encoded nonce.
TEST_F(RotateUtilTest, RotateDTKeyFailure_InvalidNonce) {}

// Tests when the chrome management services key rotation failed due to
// an invalid dm server url i.e not https or http.
TEST_F(RotateUtilTest, RotateDTKeyFailure_NoDMServerUrl) {}

// Tests when the chrome management services key rotation failed due to
// a missing dm server url.
TEST_F(RotateUtilTest, RotateDTKeyFailure_InvalidDMServerUrl) {}

// Tests when the chrome management services key rotation failed due to
// an invalid rotate command i.e stable channel and non prod host name.
TEST_F(RotateUtilTest, RotateDTKeyFailure_InvalidCommand) {}

// Tests when the chrome management services key rotation failed due to
// incorrect signing key permissions.
TEST_F(RotateUtilTest, RotateDTKeyFailure_PermissionsFailed) {}

// Tests when the chrome management services key rotation failed due to
// an store key failure.
TEST_F(RotateUtilTest, RotateDTKeyFailure_StoreKeyFailed) {}

// Tests when the chrome management services key rotation failed due to
// an upload key failure.
TEST_F(RotateUtilTest, RotateDTKeyFailure_UploadKeyFailed) {}

// Tests when the chrome management services key rotation failed due to
// an upload key conflict.
TEST_F(RotateUtilTest, RotateDTKeyFailure_UploadKeyConflict) {}

}  // namespace enterprise_connectors