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
d2a1648
commit 052a8a1
Showing
7 changed files
with
250 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,65 @@ | ||
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/fixtures/valid.conf").expect("should read and parse XML input"); | ||
|
||
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() | ||
} | ||
); | ||
} | ||
|
||
#[should_panic] | ||
#[test] | ||
fn config_read_file_with_missing_include_err() { | ||
Config::read_file("./tests/fixtures/missing_include.conf") | ||
.expect("should read and parse XML input"); | ||
} | ||
|
||
#[should_panic] | ||
#[test] | ||
fn config_read_file_with_transitive_missing_include_err() { | ||
Config::read_file("./tests/fixtures/transitive_missing_include.conf") | ||
.expect("should read and parse XML input"); | ||
} |
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,5 @@ | ||
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" | ||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> | ||
<busconfig> | ||
<include>./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,5 @@ | ||
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" | ||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> | ||
<busconfig> | ||
<include>./missing_include.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,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>./valid_included.conf</include> | ||
<include ignore_missing="yes">./valid_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> |