Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle None for signal_id in GetValue endpoint #123

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions databroker/src/grpc/kuksa_val_v2/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,10 @@ async fn get_signal(
signal_id: Option<proto::SignalId>,
broker: &AuthorizedAccess<'_, '_>,
) -> Result<i32, tonic::Status> {
if signal_id.is_none() {
return Err(tonic::Status::invalid_argument("No SignalId provided"));
}

if let Some(signal) = signal_id.unwrap().signal {
match signal {
proto::signal_id::Signal::Path(path) => {
Expand Down Expand Up @@ -1175,6 +1179,28 @@ mod tests {
}
}

#[tokio::test]
async fn test_get_value_with_signal_id_none() {
let broker = DataBroker::default();

let request = proto::GetValueRequest { signal_id: None };

// Manually insert permissions
let mut get_value_request = tonic::Request::new(request);
get_value_request
.extensions_mut()
.insert(permissions::ALLOW_ALL.clone());

match broker.get_value(get_value_request).await {
Ok(_response) => {
panic!("Did not expect success");
}
Err(status) => {
assert_eq!(status.code(), tonic::Code::InvalidArgument)
}
}
}

struct GetValuesConfig {
send_auth: bool,
request_first: bool,
Expand Down
Loading