Skip to content

Commit ca68072

Browse files
committed
Rename CloudAuditLogFieldChecker to FieldMaskPathChecker
1 parent 43bd069 commit ca68072

File tree

5 files changed

+38
-38
lines changed

5 files changed

+38
-38
lines changed

proto_processing_lib/interface_util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ class FieldMaskTreeInterface : public proto_scrubber::FieldCheckerInterface {
5151
virtual const proto_scrubber::FieldMaskNode* root() const = 0;
5252
};
5353

54-
// CloudAuditLogFieldCheckerInterface is an abstract class. Proto Processing
54+
// FieldMaskPathCheckerInterface is an abstract class. Proto Processing
5555
// Library provides its own implementation.
56-
class CloudAuditLogFieldCheckerInterface
56+
class FieldMaskPathCheckerInterface
5757
: public proto_scrubber::FieldCheckerInterface {
5858
public:
5959
// Adds a list of auditing field paths to this field checker. For example,

proto_processing_lib/proto_scrubber/cloud_audit_log_field_checker.cc renamed to proto_processing_lib/proto_scrubber/field_mask_path_checker.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "proto_processing_lib/proto_scrubber/cloud_audit_log_field_checker.h"
15+
#include "proto_processing_lib/proto_scrubber/field_mask_path_checker.h"
1616

1717
#include <functional>
1818
#include <string>
@@ -34,19 +34,19 @@ namespace {
3434
const std::string* GetMessageTypeName(const FieldMaskNode* node);
3535
} // namespace
3636

37-
CloudAuditLogFieldChecker::CloudAuditLogFieldChecker(
37+
FieldMaskPathChecker::FieldMaskPathChecker(
3838
const google::protobuf::Type* type,
3939
std::function<const google::protobuf::Type*(const std::string&)>
4040
type_finder)
4141
: field_mask_tree_(
4242
FactoryCreateFieldMaskTree(type, std::move(type_finder))) {}
4343

44-
absl::Status CloudAuditLogFieldChecker::AddOrIntersectFieldPaths(
44+
absl::Status FieldMaskPathChecker::AddOrIntersectFieldPaths(
4545
const std::vector<std::string>& paths) {
4646
return field_mask_tree_->AddOrIntersectFieldPaths(paths);
4747
}
4848

49-
FieldCheckResults CloudAuditLogFieldChecker::CheckField(
49+
FieldCheckResults FieldMaskPathChecker::CheckField(
5050
const std::vector<std::string>& path,
5151
const google::protobuf::Field* field) const {
5252
if (!field_mask_tree_->status().ok()) {

proto_processing_lib/proto_scrubber/cloud_audit_log_field_checker.h renamed to proto_processing_lib/proto_scrubber/field_mask_path_checker.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef THIRD_PARTY_PROTO_PROCESSING_LIB_SRC_PROTO_SCRUBBER_CLOUD_AUDIT_LOG_FIELD_CHECKER_H_
16-
#define THIRD_PARTY_PROTO_PROCESSING_LIB_SRC_PROTO_SCRUBBER_CLOUD_AUDIT_LOG_FIELD_CHECKER_H_
15+
#ifndef THIRD_PARTY_PROTO_PROCESSING_LIB_SRC_PROTO_SCRUBBER_FIELD_MASK_PATH_CHECKER_H_
16+
#define THIRD_PARTY_PROTO_PROCESSING_LIB_SRC_PROTO_SCRUBBER_FIELD_MASK_PATH_CHECKER_H_
1717

1818
#include <functional>
1919
#include <memory>
@@ -34,24 +34,24 @@ namespace proto_processing_lib::proto_scrubber {
3434
// The implementation does not support field mask path with map keys (e.g.
3535
// "message.primitive_map[\"123\"].message_embedded") because the field mask
3636
// paths generated for Cloud Audit Logging will not contain map keys.
37-
class CloudAuditLogFieldChecker
38-
: public proto_processing_lib::CloudAuditLogFieldCheckerInterface {
37+
class FieldMaskPathChecker
38+
: public proto_processing_lib::FieldMaskPathCheckerInterface {
3939
public:
4040
// See FieldMaskTreeInterface class for description of the parameters.
41-
CloudAuditLogFieldChecker(
41+
FieldMaskPathChecker(
4242
const google::protobuf::Type* type,
4343
std::function<const google::protobuf::Type*(const std::string&)>
4444
type_finder);
45-
CloudAuditLogFieldChecker(const CloudAuditLogFieldChecker&) = delete;
46-
CloudAuditLogFieldChecker& operator=(const CloudAuditLogFieldChecker&) =
45+
FieldMaskPathChecker(const FieldMaskPathChecker&) = delete;
46+
FieldMaskPathChecker& operator=(const FieldMaskPathChecker&) =
4747
delete;
4848
// Adds a list of auditing field paths to this field checker. For example,
4949
// {"a.b", "c"} indicates that the root message can include only fields "a"
5050
// and "c", and the message "a" can include only field "b".
5151
absl::Status AddOrIntersectFieldPaths(
5252
const std::vector<std::string>& paths) override;
5353

54-
using CloudAuditLogFieldCheckerInterface::CheckField;
54+
using FieldMaskPathCheckerInterface::CheckField;
5555
// Decides whether the given field path is included, partially included, or
5656
// excluded.
5757
//
@@ -77,4 +77,4 @@ class CloudAuditLogFieldChecker
7777

7878
} // namespace proto_processing_lib::proto_scrubber
7979

80-
#endif // THIRD_PARTY_PROTO_PROCESSING_LIB_SRC_PROTO_SCRUBBER_CLOUD_AUDIT_LOG_FIELD_CHECKER_H_
80+
#endif // THIRD_PARTY_PROTO_PROCESSING_LIB_SRC_PROTO_SCRUBBER_FIELD_MASK_PATH_CHECKER_H_

proto_processing_lib/proto_scrubber/cloud_audit_log_field_checker_test.cc renamed to proto_processing_lib/proto_scrubber/field_mask_path_checker_test.cc

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "proto_processing_lib/proto_scrubber/cloud_audit_log_field_checker.h"
15+
#include "proto_processing_lib/proto_scrubber/field_mask_path_checker.h"
1616

1717
#include <functional>
1818
#include <memory>
@@ -38,43 +38,43 @@ namespace testing {
3838
using ::absl::bind_front;
3939
using ::google::protobuf::Type;
4040
using ::google::protobuf::field_extraction::testing::TypeHelper;
41-
using ::proto_processing_lib::proto_scrubber::CloudAuditLogFieldChecker;
41+
using ::proto_processing_lib::proto_scrubber::FieldMaskPathChecker;
4242
using proto_processing_lib::proto_scrubber::FieldCheckResults;
4343
using ::ocpdiag::testing::StatusIs;
4444

45-
class CloudAuditLogFieldCheckerTest : public ::testing::Test {
45+
class FieldMaskPathCheckerTest : public ::testing::Test {
4646
protected:
4747
void SetUp() override {
4848
std::string descriptor_path = GetTestDataFilePath(
4949
"proto_scrubber/"
50-
"cloud_audit_log_field_checker_test_proto_descriptor.pb");
50+
"field_mask_path_checker_test_proto_descriptor.pb");
5151

5252
auto status = TypeHelper::Create(descriptor_path);
5353
ASSERT_OK(status);
5454
type_helper_ = std::move(status.value());
5555

56-
type_finder_ = bind_front(&CloudAuditLogFieldCheckerTest::FindType, this);
56+
type_finder_ = bind_front(&FieldMaskPathCheckerTest::FindType, this);
5757

5858
// Resolve the pointer to the type of root message.
5959
root_type_ = type_finder_(
6060
"type.googleapis.com/"
6161
"proto_processing_lib.scrubber.log.testing.TestMessage");
6262

63-
// Create CloudAuditLogFieldChecker instance.
64-
cloud_audit_log_field_checker_ =
65-
std::make_unique<CloudAuditLogFieldChecker>(root_type_, type_finder_);
63+
// Create FieldMaskPathChecker instance.
64+
field_mask_path_checker_ =
65+
std::make_unique<FieldMaskPathChecker>(root_type_, type_finder_);
6666
}
6767

6868
absl::Status AddOrIntersectPaths(const std::vector<std::string>& paths) {
69-
return cloud_audit_log_field_checker_->AddOrIntersectFieldPaths(paths);
69+
return field_mask_path_checker_->AddOrIntersectFieldPaths(paths);
7070
}
7171

7272
FieldCheckResults CheckField(const std::vector<std::string>& path) {
73-
return cloud_audit_log_field_checker_->CheckField(path, nullptr);
73+
return field_mask_path_checker_->CheckField(path, nullptr);
7474
}
7575

76-
CloudAuditLogFieldChecker* cloud_audit_log_field_checker() {
77-
return cloud_audit_log_field_checker_.get();
76+
FieldMaskPathChecker* cloud_audit_log_field_checker() {
77+
return field_mask_path_checker_.get();
7878
}
7979

8080
const Type* root_type() { return root_type_; }
@@ -95,10 +95,10 @@ class CloudAuditLogFieldCheckerTest : public ::testing::Test {
9595
// A TypeHelper for testing.
9696
std::unique_ptr<TypeHelper> type_helper_ = nullptr;
9797
std::function<const Type*(const std::string&)> type_finder_;
98-
std::unique_ptr<CloudAuditLogFieldChecker> cloud_audit_log_field_checker_;
98+
std::unique_ptr<FieldMaskPathChecker> field_mask_path_checker_;
9999
};
100100

101-
TEST_F(CloudAuditLogFieldCheckerTest, NormalPathTests) {
101+
TEST_F(FieldMaskPathCheckerTest, NormalPathTests) {
102102
ASSERT_OK(AddOrIntersectPaths({"singular_int32", "repeated_enum",
103103
"message_embedded.embedded2.embedded3"}));
104104

@@ -125,7 +125,7 @@ TEST_F(CloudAuditLogFieldCheckerTest, NormalPathTests) {
125125
FieldCheckResults::kExclude);
126126
}
127127

128-
TEST_F(CloudAuditLogFieldCheckerTest, NormalPathTestsLeafAsMap) {
128+
TEST_F(FieldMaskPathCheckerTest, NormalPathTestsLeafAsMap) {
129129
ASSERT_OK(AddOrIntersectPaths({"message_embedded.message_map.properties"}));
130130

131131
EXPECT_EQ(CheckField({"message_embedded", "message_map", "properties"}),
@@ -138,7 +138,7 @@ TEST_F(CloudAuditLogFieldCheckerTest, NormalPathTestsLeafAsMap) {
138138
FieldCheckResults::kInclude);
139139
}
140140

141-
TEST_F(CloudAuditLogFieldCheckerTest, NormalPathTestsNonLeafAsMap) {
141+
TEST_F(FieldMaskPathCheckerTest, NormalPathTestsNonLeafAsMap) {
142142
ASSERT_OK(AddOrIntersectPaths(
143143
{"message_embedded.message_map.properties.repeated_value"}));
144144

@@ -152,7 +152,7 @@ TEST_F(CloudAuditLogFieldCheckerTest, NormalPathTestsNonLeafAsMap) {
152152
FieldCheckResults::kPartial);
153153
}
154154

155-
TEST_F(CloudAuditLogFieldCheckerTest, CyclicPath) {
155+
TEST_F(FieldMaskPathCheckerTest, CyclicPath) {
156156
// Corresponding field mask tree:
157157
// message_embedded ------------ embedded2 -- embedded3 -- message_embedded
158158
// | |
@@ -216,7 +216,7 @@ TEST_F(CloudAuditLogFieldCheckerTest, CyclicPath) {
216216
FieldCheckResults::kExclude);
217217
}
218218

219-
TEST_F(CloudAuditLogFieldCheckerTest, CyclicPathTestsLeafAsMap) {
219+
TEST_F(FieldMaskPathCheckerTest, CyclicPathTestsLeafAsMap) {
220220
ASSERT_OK(AddOrIntersectPaths({"message_embedded.map_embedded2"}));
221221

222222
EXPECT_EQ(CheckField({"message_embedded", "map_embedded2", "embedded3"}),
@@ -227,7 +227,7 @@ TEST_F(CloudAuditLogFieldCheckerTest, CyclicPathTestsLeafAsMap) {
227227
FieldCheckResults::kExclude);
228228
}
229229

230-
TEST_F(CloudAuditLogFieldCheckerTest, CyclicPathTestsNonLaefAsMap) {
230+
TEST_F(FieldMaskPathCheckerTest, CyclicPathTestsNonLaefAsMap) {
231231
ASSERT_OK(AddOrIntersectPaths({"map_embedded_message.message_embedded",
232232
"map_embedded_message.embedded2.embedded3",
233233
"singular_int64"}));
@@ -258,7 +258,7 @@ TEST_F(CloudAuditLogFieldCheckerTest, CyclicPathTestsNonLaefAsMap) {
258258
FieldCheckResults::kExclude);
259259
}
260260

261-
TEST_F(CloudAuditLogFieldCheckerTest, NoPathsAdded) {
261+
TEST_F(FieldMaskPathCheckerTest, NoPathsAdded) {
262262
EXPECT_EQ(CheckField({"singular_double"}), FieldCheckResults::kInclude);
263263
EXPECT_EQ(CheckField({"message_embedded"}), FieldCheckResults::kInclude);
264264
EXPECT_EQ(CheckField({"map_embedded_message"}), FieldCheckResults::kInclude);
@@ -268,14 +268,14 @@ TEST_F(CloudAuditLogFieldCheckerTest, NoPathsAdded) {
268268
FieldCheckResults::kInclude);
269269
}
270270

271-
TEST_F(CloudAuditLogFieldCheckerTest, BrokenFieldChecker) {
271+
TEST_F(FieldMaskPathCheckerTest, BrokenFieldChecker) {
272272
ASSERT_THAT(AddOrIntersectPaths({"map_embedded_unknown.message_embedded"}),
273273
StatusIs(
274274
absl::StatusCode::kInvalidArgument
275275
));
276276
}
277277

278-
TEST_F(CloudAuditLogFieldCheckerTest, CheckType) {
278+
TEST_F(FieldMaskPathCheckerTest, CheckType) {
279279
EXPECT_EQ(cloud_audit_log_field_checker()->CheckType(nullptr),
280280
FieldCheckResults::kInclude);
281281

proto_processing_lib/proto_scrubber/testdata/cloud_audit_log_field_checker_test.proto renamed to proto_processing_lib/proto_scrubber/testdata/field_mask_path_checker_test.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ message TestMessage {
120120
map<int64, TestEmbeddedMessage> map_embedded_message = 32;
121121
}
122122

123-
service CloudAuditLogService {
123+
service FieldMaskPathCheckerTestService {
124124
// Test method.
125125
rpc TestMethod(TestMessage) returns (TestMessage);
126126
}

0 commit comments

Comments
 (0)