first pass at access control setup
This commit is contained in:
@@ -66,7 +66,10 @@ async fn test_create_action_with_optional_fields() {
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(action.label, "Full Test Action");
|
||||
assert_eq!(action.description, "Action with all optional fields");
|
||||
assert_eq!(
|
||||
action.description,
|
||||
Some("Action with all optional fields".to_string())
|
||||
);
|
||||
assert_eq!(action.entrypoint, "custom.py");
|
||||
assert!(action.param_schema.is_some());
|
||||
assert!(action.out_schema.is_some());
|
||||
@@ -204,7 +207,9 @@ async fn test_update_action() {
|
||||
|
||||
let update = UpdateActionInput {
|
||||
label: Some("Updated Label".to_string()),
|
||||
description: Some("Updated description".to_string()),
|
||||
description: Some(attune_common::repositories::Patch::Set(
|
||||
"Updated description".to_string(),
|
||||
)),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -214,7 +219,7 @@ async fn test_update_action() {
|
||||
|
||||
assert_eq!(updated.id, action.id);
|
||||
assert_eq!(updated.label, "Updated Label");
|
||||
assert_eq!(updated.description, "Updated description");
|
||||
assert_eq!(updated.description, Some("Updated description".to_string()));
|
||||
assert_eq!(updated.entrypoint, action.entrypoint); // Unchanged
|
||||
assert!(updated.updated > original_updated);
|
||||
}
|
||||
@@ -338,7 +343,7 @@ async fn test_action_foreign_key_constraint() {
|
||||
pack: 99999,
|
||||
pack_ref: "nonexistent.pack".to_string(),
|
||||
label: "Test Action".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
entrypoint: "main.py".to_string(),
|
||||
runtime: None,
|
||||
runtime_version_constraint: None,
|
||||
|
||||
@@ -49,7 +49,7 @@ async fn test_create_enforcement_minimal() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -121,7 +121,7 @@ async fn test_create_enforcement_with_event() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -189,7 +189,7 @@ async fn test_create_enforcement_with_conditions() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -255,7 +255,7 @@ async fn test_create_enforcement_with_any_condition() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -397,7 +397,7 @@ async fn test_find_enforcement_by_id() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -471,7 +471,7 @@ async fn test_get_enforcement_by_id() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -552,7 +552,7 @@ async fn test_list_enforcements() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -624,7 +624,7 @@ async fn test_update_enforcement_status() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -690,7 +690,7 @@ async fn test_update_enforcement_status_transitions() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -769,7 +769,7 @@ async fn test_update_enforcement_payload() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -832,7 +832,7 @@ async fn test_update_enforcement_both_fields() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -896,7 +896,7 @@ async fn test_update_enforcement_no_changes() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -981,7 +981,7 @@ async fn test_delete_enforcement() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -1056,7 +1056,7 @@ async fn test_find_enforcements_by_rule() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Rule 1".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -1078,7 +1078,7 @@ async fn test_find_enforcements_by_rule() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Rule 2".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -1149,7 +1149,7 @@ async fn test_find_enforcements_by_status() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -1239,7 +1239,7 @@ async fn test_find_enforcements_by_event() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -1324,7 +1324,7 @@ async fn test_delete_rule_sets_enforcement_rule_to_null() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -1390,7 +1390,7 @@ async fn test_enforcement_resolved_at_lifecycle() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
|
||||
@@ -449,7 +449,7 @@ async fn test_delete_event_enforcement_retains_event_id() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
|
||||
@@ -454,7 +454,7 @@ impl ActionFixture {
|
||||
pack_ref: self.pack_ref,
|
||||
r#ref: self.r#ref,
|
||||
label: self.label,
|
||||
description: self.description,
|
||||
description: Some(self.description),
|
||||
entrypoint: self.entrypoint,
|
||||
runtime: self.runtime,
|
||||
runtime_version_constraint: None,
|
||||
@@ -1088,7 +1088,7 @@ impl SensorFixture {
|
||||
pack: self.pack_id,
|
||||
pack_ref: self.pack_ref,
|
||||
label: self.label,
|
||||
description: self.description,
|
||||
description: Some(self.description),
|
||||
entrypoint: self.entrypoint,
|
||||
runtime: self.runtime_id,
|
||||
runtime_ref: self.runtime_ref,
|
||||
|
||||
@@ -219,6 +219,7 @@ async fn test_update_identity() {
|
||||
display_name: Some("Updated Name".to_string()),
|
||||
password_hash: None,
|
||||
attributes: Some(json!({"key": "updated", "new_key": "new_value"})),
|
||||
frozen: None,
|
||||
};
|
||||
|
||||
let updated = IdentityRepository::update(&pool, identity.id, update_input)
|
||||
@@ -252,6 +253,7 @@ async fn test_update_identity_partial() {
|
||||
display_name: Some("Only Display Name Changed".to_string()),
|
||||
password_hash: None,
|
||||
attributes: None,
|
||||
frozen: None,
|
||||
};
|
||||
|
||||
let updated = IdentityRepository::update(&pool, identity.id, update_input)
|
||||
@@ -274,6 +276,7 @@ async fn test_update_identity_not_found() {
|
||||
display_name: Some("Updated Name".to_string()),
|
||||
password_hash: None,
|
||||
attributes: None,
|
||||
frozen: None,
|
||||
};
|
||||
|
||||
let result = IdentityRepository::update(&pool, 999999, update_input).await;
|
||||
@@ -380,6 +383,7 @@ async fn test_identity_updated_changes_on_update() {
|
||||
display_name: Some("Updated".to_string()),
|
||||
password_hash: None,
|
||||
attributes: None,
|
||||
frozen: None,
|
||||
};
|
||||
|
||||
let updated = IdentityRepository::update(&pool, identity.id, update_input)
|
||||
|
||||
@@ -8,7 +8,7 @@ mod helpers;
|
||||
use attune_common::{
|
||||
repositories::{
|
||||
rule::{CreateRuleInput, RuleRepository, UpdateRuleInput},
|
||||
Create, Delete, FindById, FindByRef, List, Update,
|
||||
Create, Delete, FindById, FindByRef, List, Patch, Update,
|
||||
},
|
||||
Error,
|
||||
};
|
||||
@@ -48,7 +48,7 @@ async fn test_create_rule() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test Rule".to_string(),
|
||||
description: "A test rule".to_string(),
|
||||
description: Some("A test rule".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -66,7 +66,7 @@ async fn test_create_rule() {
|
||||
assert_eq!(rule.pack, pack.id);
|
||||
assert_eq!(rule.pack_ref, pack.r#ref);
|
||||
assert_eq!(rule.label, "Test Rule");
|
||||
assert_eq!(rule.description, "A test rule");
|
||||
assert_eq!(rule.description, Some("A test rule".to_string()));
|
||||
assert_eq!(rule.action, Some(action.id));
|
||||
assert_eq!(rule.action_ref, action.r#ref);
|
||||
assert_eq!(rule.trigger, Some(trigger.id));
|
||||
@@ -105,7 +105,7 @@ async fn test_create_rule_disabled() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Disabled Rule".to_string(),
|
||||
description: "A disabled rule".to_string(),
|
||||
description: Some("A disabled rule".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -155,7 +155,7 @@ async fn test_create_rule_with_complex_conditions() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Complex Rule".to_string(),
|
||||
description: "Rule with complex conditions".to_string(),
|
||||
description: Some("Rule with complex conditions".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -200,7 +200,7 @@ async fn test_create_rule_duplicate_ref() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "First Rule".to_string(),
|
||||
description: "First".to_string(),
|
||||
description: Some("First".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -220,7 +220,7 @@ async fn test_create_rule_duplicate_ref() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Second Rule".to_string(),
|
||||
description: "Second".to_string(),
|
||||
description: Some("Second".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -274,7 +274,7 @@ async fn test_create_rule_invalid_ref_format_uppercase() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Upper Rule".to_string(),
|
||||
description: "Invalid uppercase ref".to_string(),
|
||||
description: Some("Invalid uppercase ref".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -316,7 +316,7 @@ async fn test_create_rule_invalid_ref_format_no_dot() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "No Dot Rule".to_string(),
|
||||
description: "Invalid ref without dot".to_string(),
|
||||
description: Some("Invalid ref without dot".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -362,7 +362,7 @@ async fn test_find_rule_by_id() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Find Rule".to_string(),
|
||||
description: "Rule to find".to_string(),
|
||||
description: Some("Rule to find".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -422,7 +422,7 @@ async fn test_find_rule_by_ref() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Find By Ref Rule".to_string(),
|
||||
description: "Find by ref".to_string(),
|
||||
description: Some("Find by ref".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -484,7 +484,7 @@ async fn test_list_rules() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: format!("List Rule {}", i),
|
||||
description: format!("Rule {}", i),
|
||||
description: Some(format!("Rule {}", i)),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -538,7 +538,7 @@ async fn test_list_rules_ordered_by_ref() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: name.to_string(),
|
||||
description: name.to_string(),
|
||||
description: Some(name.to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -594,7 +594,7 @@ async fn test_update_rule_label() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Original Label".to_string(),
|
||||
description: "Original".to_string(),
|
||||
description: Some("Original".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -618,7 +618,7 @@ async fn test_update_rule_label() {
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(updated.label, "Updated Label");
|
||||
assert_eq!(updated.description, "Original"); // unchanged
|
||||
assert_eq!(updated.description, Some("Original".to_string())); // unchanged
|
||||
assert!(updated.updated > created.updated);
|
||||
}
|
||||
|
||||
@@ -647,7 +647,7 @@ async fn test_update_rule_description() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test".to_string(),
|
||||
description: "Old description".to_string(),
|
||||
description: Some("Old description".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -662,7 +662,7 @@ async fn test_update_rule_description() {
|
||||
let created = RuleRepository::create(&pool, input).await.unwrap();
|
||||
|
||||
let update = UpdateRuleInput {
|
||||
description: Some("New description".to_string()),
|
||||
description: Some(Patch::Set("New description".to_string())),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -670,7 +670,7 @@ async fn test_update_rule_description() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(updated.description, "New description");
|
||||
assert_eq!(updated.description, Some("New description".to_string()));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -698,7 +698,7 @@ async fn test_update_rule_conditions() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -750,7 +750,7 @@ async fn test_update_rule_enabled() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -803,7 +803,7 @@ async fn test_update_rule_multiple_fields() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Old".to_string(),
|
||||
description: "Old".to_string(),
|
||||
description: Some("Old".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -819,7 +819,7 @@ async fn test_update_rule_multiple_fields() {
|
||||
|
||||
let update = UpdateRuleInput {
|
||||
label: Some("New Label".to_string()),
|
||||
description: Some("New Description".to_string()),
|
||||
description: Some(Patch::Set("New Description".to_string())),
|
||||
conditions: Some(json!({"updated": true})),
|
||||
action_params: None,
|
||||
trigger_params: None,
|
||||
@@ -831,7 +831,7 @@ async fn test_update_rule_multiple_fields() {
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(updated.label, "New Label");
|
||||
assert_eq!(updated.description, "New Description");
|
||||
assert_eq!(updated.description, Some("New Description".to_string()));
|
||||
assert_eq!(updated.conditions, json!({"updated": true}));
|
||||
assert!(!updated.enabled);
|
||||
}
|
||||
@@ -861,7 +861,7 @@ async fn test_update_rule_no_changes() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Test".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -914,7 +914,7 @@ async fn test_delete_rule() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "To Delete".to_string(),
|
||||
description: "Will be deleted".to_string(),
|
||||
description: Some("Will be deleted".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -995,7 +995,7 @@ async fn test_find_rules_by_pack() {
|
||||
pack: pack1.id,
|
||||
pack_ref: pack1.r#ref.clone(),
|
||||
label: format!("Rule {}", i),
|
||||
description: format!("Rule {}", i),
|
||||
description: Some(format!("Rule {}", i)),
|
||||
action: action1.id,
|
||||
action_ref: action1.r#ref.clone(),
|
||||
trigger: trigger1.id,
|
||||
@@ -1016,7 +1016,7 @@ async fn test_find_rules_by_pack() {
|
||||
pack: pack2.id,
|
||||
pack_ref: pack2.r#ref.clone(),
|
||||
label: "Pack2 Rule".to_string(),
|
||||
description: "Pack2".to_string(),
|
||||
description: Some("Pack2".to_string()),
|
||||
action: action2.id,
|
||||
action_ref: action2.r#ref.clone(),
|
||||
trigger: trigger2.id,
|
||||
@@ -1073,7 +1073,7 @@ async fn test_find_rules_by_action() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: format!("Action1 Rule {}", i),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action1.id,
|
||||
action_ref: action1.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -1094,7 +1094,7 @@ async fn test_find_rules_by_action() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Action2 Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action2.id,
|
||||
action_ref: action2.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -1155,7 +1155,7 @@ async fn test_find_rules_by_trigger() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: format!("Trigger1 Rule {}", i),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger1.id,
|
||||
@@ -1176,7 +1176,7 @@ async fn test_find_rules_by_trigger() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Trigger2 Rule".to_string(),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger2.id,
|
||||
@@ -1234,7 +1234,7 @@ async fn test_find_enabled_rules() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: format!("Enabled {}", i),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -1256,7 +1256,7 @@ async fn test_find_enabled_rules() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: format!("Disabled {}", i),
|
||||
description: "Test".to_string(),
|
||||
description: Some("Test".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -1312,7 +1312,7 @@ async fn test_cascade_delete_pack_deletes_rules() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Cascade Rule".to_string(),
|
||||
description: "Will be cascade deleted".to_string(),
|
||||
description: Some("Will be cascade deleted".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
@@ -1368,7 +1368,7 @@ async fn test_rule_timestamps() {
|
||||
pack: pack.id,
|
||||
pack_ref: pack.r#ref.clone(),
|
||||
label: "Timestamp Rule".to_string(),
|
||||
description: "Test timestamps".to_string(),
|
||||
description: Some("Test timestamps".to_string()),
|
||||
action: action.id,
|
||||
action_ref: action.r#ref.clone(),
|
||||
trigger: trigger.id,
|
||||
|
||||
@@ -179,7 +179,7 @@ async fn test_create_sensor_duplicate_ref_fails() {
|
||||
pack: Some(pack.id),
|
||||
pack_ref: Some(pack.r#ref.clone()),
|
||||
label: "Duplicate Sensor".to_string(),
|
||||
description: "Test sensor".to_string(),
|
||||
description: Some("Test sensor".to_string()),
|
||||
entrypoint: "sensors/dup.py".to_string(),
|
||||
runtime: runtime.id,
|
||||
runtime_ref: runtime.r#ref.clone(),
|
||||
@@ -235,7 +235,7 @@ async fn test_create_sensor_invalid_ref_format_fails() {
|
||||
pack: Some(pack.id),
|
||||
pack_ref: Some(pack.r#ref.clone()),
|
||||
label: "Invalid Sensor".to_string(),
|
||||
description: "Test sensor".to_string(),
|
||||
description: Some("Test sensor".to_string()),
|
||||
entrypoint: "sensors/invalid.py".to_string(),
|
||||
runtime: runtime.id,
|
||||
runtime_ref: runtime.r#ref.clone(),
|
||||
@@ -276,7 +276,7 @@ async fn test_create_sensor_invalid_pack_fails() {
|
||||
pack: Some(99999), // Non-existent pack
|
||||
pack_ref: Some("invalid".to_string()),
|
||||
label: "Invalid Pack Sensor".to_string(),
|
||||
description: "Test sensor".to_string(),
|
||||
description: Some("Test sensor".to_string()),
|
||||
entrypoint: "sensors/invalid.py".to_string(),
|
||||
runtime: runtime.id,
|
||||
runtime_ref: runtime.r#ref.clone(),
|
||||
@@ -308,7 +308,7 @@ async fn test_create_sensor_invalid_trigger_fails() {
|
||||
pack: None,
|
||||
pack_ref: None,
|
||||
label: "Invalid Trigger Sensor".to_string(),
|
||||
description: "Test sensor".to_string(),
|
||||
description: Some("Test sensor".to_string()),
|
||||
entrypoint: "sensors/invalid.py".to_string(),
|
||||
runtime: runtime.id,
|
||||
runtime_ref: runtime.r#ref.clone(),
|
||||
@@ -340,7 +340,7 @@ async fn test_create_sensor_invalid_runtime_fails() {
|
||||
pack: None,
|
||||
pack_ref: None,
|
||||
label: "Invalid Runtime Sensor".to_string(),
|
||||
description: "Test sensor".to_string(),
|
||||
description: Some("Test sensor".to_string()),
|
||||
entrypoint: "sensors/invalid.py".to_string(),
|
||||
runtime: 99999, // Non-existent runtime
|
||||
runtime_ref: "invalid.runtime".to_string(),
|
||||
@@ -728,7 +728,7 @@ async fn test_update_description() {
|
||||
.unwrap();
|
||||
|
||||
let input = UpdateSensorInput {
|
||||
description: Some("New description for the sensor".to_string()),
|
||||
description: Some(Patch::Set("New description for the sensor".to_string())),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -736,7 +736,10 @@ async fn test_update_description() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(updated.description, "New description for the sensor");
|
||||
assert_eq!(
|
||||
updated.description,
|
||||
Some("New description for the sensor".to_string())
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -934,7 +937,7 @@ async fn test_update_multiple_fields() {
|
||||
|
||||
let input = UpdateSensorInput {
|
||||
label: Some("Multi Update".to_string()),
|
||||
description: Some("Updated multiple fields".to_string()),
|
||||
description: Some(Patch::Set("Updated multiple fields".to_string())),
|
||||
entrypoint: Some("sensors/multi.py".to_string()),
|
||||
enabled: Some(false),
|
||||
param_schema: Some(Patch::Set(json!({"type": "object"}))),
|
||||
@@ -946,7 +949,10 @@ async fn test_update_multiple_fields() {
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(updated.label, "Multi Update");
|
||||
assert_eq!(updated.description, "Updated multiple fields");
|
||||
assert_eq!(
|
||||
updated.description,
|
||||
Some("Updated multiple fields".to_string())
|
||||
);
|
||||
assert_eq!(updated.entrypoint, "sensors/multi.py");
|
||||
assert!(!updated.enabled);
|
||||
assert_eq!(updated.param_schema, Some(json!({"type": "object"})));
|
||||
|
||||
Reference in New Issue
Block a user