chromium/google_apis/gaia/oauth2_mint_token_flow_unittest.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// A complete set of unit tests for OAuth2MintTokenFlow.

#include "google_apis/gaia/oauth2_mint_token_flow.h"

#include <memory>
#include <optional>
#include <set>
#include <string>
#include <string_view>
#include <vector>

#include "base/json/json_reader.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/values_test_util.h"
#include "base/values.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "google_apis/gaia/oauth2_access_token_fetcher.h"
#include "net/base/net_errors.h"
#include "net/cookies/canonical_cookie.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_status_code.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

_;
AllOf;
ByRef;
Eq;
Field;
StrictMock;

namespace {

const char kValidTokenResponse[] =;

const char kValidTokenResponseEnrcypted[] =;

const char kTokenResponseNoGrantedScopes[] =;

const char kTokenResponseEmptyGrantedScopes[] =;

const char kTokenResponseNoAccessToken[] =;

const char kValidRemoteConsentResponse[] =;

const char kInvalidRemoteConsentResponse[] =;

constexpr std::string_view kVersion =;
constexpr std::string_view kChannel =;
constexpr std::string_view kScopes[] =;
constexpr std::string_view kClientId =;

MATCHER_P4(HasMintTokenResult,
           access_token,
           granted_scopes,
           time_to_live,
           is_token_encrypted,
           "") {}

static RemoteConsentResolutionData CreateRemoteConsentResolutionData() {}

class MockDelegate : public OAuth2MintTokenFlow::Delegate {};

class MockMintTokenFlow : public OAuth2MintTokenFlow {};

}  // namespace

class OAuth2MintTokenFlowTest : public testing::Test {};

TEST_F(OAuth2MintTokenFlowTest, CreateApiCallBodyIssueAdviceMode) {}

TEST_F(OAuth2MintTokenFlowTest, CreateApiCallBodyRecordGrantMode) {}

TEST_F(OAuth2MintTokenFlowTest, CreateApiCallBodyMintTokenNoForceMode) {}

TEST_F(OAuth2MintTokenFlowTest, CreateApiCallBodyMintTokenForceMode) {}

TEST_F(OAuth2MintTokenFlowTest,
       CreateApiCallBodyMintTokenWithGranularPermissionsEnabled) {}

TEST_F(OAuth2MintTokenFlowTest, CreateApiCallBodyMintTokenWithDeviceId) {}

TEST_F(OAuth2MintTokenFlowTest, CreateApiCallBodyMintTokenWithSelectedUserId) {}

TEST_F(OAuth2MintTokenFlowTest, CreateApiCallBodyMintTokenWithConsentResult) {}

TEST_F(OAuth2MintTokenFlowTest, CreateApiCallBodyClientAccessTokenFlow) {}

TEST_F(OAuth2MintTokenFlowTest, CreateAuthorizationHeaderValue) {}

TEST_F(OAuth2MintTokenFlowTest, CreateApiCallHeaders) {}

TEST_F(OAuth2MintTokenFlowTest,
       CreateApiCallBodyClientAccessTokenFlowWithBoundOAuthToken) {}

TEST_F(OAuth2MintTokenFlowTest, CreateAuthorizationHeaderValueBoundOAuthToken) {}

TEST_F(OAuth2MintTokenFlowTest, ParseMintTokenResponseAccessTokenMissing) {}

TEST_F(OAuth2MintTokenFlowTest, ParseMintTokenResponseEmptyGrantedScopes) {}

TEST_F(OAuth2MintTokenFlowTest, ParseMintTokenResponseNoGrantedScopes) {}

TEST_F(OAuth2MintTokenFlowTest, ParseMintTokenResponseGoodToken) {}

TEST_F(OAuth2MintTokenFlowTest, ParseMintTokenResponseEncryptedToken) {}

TEST_F(OAuth2MintTokenFlowTest, ParseRemoteConsentResponse) {}

TEST_F(OAuth2MintTokenFlowTest, ParseRemoteConsentResponse_EmptyCookies) {}

TEST_F(OAuth2MintTokenFlowTest, ParseRemoteConsentResponse_NoCookies) {}

TEST_F(OAuth2MintTokenFlowTest, ParseRemoteConsentResponse_NoResolutionData) {}

TEST_F(OAuth2MintTokenFlowTest, ParseRemoteConsentResponse_NoUrl) {}

TEST_F(OAuth2MintTokenFlowTest, ParseRemoteConsentResponse_BadUrl) {}

TEST_F(OAuth2MintTokenFlowTest, ParseRemoteConsentResponse_NoApproach) {}

TEST_F(OAuth2MintTokenFlowTest, ParseRemoteConsentResponse_BadApproach) {}

TEST_F(OAuth2MintTokenFlowTest,
       ParseRemoteConsentResponse_BadCookie_MissingRequiredField) {}

TEST_F(OAuth2MintTokenFlowTest,
       ParseRemoteConsentResponse_MissingCookieOptionalField) {}

TEST_F(OAuth2MintTokenFlowTest,
       ParseRemoteConsentResponse_BadCookie_BadMaxAge) {}

TEST_F(OAuth2MintTokenFlowTest, ParseRemoteConsentResponse_BadCookieList) {}

TEST_F(OAuth2MintTokenFlowTest, ProcessApiCallSuccess_NoBody) {}

TEST_F(OAuth2MintTokenFlowTest, ProcessApiCallSuccess_BadJson) {}

TEST_F(OAuth2MintTokenFlowTest, ProcessApiCallSuccess_NoAccessToken) {}

TEST_F(OAuth2MintTokenFlowTest, ProcessApiCallSuccess_GoodToken) {}

TEST_F(OAuth2MintTokenFlowTest, ProcessApiCallSuccess_GoodRemoteConsent) {}

TEST_F(OAuth2MintTokenFlowTest, ProcessApiCallSuccess_RemoteConsentFailure) {}

TEST_F(OAuth2MintTokenFlowTest, ProcessApiCallFailure_TokenBindingChallenge) {}

TEST_F(OAuth2MintTokenFlowTest, ProcessApiCallFailure_NullDelegate) {}

TEST_F(OAuth2MintTokenFlowTest, ProcessApiCallFailure_NonNullDelegate) {}

TEST_F(OAuth2MintTokenFlowTest, ProcessApiCallFailure_NullHead) {}

TEST_F(OAuth2MintTokenFlowTest, ProcessApiCallSuccess_NoGrantedScopes) {}