* [Rewards] Make gate3 URL environment-aware via CLI switches * Address review: network audit list, public_deps, CHECK - Add gate3 prod and dev endpoints to network audit allowed list - Move //base to public_deps in :constants (BS-024) - Replace DCHECK with CHECK in GetGate3URL (CS-025) * Fix broken tests * Remove gate3 endpoints from network audit list * Add gate3 endpoints to TLS pin list * Replace auto with explicit type * Refactor GetGate3URL tests into table-driven loop * Move kEnvGate3Switch to header and use named constants in tests * Add explicit default for gate3_url in RewardsEngineOptions * Fix MaybeWarnSwitchValue comment to describe both log paths * Remove gate3 entries from brave_network_audit_allowed_lists.h * Simplify GetGate3URL to delegate to GetServicesDomain * Use std::optional<std::string> for gate3_url instead of empty sentinel * Rename brave_domains/constants.h/cc to urls.h/cc * Switch to GURL in GetGate3URL * Clean up review nits from gate3 env switch * Add comment in brave_domains/urls.h
55 lines
1.7 KiB
C++
55 lines
1.7 KiB
C++
// Copyright (c) 2026 The Brave Authors. All rights reserved.
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
#include "brave/brave_domains/urls.h"
|
|
|
|
#include <string>
|
|
|
|
#include "base/strings/strcat.h"
|
|
#include "base/test/scoped_command_line.h"
|
|
#include "brave/brave_domains/buildflags.h"
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
#include "url/gurl.h"
|
|
|
|
namespace brave_domains {
|
|
|
|
namespace {
|
|
std::string ExpectedGate3Host(const char* domain) {
|
|
return base::StrCat({"gate3.wallet.", domain});
|
|
}
|
|
} // namespace
|
|
|
|
TEST(GetGate3URLTest, DefaultIsProductionURL) {
|
|
GURL gurl = GetGate3URL();
|
|
EXPECT_TRUE(gurl.is_valid());
|
|
EXPECT_EQ(gurl.scheme(), "https");
|
|
EXPECT_EQ(gurl.host(),
|
|
ExpectedGate3Host(BUILDFLAG(BRAVE_SERVICES_PRODUCTION_DOMAIN)));
|
|
}
|
|
|
|
TEST(GetGate3URLTest, DevEnvironment) {
|
|
base::test::ScopedCommandLine scoped_cl;
|
|
scoped_cl.GetProcessCommandLine()->AppendSwitchASCII("env-gate3.wallet",
|
|
"dev");
|
|
|
|
GURL gurl = GetGate3URL();
|
|
EXPECT_TRUE(gurl.is_valid());
|
|
EXPECT_EQ(gurl.host(),
|
|
ExpectedGate3Host(BUILDFLAG(BRAVE_SERVICES_DEV_DOMAIN)));
|
|
}
|
|
|
|
TEST(GetGate3URLTest, StagingEnvironment) {
|
|
base::test::ScopedCommandLine scoped_cl;
|
|
scoped_cl.GetProcessCommandLine()->AppendSwitchASCII("env-gate3.wallet",
|
|
"staging");
|
|
|
|
GURL gurl = GetGate3URL();
|
|
EXPECT_TRUE(gurl.is_valid());
|
|
EXPECT_EQ(gurl.host(),
|
|
ExpectedGate3Host(BUILDFLAG(BRAVE_SERVICES_STAGING_DOMAIN)));
|
|
}
|
|
|
|
} // namespace brave_domains
|