summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/config_tests.rs36
-rw-r--r--tests/sota_client_tests.rs134
-rw-r--r--tests/toml/default.toml46
-rw-r--r--tests/toml/genivi.toml30
-rw-r--r--tests/toml/old.toml (renamed from tests/sota.toml)12
-rw-r--r--tests/toml/polling.toml5
6 files changed, 123 insertions, 140 deletions
diff --git a/tests/config_tests.rs b/tests/config_tests.rs
new file mode 100644
index 0000000..21dcb4e
--- /dev/null
+++ b/tests/config_tests.rs
@@ -0,0 +1,36 @@
+use std::env;
+use std::path::Path;
+use std::process::{Command, Output};
+
+
+fn run_client(config: &str) -> Output {
+ let out_dir = env::var("OUT_DIR").expect("expected OUT_DIR environment variable");
+ let bin_dir = Path::new(&out_dir).parent().unwrap().parent().unwrap().parent().unwrap();
+
+ Command::new(format!("{}/sota_client", bin_dir.to_str().unwrap()))
+ .arg("--print")
+ .arg(format!("--config={}", config))
+ .output()
+ .unwrap_or_else(|err| panic!("couldn't start client: {}", err))
+}
+
+
+#[test]
+fn default_config() {
+ assert!(run_client("tests/toml/default.toml").status.success());
+}
+
+#[test]
+fn genivi_config() {
+ assert!(run_client("tests/toml/genivi.toml").status.success());
+}
+
+#[test]
+fn old_config() {
+ assert!(run_client("tests/toml/old.toml").status.success());
+}
+
+#[test]
+fn polling_config() {
+ assert!(run_client("tests/toml/polling.toml").status.success() != true);
+}
diff --git a/tests/sota_client_tests.rs b/tests/sota_client_tests.rs
deleted file mode 100644
index fcdbd0d..0000000
--- a/tests/sota_client_tests.rs
+++ /dev/null
@@ -1,134 +0,0 @@
-use std::env;
-use std::fs::File;
-use std::io::Write;
-use std::path::Path;
-use std::process::Command;
-
-
-fn run_client(args: &[&str]) -> String {
- let output = Command::new(format!("{}/sota_client", bin_dir()))
- .args(args)
- .output()
- .unwrap_or_else(|err| panic!("failed to execute child: {}", err));
- String::from_utf8(output.stdout).unwrap()
-}
-
-fn run_client_with_config(filename: &str, args: &[&str], config: &str) -> String {
- let mut file = File::create(filename.to_string()).expect("couldn't create test config file");
- let _ = file.write_all(config.as_bytes()).unwrap();
- let _ = file.flush().unwrap();
- let arg = "--config=".to_string() + filename;
- let mut args = args.to_vec();
- args.push(&arg);
- run_client(&args)
-}
-
-fn bin_dir() -> String {
- let out_dir = env::var("OUT_DIR").unwrap();
- let bin_dir = Path::new(&out_dir)
- .parent().unwrap()
- .parent().unwrap()
- .parent().unwrap();
- String::from(bin_dir.to_str().unwrap())
-}
-
-
-#[test]
-fn help() {
- assert_eq!(run_client(&["-h"]),
- format!(r#"Usage: {}/sota_client [options]
-
-Options:
- -h, --help print this help menu
- --config PATH change config path
- --auth-server URL
- change the auth server
- --auth-client-id ID
- change the auth client id
- --auth-client-secret SECRET
- change the auth client secret
- --auth-credentials-file PATH
- change the auth credentials file
- --core-server URL
- change the core server
- --dbus-name NAME
- change the dbus registration name
- --dbus-path PATH
- change the dbus path
- --dbus-interface INTERFACE
- change the dbus interface name
- --dbus-software-manager NAME
- change the dbus software manager name
- --dbus-software-manager-path PATH
- change the dbus software manager path
- --dbus-timeout TIMEOUT
- change the dbus installation timeout
- --device-uuid UUID
- change the device uuid
- --device-vin VIN
- change the device vin
- --device-packages-dir PATH
- change downloaded directory for packages
- --device-package-manager MANAGER
- change the package manager
- --device-polling-interval INTERVAL
- change the package polling interval
- --device-certificates-path PATH
- change the OpenSSL CA certificates file
- --device-system-info PATH
- change the system information command
- --gateway-console BOOL
- toggle the console gateway
- --gateway-dbus BOOL
- toggle the dbus gateway
- --gateway-http BOOL
- toggle the http gateway
- --gateway-rvi BOOL
- toggle the rvi gateway
- --gateway-socket BOOL
- toggle the unix domain socket gateway
- --gateway-websocket BOOL
- toggle the websocket gateway
- --network-http-server ADDR
- change the http server gateway address
- --network-rvi-edge-server ADDR
- change the rvi edge server gateway address
- --network-socket-commands-path PATH
- change the socket path for reading commands
- --network-socket-events-path PATH
- change the socket path for sending events
- --network-websocket-server ADDR
- change the websocket gateway address
- --rvi-client URL
- change the rvi client URL
- --rvi-storage-dir PATH
- change the rvi storage directory
- --rvi-timeout TIMEOUT
- change the rvi timeout
-
-"#, bin_dir()));
-}
-
-#[test]
-fn bad_ota_server_url() {
- assert_eq!(run_client(&["--config", "tests/sota.toml", "--core-server", "bad-url"]),
- "Invalid core-server URL: Url parse error: relative URL without a base\n")
-}
-
-#[test]
-fn bad_section() {
- assert_eq!(run_client_with_config("/tmp/sota-test-config-1", &[""], "[foo]\n"),
- "Parse error: invalid section: core\n")
-}
-
-#[test]
-fn bad_toml() {
- assert_eq!(run_client_with_config("/tmp/sota-test-config-2", &[""], "auth]"),
- "Toml parser errors: [ParserError { lo: 4, hi: 5, desc: \"expected `=`, but found `]`\" }]\n")
-}
-
-#[test]
-fn bad_path_dir() {
- assert_eq!(run_client(&["--config=/"]),
- "IO error: Is a directory (os error 21)\n")
-}
diff --git a/tests/toml/default.toml b/tests/toml/default.toml
new file mode 100644
index 0000000..77a663b
--- /dev/null
+++ b/tests/toml/default.toml
@@ -0,0 +1,46 @@
+[auth]
+server = "http://127.0.0.1:9001"
+client_id = "client-id"
+client_secret = "client-secret"
+credentials_file = "/tmp/sota_credentials.toml"
+
+[core]
+server = "http://127.0.0.1:8080"
+polling = true
+polling_sec = 10
+
+[dbus]
+name = "org.genivi.SotaClient"
+path = "/org/genivi/SotaClient"
+interface = "org.genivi.SotaClient"
+software_manager = "org.genivi.SoftwareLoadingManager"
+software_manager_path = "/org/genivi/SoftwareLoadingManager"
+timeout = 60
+
+[device]
+uuid = "123e4567-e89b-12d3-a456-426655440000"
+vin = "V1234567890123456"
+packages_dir = "/tmp/"
+package_manager = "off"
+certificates_path = "/tmp/sota_certificates"
+system_info = "system_info.sh"
+
+[gateway]
+console = false
+dbus = false
+http = false
+rvi = false
+socket = false
+websocket = false
+
+[network]
+http_server = "127.0.0.1:8888"
+rvi_edge_server = "127.0.0.1:9080"
+socket_commands_path = "/tmp/sota-commands.socket"
+socket_events_path = "/tmp/sota-events.socket"
+websocket_server = "127.0.0.1:3012"
+
+[rvi]
+client = "http://127.0.0.1:8901"
+storage_dir = "/var/sota"
+timeout = 20
diff --git a/tests/toml/genivi.toml b/tests/toml/genivi.toml
new file mode 100644
index 0000000..5c93d8a
--- /dev/null
+++ b/tests/toml/genivi.toml
@@ -0,0 +1,30 @@
+# Replace 192.168.1.40 with your IP address
+[core]
+server = "http://192.168.1.40:8080"
+polling = false
+
+[dbus]
+name = "org.genivi.SotaClient"
+path = "/org/genivi/SotaClient"
+interface = "org.genivi.SotaClient"
+software_manager = "org.genivi.SoftwareLoadingManager"
+software_manager_path = "/org/genivi/SoftwareLoadingManager"
+timeout = 60
+
+[device]
+uuid = "9ea653bc-3486-44cd-aa86-d936bd957e52"
+packages_dir = "/tmp/"
+package_manager = "off"
+certificates_path = "run/sota_certificates"
+
+[gateway]
+dbus = true
+rvi = true
+
+[network]
+rvi_edge_server = "192.168.1.40:9080"
+
+[rvi]
+client = "http://192.168.1.40:8901"
+storage_dir = "/tmp"
+timeout = 20
diff --git a/tests/sota.toml b/tests/toml/old.toml
index 0801509..21447cd 100644
--- a/tests/sota.toml
+++ b/tests/toml/old.toml
@@ -19,10 +19,10 @@ timeout = 60
uuid = "123e4567-e89b-12d3-a456-426655440000"
vin = "V1234567890123456"
packages_dir = "/tmp/"
-package_manager = "deb"
+package_manager = "off"
+certificates_path = "/tmp/sota_certificates"
system_info = "system_info.sh"
polling_interval = 10
-certificates_path = "/tmp/sota_certificates"
[gateway]
console = false
@@ -30,14 +30,14 @@ dbus = false
http = false
rvi = false
socket = false
-websocket = true
+websocket = false
[network]
-http_server = "http://127.0.0.1:8888"
-rvi_edge_server = "http://127.0.0.1:9080"
+http_server = "127.0.0.1:8888"
+rvi_edge_server = "127.0.0.1:9080"
socket_commands_path = "/tmp/sota-commands.socket"
socket_events_path = "/tmp/sota-events.socket"
-websocket_server = "ws://127.0.0.1:3012"
+websocket_server = "127.0.0.1:3012"
[rvi]
client = "http://127.0.0.1:8901"
diff --git a/tests/toml/polling.toml b/tests/toml/polling.toml
new file mode 100644
index 0000000..a0e29d6
--- /dev/null
+++ b/tests/toml/polling.toml
@@ -0,0 +1,5 @@
+[core]
+polling_sec = 1
+
+[device]
+polling_interval = 2