Skip to content

Commit

Permalink
🔥 Remove Default trait from (send|receive_*)
Browse files Browse the repository at this point in the history
  • Loading branch information
jokeyrhyme committed Nov 16, 2024
1 parent 5216e23 commit d3e080e
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ impl TryFrom<PolicyElement> for OptionalPolicy {
}
}

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq)]
pub struct ReceiveOperation {
pub error: Option<String>,
pub interface: Option<String>,
Expand Down Expand Up @@ -531,7 +531,7 @@ fn rules_try_from_rule_elements(value: Vec<RuleElement>) -> Result<Vec<Rule>> {

pub type Rule = (Access, Operation);

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq)]
pub struct SendOperation {
pub broadcast: Option<bool>,
pub destination: Option<Destination>,
Expand Down Expand Up @@ -845,18 +845,29 @@ mod tests {
(
Access::Allow,
Operation::Send(SendOperation {
broadcast: None,
destination: Some(Destination::Prefix(String::from(
"org.freedesktop"
))),
..Default::default()
error: None,
interface: None,
max_fds: None,
min_fds: None,
path: None,
r#type: None
})
),
// `<allow send_member=...` should be dropped
(
Access::Allow,
Operation::Receive(ReceiveOperation {
sender: Some(String::from("org.freedesktop.Avahi")),
..Default::default()
error: None,
interface: None,
max_fds: None,
min_fds: None,
path: None,
r#type: None
})
),
],
Expand All @@ -865,8 +876,14 @@ mod tests {
Policy::MandatoryContext(vec![(
Access::Deny,
Operation::Send(SendOperation {
broadcast: None,
destination: Some(Destination::Name(String::from("net.connman.iwd"))),
..Default::default()
error: None,
interface: None,
max_fds: None,
min_fds: None,
path: None,
r#type: None
})
),]),
],
Expand Down Expand Up @@ -909,8 +926,14 @@ mod tests {
Access::Allow,
// `eavesdrop="true"` is dropped, keep other attributes
Operation::Send(SendOperation {
broadcast: None,
destination: Some(Destination::Any),
..Default::default()
error: None,
interface: None,
max_fds: None,
min_fds: None,
path: None,
r#type: None
})
),
// `<allow eavesdrop="true"/>` has nothing left after dropping eavesdrop
Expand All @@ -922,12 +945,16 @@ mod tests {
(
Access::Allow,
Operation::Send(SendOperation {
broadcast: None,
destination: Some(Destination::Name(String::from(
"org.gnome.DisplayManager"
))),
interface: Some(String::from("org.gnome.DisplayManager.Manager")),
// `member=... is dropped`
..Default::default()
error: None,
max_fds: None,
min_fds: None,
path: None,
r#type: None
}),
),
]),
Expand Down

0 comments on commit d3e080e

Please sign in to comment.