about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-12-09 13:30:25 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-12-09 13:30:25 +0100
commitf7869a09906747d0797dcd8c49c069fa8f02930c (patch)
treef219226e62d16995cd4906d57f7e279b591460ff
parentstyle(treewide): Format (diff)
downloadserver-f7869a09906747d0797dcd8c49c069fa8f02930c.zip
chore(treewide): Remove last references to old paths
-rw-r--r--crates/rocie-cli/src/cli.rs12
-rw-r--r--crates/rocie-cli/src/handle/mod.rs41
-rw-r--r--crates/rocie-cli/src/main.rs9
-rw-r--r--crates/rocie-server/tests/users/mod.rs25
4 files changed, 62 insertions, 25 deletions
diff --git a/crates/rocie-cli/src/cli.rs b/crates/rocie-cli/src/cli.rs
index 626a7b1..376eda5 100644
--- a/crates/rocie-cli/src/cli.rs
+++ b/crates/rocie-cli/src/cli.rs
@@ -15,6 +15,12 @@ pub(crate) enum Command {
         command: ProductCommand,
     },
 
+    /// Deal with users
+    User {
+        #[command(subcommand)]
+        command: UserCommand,
+    },
+
     /// Deal with parents
     Parents {
         #[command(subcommand)]
@@ -41,6 +47,12 @@ pub(crate) enum Command {
 }
 
 #[derive(Subcommand)]
+pub(crate) enum UserCommand {
+    /// List all registered users
+    List {},
+}
+
+#[derive(Subcommand)]
 pub(crate) enum ProductParentCommand {
     /// Register a new product parent
     Register {
diff --git a/crates/rocie-cli/src/handle/mod.rs b/crates/rocie-cli/src/handle/mod.rs
index 4e63696..4e30f77 100644
--- a/crates/rocie-cli/src/handle/mod.rs
+++ b/crates/rocie-cli/src/handle/mod.rs
@@ -1,16 +1,17 @@
-use crate::cli::{BarcodeCommand, ProductCommand, UnitCommand, UnitPropertyCommand};
+use crate::cli::{BarcodeCommand, ProductCommand, UnitCommand, UnitPropertyCommand, UserCommand};
 
 use anyhow::{Context, Result};
 use rocie_client::{
     apis::{
-        api_get_inventory_api::amount_by_id,
-        api_get_product_api::{product_by_id, products_registered},
-        api_get_unit_api::{unit_by_id, units},
-        api_get_unit_property_api::{unit_properties, unit_property_by_id},
-        api_set_barcode_api::{buy_barcode, consume_barcode},
-        api_set_product_api::{associate_barcode, register_product},
-        api_set_unit_api::register_unit,
-        api_set_unit_property_api::register_unit_property,
+        api_get_auth_inventory_api::amount_by_id,
+        api_get_auth_product_api::{product_by_id, products_registered},
+        api_get_auth_unit_api::{unit_by_id, units},
+        api_get_auth_unit_property_api::{unit_properties, unit_property_by_id},
+        api_get_auth_user_api::users,
+        api_set_auth_barcode_api::{buy_barcode, consume_barcode},
+        api_set_auth_product_api::{associate_barcode, register_product},
+        api_set_auth_unit_api::register_unit,
+        api_set_auth_unit_property_api::register_unit_property,
         configuration::Configuration,
     },
     models::{
@@ -19,6 +20,16 @@ use rocie_client::{
     },
 };
 
+pub(crate) async fn user(config: &Configuration, command: UserCommand) -> Result<()> {
+    match command {
+        UserCommand::List {} => {
+            users(config).await?;
+        }
+    }
+
+    Ok(())
+}
+
 #[expect(clippy::too_many_lines)]
 pub(crate) async fn product(config: &Configuration, command: ProductCommand) -> Result<()> {
     match command {
@@ -227,15 +238,9 @@ pub(crate) async fn unit_property(
 ) -> Result<()> {
     match command {
         UnitPropertyCommand::Register { name, description } => {
-            let new_id = register_unit_property(
-                config,
-                UnitPropertyStub {
-                    description,
-                    name,
-                },
-            )
-            .await
-            .context("Failed to register unit property")?;
+            let new_id = register_unit_property(config, UnitPropertyStub { description, name })
+                .await
+                .context("Failed to register unit property")?;
             println!("Registered new unit property with id: {new_id}");
         }
         UnitPropertyCommand::List {} => {
diff --git a/crates/rocie-cli/src/main.rs b/crates/rocie-cli/src/main.rs
index 2a4eaac..0b3ec09 100644
--- a/crates/rocie-cli/src/main.rs
+++ b/crates/rocie-cli/src/main.rs
@@ -15,11 +15,12 @@ async fn main() -> Result<()> {
     "http://127.0.0.1:8080".clone_into(&mut config.base_path);
 
     match args.command {
-        Command::Product{command}=>handle::product(&config,command).await?,
-        Command::Unit{command}=>handle::unit(&config,command).await?,
-        Command::Barcode{command}=>handle::barcode(&config,command).await?,
-        Command::UnitProperty{command}=>handle::unit_property(&config,command).await?,
+        Command::Product { command } => handle::product(&config, command).await?,
+        Command::Unit { command } => handle::unit(&config, command).await?,
+        Command::Barcode { command } => handle::barcode(&config, command).await?,
+        Command::UnitProperty { command } => handle::unit_property(&config, command).await?,
         Command::Parents { command } => todo!(),
+        Command::User { command } => handle::user(&config, command).await?,
     }
 
     Ok(())
diff --git a/crates/rocie-server/tests/users/mod.rs b/crates/rocie-server/tests/users/mod.rs
index eaa387f..8138691 100644
--- a/crates/rocie-server/tests/users/mod.rs
+++ b/crates/rocie-server/tests/users/mod.rs
@@ -1,8 +1,8 @@
 use rocie_client::{
     apis::{
-        api_get_no_auth_user_api::user_by_id,
+        api_get_auth_user_api::user_by_id,
         api_set_auth_user_api::register_user,
-        api_set_no_auth_user_api::{login, logout},
+        api_set_no_auth_user_api::{login, logout, provision},
     },
     models::{LoginInfo, UserStub},
 };
@@ -10,11 +10,30 @@ use rocie_client::{
 use crate::testenv::{TestEnv, init::function_name, log::request};
 
 #[tokio::test]
-async fn test_register_user() {
+async fn test_provisioning() {
     let env = TestEnv::new_no_login(function_name!());
 
     let user_id = request!(
         env,
+        provision(UserStub {
+            description: None,
+            name: "James Richard Haynes".to_string(),
+            password: "hunter14".to_string()
+        })
+    );
+
+    let user = request!(env, user_by_id(user_id));
+
+    assert_eq!(&user.name, "James Richard Haynes");
+    assert_eq!(user.description, None);
+}
+
+#[tokio::test]
+async fn test_register_user() {
+    let env = TestEnv::new(function_name!()).await;
+
+    let user_id = request!(
+        env,
         register_user(UserStub {
             description: Some("Myself".to_string()),
             name: "me".to_string(),