-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
168 additions
and
35 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
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,25 @@ | ||
-----BEGIN PUBLIC KEY----- | ||
MIIEIjANBgkqhkiG9w0BAQEFAAOCBA8AMIIECgKCBAEAsYILpb/aVzhKuwAMqSX8 | ||
Ao57fgaPpqIOoRiAxUzu19Mi5+SHA7JhzVKTRV23oUQt8KyvOMPsfYkfIuWqu5ZV | ||
mJDN0NbN5PwmQWjYY0kDCKzjdkxWCgxLXT9E7SCqJk4i6DaLnzEKuj0cnOHzqtpu | ||
39tKkefWSFBzp52YCEyAIFMO62G0l76PRuowz/tlWaLAxA+eleGg4DJWWgiy8Kss | ||
xhkLJkTy78jufaHgxKlpzvCF3QAhrWEDLPBPx83SlIaYuhtXZMhfd3w0on6ii5wN | ||
N5AcsalnBLPV/mduXNkSSYxsXq4wkXOakXOxo4ZPbwVsy7QFe/IrroLZ+Z4CTTkO | ||
zbbS/HkDQhxzmY0bsBwihQBOOaSVZ9r5baB4DWzrkepjTkJqf6seJdbiG98ADwTN | ||
wNCn11kf4zHR7tfsX8QG3sdVPS2NbxhxbKm4na9gNN1PpWBSog6fCw3h2awyFWFO | ||
f1xKFmeCpC6TiJscQiAk31nJV6gW0qcAmwDH36F/fcn+buxu/0WYxDtQHLkw4Yp4 | ||
p57RFwRXv17awz9hZeAdeU5kcBu89o8frldTtUKshCXecNqDJf2ogNgFeqHugOSy | ||
g1V/py3UZso4a/ohfl98h4XxWmeigZyosowE0zf7wgtVgNZaEbX77WWYaun2P4ka | ||
RsMHRQGMEBQerI9tPHLJYeb4hc0d69Ei7Ukv0X0H3mLWSBixZiSV0cuC150TCYIE | ||
aEFqdkMhgSELUtKZBDVjfQv4XfbqU1bNHcC+CeoYvjz7VheqfWcZm7AEqFW1oVQ1 | ||
iaixe6VyIb2yhtoZsi3C0eCg26l/q3DnL8lxUOeuyDhjtnxiB8DZwTmiD2qxlPEt | ||
vy4VtsJeZwDhyxCzBXkClq1TwcxSsHjultcTWnxB/uiaCIL8CLspowEYwUd4SLF6 | ||
QdAUZ+JYV2QLIeHB36WQg1mBZyg6ELysXkQRoJ6xfAgdjJHesI78rt22aQs0I6+q | ||
vYWDPLzkfutcwzaWlHZvwDVoQzvap1U52zNR/VIxaOH/GLvmAgJkGGgoAl47FOub | ||
lOV760WBHOslbFP4O1hxAI+MUiUpdyT34bbrWZZq3HWCYiWgLoFUi7NsuteRYz6N | ||
xXdDYXlOXWEBQlmq90ozFAv0SYKM41AxxTNkX5foy53sRajPwCtXHmmC2X60FbDj | ||
0/mptvlqt0LyflPbjxXAkfTH1jISZx30yVvmmSSIpqDsJqRVLmHfWBDEA7gVljU4 | ||
/g0SqONHBfa4dSuKikNhtdpVfdlRErjXNtQ1OzxfnKlOxTepiOxyy7zbU9kyUmbU | ||
AguhECfVELBTO16MXgXZ5hY184iifFuOEBy/wGE8wjzWQp749dlDldqy8trVR8Qh | ||
WQIDAQAB | ||
-----END PUBLIC KEY----- |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
address = "127.0.0.1:8080" | ||
config_dir = "/etc/ruroco/" | ||
config_dir = "tests/conf_dir" | ||
|
||
[commands] | ||
default = "touch /tmp/ruroco_test/start.test /tmp/ruroco_test/stop.test" |
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,2 @@ | ||
foo = "bar" | ||
baz = "foo" |
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 |
---|---|---|
@@ -1,23 +1,72 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
use ruroco::config_server::ConfigServer; | ||
use ruroco::server::Server; | ||
use std::env; | ||
use std::path::PathBuf; | ||
|
||
use ruroco::config_server::ConfigServer; | ||
use ruroco::server::Server; | ||
#[test] | ||
fn test_create_invalid_pid() { | ||
env::set_var("LISTEN_PID", "12345"); | ||
|
||
let conf_dir_path = | ||
env::current_dir().unwrap_or(PathBuf::from("/tmp")).join("tests").join("conf_dir"); | ||
|
||
let result = Server::create(ConfigServer { | ||
address: String::from("127.0.0.1:8082"), | ||
config_dir: conf_dir_path, | ||
..Default::default() | ||
}); | ||
|
||
assert!(result.is_ok()); | ||
} | ||
|
||
#[test] | ||
fn test_create_from_path() { | ||
let path = | ||
env::current_dir().unwrap_or(PathBuf::from("/tmp")).join("tests").join("config.toml"); | ||
let tests_dir_path = env::current_dir().unwrap_or(PathBuf::from("/tmp")).join("tests"); | ||
let conf_path = tests_dir_path.join("config.toml"); | ||
let conf_dir_path = tests_dir_path.join("conf_dir"); | ||
|
||
let res_path = Server::create_from_path(conf_path).unwrap(); | ||
let res_create = Server::create(ConfigServer { | ||
address: String::from("127.0.0.1:8081"), | ||
config_dir: conf_dir_path, | ||
..Default::default() | ||
}) | ||
.unwrap(); | ||
|
||
assert_eq!(res_path, res_create); | ||
} | ||
|
||
#[test] | ||
fn test_create_from_invalid_path() { | ||
let path = env::current_dir() | ||
.unwrap_or(PathBuf::from("/tmp")) | ||
.join("tests") | ||
.join("config_invalid.toml"); | ||
|
||
let result = Server::create_from_path(path); | ||
|
||
assert!(result.is_err()); | ||
assert_eq!( | ||
result.err().unwrap(), | ||
r#"Could not create TOML from "/home/beac0n/dev/beac0n/ruroco/tests/config_invalid.toml": TOML parse error at line 1, column 1 | ||
| | ||
1 | foo = "bar" | ||
| ^^^^^^^^^^^ | ||
missing field `commands` | ||
"# | ||
); | ||
} | ||
|
||
#[test] | ||
fn test_create_from_invalid_toml_path() { | ||
let result = Server::create_from_path(PathBuf::from("/tmp/path/does/not/exist")); | ||
|
||
assert!(result.is_err()); | ||
assert_eq!( | ||
Server::create_from_path(path), | ||
Server::create(ConfigServer { | ||
address: String::from("127.0.0.1:8080"), | ||
config_dir: PathBuf::from("/etc/ruroco/"), | ||
..Default::default() | ||
}) | ||
result.err().unwrap(), | ||
r#"Could not read "/tmp/path/does/not/exist": No such file or directory (os error 2)"# | ||
); | ||
} | ||
} |