Skip to content

Commit 0e0112c

Browse files
authored
initial artemis client code (#129)
1 parent 1c36c19 commit 0e0112c

File tree

41 files changed

+1001
-112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1001
-112
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Added
2+
body: Initial code for artemis client
3+
time: 2024-04-09T22:01:12.716881-04:00
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Added
2+
body: Initial script for macOS app sigining
3+
time: 2024-04-09T22:01:42.622749-04:00

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
if: matrix.info.os == 'windows-latest'
8080
run: just --shell pwsh.exe --shell-arg -c _coverage
8181
- name: Upload coverage to Codecov
82-
uses: codecov/codecov-action@v4.20
82+
uses: codecov/codecov-action@v4.2.0
8383
with:
8484
token: ${{ secrets.CODECOV_TOKEN }}
8585
files: lcov.info

.justfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ linux: (_test "artifacts::os::linux")
5151
# Test all the Unix artifacts
5252
unix: (_test "artifacts::os::unix")
5353

54+
# Spawn single client and attempt to connect to server
55+
client:
56+
cd client && cargo build --release --examples
57+
cd target/release/examples && ./start_client ../../../client/tests/test_data/client.toml
58+
59+
5460
# Compile WASM and server code then start the server
5561
server:(_wasm)
5662
cd server && cargo build --release --examples

Cargo.lock

Lines changed: 33 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["cli", "core", "server", "webui", "common"]
2+
members = ["cli", "core", "server", "webui", "common", "client"]
33
resolver = "2"
44

55
[profile.release]

cli/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
[package]
22
name = "artemis"
3+
license = { workspace = true }
34
edition = { workspace = true }
45
version = { workspace = true }
5-
license = "MIT"
6+
homepage = { workspace = true }
7+
repository = { workspace = true }
68

79
[dependencies]
810
base64 = { workspace = true }

client/Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "client"
3+
license = { workspace = true }
4+
edition = { workspace = true }
5+
version = { workspace = true }
6+
homepage = { workspace = true }
7+
repository = { workspace = true }
8+
9+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
10+
11+
[dependencies]
12+
tokio = { workspace = true }
13+
log = { workspace = true }
14+
serde = { workspace = true }
15+
serde_json = { workspace = true }
16+
uuid = { workspace = true }
17+
toml = { workspace = true }
18+
reqwest = { workspace = true }
19+
sysinfo = { workspace = true }
20+
21+
common = { path = "../common" }
22+
23+
tokio-tungstenite = "0.21.0"
24+
25+
[dev-dependencies]
26+
httpmock = "0.7.0"

client/examples/start_client.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use client::client::start;
2+
use std::{env, path::Path};
3+
4+
fn main() {
5+
let args: Vec<String> = env::args().collect();
6+
7+
if args.len() == 2 {
8+
let path = &args[1];
9+
if Path::new(path).is_file() {
10+
start(path);
11+
} else {
12+
println!("Not client config file")
13+
}
14+
} else {
15+
println!("Require TOML config input file. See tests for an example")
16+
}
17+
}

client/src/client.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use crate::{enrollment::enroll::enroll_client, filesystem::config::read_config};
2+
use log::error;
3+
4+
#[tokio::main]
5+
pub async fn start(path: &str) {
6+
let config_result = read_config(path).await;
7+
let mut config = match config_result {
8+
Ok(result) => result,
9+
Err(err) => {
10+
error!("[client] Could not read config at {path}. Cannot start client without a config file: {err:?}");
11+
return;
12+
}
13+
};
14+
15+
let enroll_status = enroll_client(&mut config).await;
16+
if enroll_status.is_err() {
17+
error!(
18+
"[client] Could not read enroll endpoint: {:?}",
19+
enroll_status.unwrap_err()
20+
);
21+
return;
22+
}
23+
}
24+
25+
#[cfg(test)]
26+
mod tests {
27+
use super::start;
28+
use std::path::PathBuf;
29+
30+
#[test]
31+
#[ignore = "Spawns client"]
32+
fn test_start() {
33+
let mut test_location = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
34+
test_location.push("tests/test_data/client.toml");
35+
let config_path = test_location.display().to_string();
36+
start(&config_path)
37+
}
38+
}

0 commit comments

Comments
 (0)