chromium/components/affiliations/core/browser/hash_affiliation_fetcher_unittest.cc

// Copyright 2020 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/affiliations/core/browser/hash_affiliation_fetcher.h"

#include <memory>
#include <string>

#include "base/strings/string_number_conversions_win.h"
#include "base/test/bind.h"
#include "base/test/gmock_move_support.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "components/affiliations/core/browser/affiliation_service_impl.h"
#include "components/affiliations/core/browser/affiliation_utils.h"
#include "components/affiliations/core/browser/affiliation_api.pb.h"
#include "components/affiliations/core/browser/mock_affiliation_fetcher_delegate.h"
#include "components/variations/scoped_variations_ids_provider.h"
#include "crypto/sha2.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/test/test_url_loader_factory.h"
#include "services/network/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace affiliations {

namespace {

constexpr char kExampleAndroidFacetURI[] =;
constexpr char kExampleAndroidPlayName[] =;
constexpr char kExampleAndroidIconURL[] =;
constexpr char kExampleWebFacet1URI[] =;
constexpr char kExampleWebFacet2URI[] =;
constexpr char kExampleWebFacet1ChangePasswordURI[] =;
constexpr char kExampleWebFacet2ChangePasswordURI[] =;

constexpr char k1ExampleURL[] =;
constexpr uint64_t k1ExampleHash16LenPrefix =;
constexpr char k2ExampleURL[] =;
constexpr uint64_t k2ExampleHash16LenPrefix =;

uint64_t ComputeHashPrefix(const FacetURI& uri) {}

std::vector<uint64_t> ComputeHashes(const std::vector<FacetURI>& facet_uris) {}

}  // namespace

class HashAffiliationFetcherTest : public testing::Test {};

void HashAffiliationFetcherTest::VerifyRequestPayload(
    const std::vector<uint64_t>& expected_hash_prefixes,
    HashAffiliationFetcher::RequestInfo request_info) {}

TEST_F(HashAffiliationFetcherTest, BuildQueryURL) {}

TEST_F(HashAffiliationFetcherTest, GetRequestedFacetURIs) {}

TEST_F(HashAffiliationFetcherTest,
       VerifyPayloadForMultipleHashesRequestWith16LengthPrefix) {}

TEST_F(HashAffiliationFetcherTest, BasicRequestAndResponse) {}

TEST_F(HashAffiliationFetcherTest, AndroidBrandingInfoIsReturnedIfPresent) {}

TEST_F(HashAffiliationFetcherTest, ChangePasswordInfoIsReturnedIfPresent) {}

// The API contract of this class is to return an equivalence class for all
// requested facets; however, the server will not return anything for facets
// that are not affiliated with any other facet. Make sure an equivalence class
// of size one is created for each of the missing facets.
TEST_F(HashAffiliationFetcherTest, MissingEquivalenceClassesAreCreated) {}

TEST_F(HashAffiliationFetcherTest, DuplicateEquivalenceClassesAreIgnored) {}

TEST_F(HashAffiliationFetcherTest, NonRequestedEquivalenceClassesAreIgnored) {}

TEST_F(HashAffiliationFetcherTest, EmptyEquivalenceClassesAreIgnored) {}

TEST_F(HashAffiliationFetcherTest, UnrecognizedFacetURIsAreIgnored) {}

TEST_F(HashAffiliationFetcherTest, FailureBecauseResponseIsNotAProtobuf) {}

// Partially overlapping equivalence classes violate the invariant that
// affiliations must form an equivalence relation. Such a response is malformed.
TEST_F(HashAffiliationFetcherTest,
       FailureBecausePartiallyOverlappingEquivalenceClasses) {}

TEST_F(HashAffiliationFetcherTest, FailOnServerError) {}

TEST_F(HashAffiliationFetcherTest, FailOnNetworkError) {}

TEST_F(HashAffiliationFetcherTest, MetricsWhenSuccess) {}

TEST_F(HashAffiliationFetcherTest, MetricsWhenFailed) {}

TEST_F(HashAffiliationFetcherTest, GroupBrandingInfoIsReturnedIfPresent) {}

}  // namespace affiliations