Skip to content

Commit

Permalink
initial artemis client code (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
puffyCid committed Apr 10, 2024
1 parent 1c36c19 commit 0e0112c
Show file tree
Hide file tree
Showing 41 changed files with 1,001 additions and 112 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Added-20240409-220112.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Added
body: Initial code for artemis client
time: 2024-04-09T22:01:12.716881-04:00
3 changes: 3 additions & 0 deletions .changes/unreleased/Added-20240409-220142.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Added
body: Initial script for macOS app sigining
time: 2024-04-09T22:01:42.622749-04:00
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
if: matrix.info.os == 'windows-latest'
run: just --shell pwsh.exe --shell-arg -c _coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.20
uses: codecov/codecov-action@v4.2.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
Expand Down
6 changes: 6 additions & 0 deletions .justfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ linux: (_test "artifacts::os::linux")
# Test all the Unix artifacts
unix: (_test "artifacts::os::unix")

# Spawn single client and attempt to connect to server
client:
cd client && cargo build --release --examples
cd target/release/examples && ./start_client ../../../client/tests/test_data/client.toml


# Compile WASM and server code then start the server
server:(_wasm)
cd server && cargo build --release --examples
Expand Down
49 changes: 33 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["cli", "core", "server", "webui", "common"]
members = ["cli", "core", "server", "webui", "common", "client"]
resolver = "2"

[profile.release]
Expand Down
4 changes: 3 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[package]
name = "artemis"
license = { workspace = true }
edition = { workspace = true }
version = { workspace = true }
license = "MIT"
homepage = { workspace = true }
repository = { workspace = true }

[dependencies]
base64 = { workspace = true }
Expand Down
26 changes: 26 additions & 0 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "client"
license = { workspace = true }
edition = { workspace = true }
version = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { workspace = true }
log = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
uuid = { workspace = true }
toml = { workspace = true }
reqwest = { workspace = true }
sysinfo = { workspace = true }

common = { path = "../common" }

tokio-tungstenite = "0.21.0"

[dev-dependencies]
httpmock = "0.7.0"
17 changes: 17 additions & 0 deletions client/examples/start_client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use client::client::start;
use std::{env, path::Path};

fn main() {
let args: Vec<String> = env::args().collect();

if args.len() == 2 {
let path = &args[1];
if Path::new(path).is_file() {
start(path);
} else {
println!("Not client config file")
}
} else {
println!("Require TOML config input file. See tests for an example")
}
}
38 changes: 38 additions & 0 deletions client/src/client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use crate::{enrollment::enroll::enroll_client, filesystem::config::read_config};
use log::error;

#[tokio::main]
pub async fn start(path: &str) {
let config_result = read_config(path).await;
let mut config = match config_result {
Ok(result) => result,
Err(err) => {
error!("[client] Could not read config at {path}. Cannot start client without a config file: {err:?}");
return;
}
};

let enroll_status = enroll_client(&mut config).await;
if enroll_status.is_err() {
error!(
"[client] Could not read enroll endpoint: {:?}",
enroll_status.unwrap_err()
);
return;
}
}

#[cfg(test)]
mod tests {
use super::start;
use std::path::PathBuf;

#[test]
#[ignore = "Spawns client"]
fn test_start() {
let mut test_location = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
test_location.push("tests/test_data/client.toml");
let config_path = test_location.display().to_string();
start(&config_path)
}
}
Loading

0 comments on commit 0e0112c

Please sign in to comment.