Skip to content

Commit

Permalink
test breaking changes using shared validators
Browse files Browse the repository at this point in the history
  • Loading branch information
jakedoublev committed Oct 16, 2024
1 parent 69c5727 commit 61aa46e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
3 changes: 2 additions & 1 deletion service/policy/kasregistry/key_access_server_registry.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package policy.kasregistry;

import "buf/validate/validate.proto";
import "common/common.proto";
import "policy/validator.proto";
import "google/api/annotations.proto";
import "policy/objects.proto";

Expand Down Expand Up @@ -82,7 +83,7 @@ message ListKeyAccessServerGrantsRequest {
// Optional
// Filter LIST by either ID or URI of a registered Key Access Server.
// If neither is provided, grants from all registered KASs to policy attribute objects are returned.
string kas_id = 1; // TOOD: test ignore_empty and other options for validating UUID only when not empty
OptionalUUID kas_id = 1;

Check failure on line 86 in service/policy/kasregistry/key_access_server_registry.proto

View workflow job for this annotation

GitHub Actions / Protocol Buffer Lint and Gencode Up-to-date check

Field "1" with name "kas_id" on message "ListKeyAccessServerGrantsRequest" changed cardinality from "optional with implicit presence" to "optional with explicit presence".

Check failure on line 86 in service/policy/kasregistry/key_access_server_registry.proto

View workflow job for this annotation

GitHub Actions / Protocol Buffer Lint and Gencode Up-to-date check

Field "1" with name "kas_id" on message "ListKeyAccessServerGrantsRequest" changed type from "string" to "message".

Check failure on line 86 in service/policy/kasregistry/key_access_server_registry.proto

View workflow job for this annotation

GitHub Actions / Protocol Buffer Lint and Gencode Up-to-date check

Field "1" with name "kas_id" on message "ListKeyAccessServerGrantsRequest" changed type from "string" to "message". See https://developers.google.com/protocol-buffers/docs/proto3#updating for wire compatibility rules.

Check failure on line 86 in service/policy/kasregistry/key_access_server_registry.proto

View workflow job for this annotation

GitHub Actions / Protocol Buffer Lint and Gencode Up-to-date check

Field "1" with name "kas_id" on message "ListKeyAccessServerGrantsRequest" changed type from "string" to "message". See https://developers.google.com/protocol-buffers/docs/proto3#updating for wire compatibility rules and https://developers.google.com/protocol-buffers/docs/proto3#json for JSON compatibility rules.
string kas_uri = 2; // TODO: uri format
}

Expand Down
13 changes: 7 additions & 6 deletions service/policy/resourcemapping/resource_mapping.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import "google/api/annotations.proto";

import "common/common.proto";
import "policy/objects.proto";
import "policy/validator.proto";

/*
Resource Mapping Groups
*/

message ListResourceMappingGroupsRequest {
// Optional
string namespace_id = 1; // TODO: validate UUID only if provided
OptionalUUID namespace_id = 1;

Check failure on line 18 in service/policy/resourcemapping/resource_mapping.proto

View workflow job for this annotation

GitHub Actions / Protocol Buffer Lint and Gencode Up-to-date check

Field "1" with name "namespace_id" on message "ListResourceMappingGroupsRequest" changed cardinality from "optional with implicit presence" to "optional with explicit presence".

Check failure on line 18 in service/policy/resourcemapping/resource_mapping.proto

View workflow job for this annotation

GitHub Actions / Protocol Buffer Lint and Gencode Up-to-date check

Field "1" with name "namespace_id" on message "ListResourceMappingGroupsRequest" changed type from "string" to "message".

Check failure on line 18 in service/policy/resourcemapping/resource_mapping.proto

View workflow job for this annotation

GitHub Actions / Protocol Buffer Lint and Gencode Up-to-date check

Field "1" with name "namespace_id" on message "ListResourceMappingGroupsRequest" changed type from "string" to "message". See https://developers.google.com/protocol-buffers/docs/proto3#updating for wire compatibility rules.

Check failure on line 18 in service/policy/resourcemapping/resource_mapping.proto

View workflow job for this annotation

GitHub Actions / Protocol Buffer Lint and Gencode Up-to-date check

Field "1" with name "namespace_id" on message "ListResourceMappingGroupsRequest" changed type from "string" to "message". See https://developers.google.com/protocol-buffers/docs/proto3#updating for wire compatibility rules and https://developers.google.com/protocol-buffers/docs/proto3#json for JSON compatibility rules.
}

message ListResourceMappingGroupsResponse {
Expand Down Expand Up @@ -58,7 +59,7 @@ message UpdateResourceMappingGroupRequest {
];

// Optional
string namespace_id = 2; // TODO: validate UUID only when provided
OptionalUUID namespace_id = 2;

Check failure on line 62 in service/policy/resourcemapping/resource_mapping.proto

View workflow job for this annotation

GitHub Actions / Protocol Buffer Lint and Gencode Up-to-date check

Field "2" with name "namespace_id" on message "UpdateResourceMappingGroupRequest" changed cardinality from "optional with implicit presence" to "optional with explicit presence".

Check failure on line 62 in service/policy/resourcemapping/resource_mapping.proto

View workflow job for this annotation

GitHub Actions / Protocol Buffer Lint and Gencode Up-to-date check

Field "2" with name "namespace_id" on message "UpdateResourceMappingGroupRequest" changed type from "string" to "message".

string name = 3;

Expand Down Expand Up @@ -89,7 +90,7 @@ message DeleteResourceMappingGroupResponse {

message ListResourceMappingsRequest {
// Optional
string group_id = 1; // TODO: validate UUID only when provided
OptionalUUID group_id = 1;
}

message ListResourceMappingsResponse {
Expand Down Expand Up @@ -145,7 +146,7 @@ message CreateResourceMappingRequest {
repeated string terms = 2 [(buf.validate.field).required = true]; // TODO: validate list min/max and term min/max

// Optional
string group_id = 3; // TODO: validate UUID only when provided
OptionalUUID group_id = 3;

common.MetadataMutable metadata = 100;
}
Expand All @@ -161,11 +162,11 @@ message UpdateResourceMappingRequest {
];

// Optional
string attribute_value_id = 4; // TODO: validate UUID only when provided
OptionalUUID attribute_value_id = 4;

repeated string terms = 5; // TODO: validate list min/max and term min/max

string group_id = 6; // TODO: validate UUID only when provided
OptionalUUID group_id = 6;

// Common Metadata
common.MetadataMutable metadata = 100;
Expand Down
5 changes: 3 additions & 2 deletions service/policy/subjectmapping/subject_mapping.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "google/api/annotations.proto";

import "common/common.proto";
import "policy/objects.proto";
import "policy/validator.proto";

// MatchSubjectMappingsRequest liberally returns a list of SubjectMappings based on the provided SubjectProperties. The SubjectMappings are returned
// if there is any single condition found among the structures that matches for one of the provided properties:
Expand Down Expand Up @@ -58,7 +59,7 @@ message CreateSubjectMappingRequest{

// Either of the following:
// Reuse existing SubjectConditionSet (NOTE: prioritized over new_subject_condition_set)
string existing_subject_condition_set_id = 3; // TODO: validate UUID only when provided
OptionalUUID existing_subject_condition_set_id = 3;
// Create new SubjectConditionSet (NOTE: ignored if existing_subject_condition_set_id is provided)
SubjectConditionSetCreate new_subject_condition_set = 4;

Expand All @@ -78,7 +79,7 @@ message UpdateSubjectMappingRequest {

// Optional
// Replaces the existing SubjectConditionSet id with a new one
string subject_condition_set_id = 2; // TODO: validate UUID only when provided
OptionalUUID subject_condition_set_id = 2;
// Replaces entire list of actions permitted by subjects
repeated policy.Action actions = 3;

Expand Down
19 changes: 19 additions & 0 deletions service/policy/validator.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
syntax = "proto3";

package policy;

import "buf/validate/validate.proto";

message OptionalUUID {
string value = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).string.uuid = true
];
}

message RequiredUUID {
string value = 1 [
(buf.validate.field).required = true,
(buf.validate.field).string.uuid = true
];
}

0 comments on commit 61aa46e

Please sign in to comment.