Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Commit e052ca3

Browse files
Privacy Sandbox Teamcopybara-github
authored andcommitted
Release version v1.26.0-rc01
GitOrigin-RevId: 2a4f952b2cf273fa118f6182e23df197d1d5d209
1 parent 4dc259e commit e052ca3

72 files changed

Lines changed: 352 additions & 272 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## [1.26.0](https://github.com/privacysandbox/coordinator-services-and-shared-libraries/compare/v1.25.0...v1.26.0) (2025-06-10)
4+
5+
### Changes
6+
- INFRA
7+
- [CA] Remove terraform version constraint in child modules
8+
- MPKGDS
9+
- [AWS] Fix AWS assume role policy issue with multiple roles
10+
- [GCP] Ignore changes to KeyDb DDL Terraform field
11+
- PBS
12+
- [CA] Introduce docker compose binary
13+
- [CA] Introduce test to verify one to one mapping between budget type and budget consumer
14+
- [CA] Use docker-compose in PBS GCP Integration test
15+
316
## [1.25.0](https://github.com/privacysandbox/coordinator-services-and-shared-libraries/compare/v1.24.0...v1.25.0) (2025-05-27)
417
### Important Note
518
**[GCP]**

MODULE.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ http_file(
216216
urls = ["https://github.com/google/google-java-format/releases/download/v1.15.0/google-java-format-1.15.0-all-deps.jar"],
217217
)
218218

219+
http_file(
220+
name = "docker_compose",
221+
downloaded_file_path = "docker-compose",
222+
sha256 = "9040bd35b2cc0783ce6c5de491de7e52e24d4137dbfc5de8a524f718fc23556c",
223+
url = "https://github.com/docker/compose/releases/download/v2.36.2/docker-compose-linux-x86_64",
224+
)
225+
219226
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
220227
go_sdk.download(version = "1.23.0")
221228

build_defs/scp_dependencies.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ load("//build_defs/shared:bazel_rules_java.bzl", "bazel_rules_java")
3030
load("//build_defs/shared:bazel_rules_pkg.bzl", "bazel_rules_pkg")
3131
load("//build_defs/shared:bazel_rules_proto.bzl", "bazel_rules_proto")
3232
load("//build_defs/shared:bazel_rules_python.bzl", "bazel_rules_python")
33+
load("//build_defs/shared:docker_compose.bzl", "docker_compose")
3334
load("//build_defs/shared:enclaves_kmstools.bzl", "import_aws_nitro_enclaves_sdk_c")
3435
load("//build_defs/shared:golang.bzl", "go_deps")
3536
load("//build_defs/shared:google_api_core.bzl", "google_api_core")
@@ -61,6 +62,7 @@ def scp_dependencies(protobuf_version, protobuf_repo_hash):
6162
go_deps()
6263
google_cloud_sdk()
6364
google_java_format()
65+
docker_compose()
6466
google_test()
6567
grpc()
6668
libpsl()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
16+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
17+
18+
# docker-compose for managing docker containers in PBS integration test
19+
20+
def docker_compose():
21+
maybe(
22+
http_file,
23+
name = "docker_compose",
24+
downloaded_file_path = "docker-compose",
25+
sha256 = "9040bd35b2cc0783ce6c5de491de7e52e24d4137dbfc5de8a524f718fc23556c",
26+
url = "https://github.com/docker/compose/releases/download/v2.36.2/docker-compose-linux-x86_64",
27+
)

cc/core/test/utils/docker_helper/BUILD

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
1616

1717
package(default_visibility = ["//cc:pbs_visibility"])
1818

19+
# Copy the file in the test directory for simplier executable file path
20+
genrule(
21+
name = "docker_compose_executable",
22+
srcs = ["@docker_compose//file"],
23+
outs = ["docker-compose"],
24+
cmd = "cp $(location @docker_compose//file) $@",
25+
tags = ["manual"],
26+
)
27+
1928
cc_library(
2029
name = "docker_helper_lib",
2130
srcs = glob(
@@ -27,6 +36,9 @@ cc_library(
2736
"docker_helper_test.cc",
2837
],
2938
),
39+
data = [
40+
":docker_compose_executable",
41+
],
3042
deps = [
3143
"@com_google_absl//absl/strings:str_format",
3244
],

cc/core/test/utils/docker_helper/docker_helper.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@ using std::map;
2626
using std::runtime_error;
2727
using std::string;
2828

29-
// localstack version is pinned so that tests are repeatable
30-
static constexpr char kLocalstackImage[] = "localstack/localstack:1.0.3";
31-
// gcloud SDK tool version is pinned so that tests are repeatable
32-
static constexpr char kGcpImage[] =
33-
"gcr.io/google.com/cloudsdktool/google-cloud-cli:380.0.0-emulators";
29+
static constexpr absl::string_view kDockerComposeBinaryPath =
30+
"cc/core/test/utils/docker_helper/docker-compose";
3431

3532
namespace privacy_sandbox::pbs_common {
3633
string PortMapToSelf(string port) {
@@ -146,4 +143,8 @@ std::string GetIpAddress(const std::string& network_name,
146143
return result.substr(0, length);
147144
}
148145

146+
int RunDockerComposeCmd(const std::string& args) {
147+
return std::system(absl::StrCat(kDockerComposeBinaryPath, " ", args).c_str());
148+
}
149+
149150
} // namespace privacy_sandbox::pbs_common

cc/core/test/utils/docker_helper/docker_helper.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,12 @@ std::string BuildStartContainerCmd(
6363
std::string GetIpAddress(const std::string& network_name,
6464
const std::string& container_name);
6565

66+
/**
67+
* @brief Execute a docker-compose command
68+
*
69+
* @param args arguments to the docker-compose command
70+
* @return the status code of the command execution
71+
*/
72+
int RunDockerComposeCmd(const std::string& args);
73+
6674
} // namespace privacy_sandbox::pbs_common

cc/core/test/utils/docker_helper/docker_helper_test.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,9 @@ TEST(DockerHelper, BuildStopContainerCmd) {
7979
EXPECT_EQ(BuildStopContainerCmd("container_name"),
8080
"docker rm -f container_name");
8181
}
82+
83+
TEST(DockerHelper, TestDockerCompose) {
84+
EXPECT_EQ(RunDockerComposeCmd("version"), 0);
85+
}
86+
8287
} // namespace privacy_sandbox::pbs_common

cc/pbs/front_end_service/src/front_end_utils.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ ValidateAndGetBudgetType(const ConsumePrivacyBudgetRequest& request_proto) {
659659

660660
using PrivacyBudgetKey = ConsumePrivacyBudgetRequest::PrivacyBudgetKey;
661661
PrivacyBudgetKey::BudgetType budget_type =
662-
PrivacyBudgetKey::BUDGET_TYPE_BINARY_BUDGET;
662+
PrivacyBudgetKey::BUDGET_TYPE_UNSPECIFIED;
663663

664664
for (const auto& data_body : request_proto.data()) {
665665
for (const auto& key_body : data_body.keys()) {
@@ -670,7 +670,9 @@ ValidateAndGetBudgetType(const ConsumePrivacyBudgetRequest& request_proto) {
670670
}
671671

672672
// All keys should have the same budget type.
673-
if (budget_type != key_budget_type) {
673+
if (budget_type == PrivacyBudgetKey::BUDGET_TYPE_UNSPECIFIED) {
674+
budget_type = key_budget_type;
675+
} else if (budget_type != key_budget_type) {
674676
SCP_INFO(kFrontEndUtils, kZeroUuid,
675677
absl::StrFormat(
676678
"All keys should have the same budget type. "
@@ -679,12 +681,13 @@ ValidateAndGetBudgetType(const ConsumePrivacyBudgetRequest& request_proto) {
679681
PrivacyBudgetKey::BudgetType_Name(key_budget_type)));
680682
return FailureExecutionResult(SC_PBS_FRONT_END_SERVICE_INVALID_REQUEST);
681683
}
682-
budget_type = key_budget_type;
683684
}
684685
}
685686

686687
// Default is binary budget consumer
687-
return budget_type;
688+
return budget_type == PrivacyBudgetKey::BUDGET_TYPE_UNSPECIFIED
689+
? PrivacyBudgetKey::BUDGET_TYPE_BINARY_BUDGET
690+
: budget_type;
688691
}
689692

690693
ExecutionResult ParseCommonV2TransactionRequestProto(

cc/pbs/front_end_service/test/front_end_service_v2_test.cc

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#include "cc/core/async_executor/mock/mock_async_executor.h"
2727
#include "cc/core/config_provider/mock/mock_config_provider.h"
2828
#include "cc/core/interface/async_context.h"
29-
#include "cc/core/interface/async_executor_interface.h"
3029
#include "cc/core/interface/config_provider_interface.h"
30+
#include "cc/core/interface/errors.h"
3131
#include "cc/core/interface/http_server_interface.h"
3232
#include "cc/core/interface/http_types.h"
3333
#include "cc/core/telemetry/mock/in_memory_metric_router.h"
@@ -39,12 +39,15 @@
3939
#include "cc/pbs/interface/type_def.h"
4040
#include "cc/public/core/interface/errors.h"
4141
#include "cc/public/core/interface/execution_result.h"
42+
#include "google/protobuf/text_format.h"
4243

4344
namespace privacy_sandbox::pbs {
4445

4546
namespace {
47+
using ::privacy_sandbox::pbs::v1::ConsumePrivacyBudgetRequest;
4648
using ::privacy_sandbox::pbs_common::AsyncContext;
4749
using ::privacy_sandbox::pbs_common::ExecutionResult;
50+
using ::privacy_sandbox::pbs_common::ExecutionResultOr;
4851
using ::privacy_sandbox::pbs_common::HttpRequest;
4952
using ::privacy_sandbox::pbs_common::HttpResponse;
5053
} // namespace
@@ -92,17 +95,20 @@ class FrontEndServiceV2Peer {
9295

9396
ExecutionResult Init() { return front_end_service_v2_->Init(); }
9497

98+
ExecutionResultOr<std::unique_ptr<BudgetConsumer>> GetBudgetConsumer(
99+
const ConsumePrivacyBudgetRequest& req) {
100+
return front_end_service_v2_->GetBudgetConsumer(req);
101+
}
102+
95103
private:
96104
std::unique_ptr<FrontEndServiceV2> front_end_service_v2_;
97105
};
98106

99107
namespace {
100108

109+
using ::google::protobuf::TextFormat;
101110
using ::privacy_sandbox::pbs_common::AsyncContext;
102-
using ::privacy_sandbox::pbs_common::AsyncExecutorInterface;
103111
using ::privacy_sandbox::pbs_common::Byte;
104-
using ::privacy_sandbox::pbs_common::ConfigProviderInterface;
105-
using ::privacy_sandbox::pbs_common::ExecutionResultOr;
106112
using ::privacy_sandbox::pbs_common::FailureExecutionResult;
107113
using ::privacy_sandbox::pbs_common::GetErrorMessage;
108114
using ::privacy_sandbox::pbs_common::GetMetricPointData;
@@ -115,7 +121,6 @@ using ::privacy_sandbox::pbs_common::MockAsyncExecutor;
115121
using ::privacy_sandbox::pbs_common::MockConfigProvider;
116122
using ::privacy_sandbox::pbs_common::SuccessExecutionResult;
117123
using ::testing::_;
118-
using ::testing::Invoke;
119124
using ::testing::NiceMock;
120125
using ::testing::Return;
121126
using ::testing::UnorderedElementsAreArray;
@@ -126,7 +131,6 @@ constexpr absl::string_view kTransactionId =
126131
constexpr absl::string_view kTransactionSecret = "secret";
127132
constexpr absl::string_view kReportingOrigin = "https://fake.com";
128133
constexpr absl::string_view kClaimedIdentity = "https://origin.site.com";
129-
constexpr absl::string_view kClaimedIdentityInvalid = "123";
130134
constexpr absl::string_view kUserAgent = "aggregation-service/2.8.7";
131135
constexpr size_t k20191212DaysFromEpoch = 18242;
132136
constexpr size_t k20191012DaysFromEpoch = 18181;
@@ -1029,5 +1033,56 @@ TEST_P(FrontEndServiceV2LifecycleTest, TestGetTransactionStatusReturns404) {
10291033
SC_PBS_FRONT_END_SERVICE_GET_TRANSACTION_STATUS_RETURNS_404_BY_DEFAULT);
10301034
}
10311035

1036+
TEST(TestOneToOneMappingBetBudgetTypeAndBudgetConsumer,
1037+
TestOneToOneMappingBetBudgetTypeAndBudgetConsumer) {
1038+
auto budget_consumption_helper =
1039+
std::make_unique<MockBudgetConsumptionHelper>();
1040+
FrontEndServiceV2PeerOptions options;
1041+
options.budget_consumption_helper = budget_consumption_helper.get();
1042+
auto front_end_service_v2_peer = MakeFrontEndServiceV2Peer(options);
1043+
auto execution_result = front_end_service_v2_peer->Init();
1044+
ASSERT_TRUE(execution_result)
1045+
<< GetErrorMessage(execution_result.status_code);
1046+
1047+
using PrivacyBudgetKey = ConsumePrivacyBudgetRequest::PrivacyBudgetKey;
1048+
std::string proto_string = R"pb(
1049+
version: "2.0"
1050+
data {
1051+
reporting_origin: "http://a.fake.com"
1052+
keys { budget_type: BUDGET_TYPE_BINARY_BUDGET }
1053+
}
1054+
)pb";
1055+
1056+
ConsumePrivacyBudgetRequest req;
1057+
ASSERT_TRUE(TextFormat::ParseFromString(proto_string, &req));
1058+
1059+
absl::flat_hash_set<std::string> returned_consumer_types;
1060+
const google::protobuf::EnumDescriptor* enum_descriptor =
1061+
PrivacyBudgetKey::BudgetType_descriptor();
1062+
1063+
// Do not test BUDGET_TYPE_UNSPECIFIED
1064+
for (int i = 1; i < enum_descriptor->value_count(); ++i) {
1065+
const google::protobuf::EnumValueDescriptor* value_descriptor =
1066+
enum_descriptor->value(i);
1067+
PrivacyBudgetKey::BudgetType budget_type =
1068+
static_cast<PrivacyBudgetKey::BudgetType>(value_descriptor->number());
1069+
1070+
req.mutable_data()->at(0).mutable_keys()->at(0).set_budget_type(
1071+
budget_type);
1072+
auto budget_consumer = front_end_service_v2_peer->GetBudgetConsumer(req);
1073+
ASSERT_TRUE(budget_consumer.has_value())
1074+
<< GetErrorMessage(budget_consumer.result().status_code);
1075+
ASSERT_NE(budget_consumer->get(), nullptr);
1076+
1077+
// Ignore warning about deferencing the pointer
1078+
#pragma GCC diagnostic ignored "-Wpotentially-evaluated-expression"
1079+
std::string type_name = typeid(*budget_consumer->get()).name();
1080+
1081+
ASSERT_TRUE(returned_consumer_types.insert(type_name).second)
1082+
<< "Duplicate consumer type returned for enum value " << budget_type
1083+
<< ". Type: " << type_name << " was already returned by another enum.";
1084+
}
1085+
}
1086+
10321087
} // namespace
10331088
} // namespace privacy_sandbox::pbs

0 commit comments

Comments
 (0)