forked from dbus2/busd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented by iterating over the `Vec<Element>`, inspired by work by @elmarco , although this version doesn't have all the same features and validations as dbus2#23
- Loading branch information
1 parent
4316545
commit 44bb379
Showing
5 changed files
with
218 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use std::collections::HashSet; | ||
|
||
use busd::config::{Access, Config, Name, Operation, OwnOperation, Policy}; | ||
|
||
#[test] | ||
fn config_read_file_with_includes_ok() { | ||
let got = Config::read_file("./tests/fixture.conf") | ||
.expect("should read and parse ./tests/fixture.conf"); | ||
|
||
assert_eq!( | ||
got, | ||
Config { | ||
auth: HashSet::from_iter(vec![String::from("ANONYMOUS"), String::from("EXTERNAL"),]), | ||
listen: HashSet::from_iter(vec![ | ||
String::from("unix:path=/tmp/foo"), | ||
String::from("tcp:host=localhost,port=1234"), | ||
]), | ||
policies: vec![ | ||
Policy::DefaultContext(vec![ | ||
( | ||
Access::Allow, | ||
Operation::Own(OwnOperation { | ||
own: Some(Name::Any) | ||
}) | ||
), | ||
( | ||
Access::Deny, | ||
Operation::Own(OwnOperation { | ||
own: Some(Name::Any) | ||
}) | ||
), | ||
]), | ||
Policy::MandatoryContext(vec![ | ||
( | ||
Access::Deny, | ||
Operation::Own(OwnOperation { | ||
own: Some(Name::Any) | ||
}) | ||
), | ||
( | ||
Access::Allow, | ||
Operation::Own(OwnOperation { | ||
own: Some(Name::Any) | ||
}) | ||
), | ||
],), | ||
], | ||
..Default::default() | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" | ||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> | ||
<busconfig> | ||
<auth>ANONYMOUS</auth> | ||
<listen>unix:path=/tmp/foo</listen> | ||
<policy context="default"> | ||
<allow own="*"/> | ||
<deny own="*"/> | ||
</policy> | ||
<include>./fixture_included.conf</include> | ||
<include ignore_missing="yes">./fixture_missing.conf</include> | ||
</busconfig> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" | ||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> | ||
<busconfig> | ||
<auth>EXTERNAL</auth> | ||
<listen>tcp:host=localhost,port=1234</listen> | ||
<policy context="mandatory"> | ||
<deny own="*"/> | ||
<allow own="*"/> | ||
</policy> | ||
</busconfig> |