Skip to content

Commit

Permalink
Changing ListMetaData to correspond to reality
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbosch committed Nov 20, 2024
1 parent 66b1c91 commit 21c7bd0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
23 changes: 9 additions & 14 deletions databroker/src/grpc/kuksa_val_v2/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ impl proto::val_server::Val for broker::DataBroker {
}

// Returns (GRPC error code):
// NOT_FOUND if the specified root branch does not exist.
// NOT_FOUND if no signals matching the request are found.
// UNAUTHENTICATED if no credentials provided or credentials has expired
// INVALID_ARGUMENT if the provided path or wildcard is wrong.
//
Expand All @@ -499,7 +499,7 @@ impl proto::val_server::Val for broker::DataBroker {

let metadata_request = request.into_inner();

match Matcher::new(&metadata_request.root) {
match Matcher::new(&metadata_request.path) {
Ok(matcher) => {
let mut metadata_response = Vec::new();
broker
Expand All @@ -512,7 +512,7 @@ impl proto::val_server::Val for broker::DataBroker {
.await;
if metadata_response.is_empty() {
Err(tonic::Status::not_found(
"Specified root branch does not exist",
"No signals matching given path found",
))
} else {
Ok(tonic::Response::new(ListMetadataResponse {
Expand Down Expand Up @@ -2203,8 +2203,7 @@ mod tests {
.expect("Register datapoint should succeed");

let mut data_req = tonic::Request::new(proto::ListMetadataRequest {
root: "test.datapoint1".to_owned(),
filter: "".to_owned(),
path: "test.datapoint1".to_owned(),
});

// Manually insert permissions
Expand Down Expand Up @@ -2270,13 +2269,11 @@ mod tests {
.expect("Register datapoint should succeed");

let mut wildcard_req_two_asteriks = tonic::Request::new(proto::ListMetadataRequest {
root: "test.**".to_owned(),
filter: "".to_owned(),
path: "test.**".to_owned(),
});

let mut wildcard_req_one_asterik = tonic::Request::new(proto::ListMetadataRequest {
root: "test.*".to_owned(),
filter: "".to_owned(),
path: "test.*".to_owned(),
});
// Manually insert permissions
wildcard_req_two_asteriks
Expand Down Expand Up @@ -2331,8 +2328,7 @@ mod tests {
.expect("Register datapoint should succeed");

let mut wildcard_req = tonic::Request::new(proto::ListMetadataRequest {
root: "test. **".to_owned(),
filter: "".to_owned(),
path: "test. **".to_owned(),
});

// Manually insert permissions
Expand Down Expand Up @@ -2360,8 +2356,7 @@ mod tests {
}

let mut not_found_req = tonic::Request::new(proto::ListMetadataRequest {
root: "test.notfound".to_owned(),
filter: "".to_owned(),
path: "test.notfound".to_owned(),
});

// Manually insert permissions
Expand All @@ -2378,7 +2373,7 @@ mod tests {
assert_eq!(error.code(), tonic::Code::NotFound, "unexpected error code");
assert_eq!(
error.message(),
"Specified root branch does not exist",
"No signals matching given path found",
"unexpected error reason"
);
}
Expand Down
7 changes: 4 additions & 3 deletions proto/kuksa/val/v2/val.proto
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ service VAL {
// List metadata of signals matching the request.
//
// Returns (GRPC error code):
// NOT_FOUND if the specified root branch does not exist.
// NOT_FOUND if no signals matching the request are found.
// UNAUTHENTICATED if no credentials provided or credentials has expired
// INVALID_ARGUMENT if the provided path or wildcard is wrong.
//
Expand Down Expand Up @@ -247,8 +247,9 @@ message BatchActuateResponse {
}

message ListMetadataRequest {
string root = 1;
string filter = 2;
// A path which may include wildcards
// See https://github.com/eclipse-kuksa/kuksa-databroker/blob/main/doc/wildcard_matching.md
string path = 1;
}

message ListMetadataResponse {
Expand Down

0 comments on commit 21c7bd0

Please sign in to comment.