Skip to content

Commit

Permalink
Include authorizer in requirement for control interface change
Browse files Browse the repository at this point in the history
Issue-Id: #22
  • Loading branch information
christoph-hamm committed Sep 30, 2024
1 parent 8693b8c commit 707e233
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
7 changes: 5 additions & 2 deletions agent/doc/swdesign/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -919,11 +919,14 @@ Needs:
- utest

##### Workload compares control interface metadata
`swdd~agent-compares-control-interface-metadata~1`
`swdd~agent-compares-control-interface-metadata~2`

Status: approved

When the WorkloadObject is triggered to compare its existing control interface metadata with the updated metadata, the Workload shall compare the existing file path with the new file path of the control interface.
When the WorkloadObject is triggered to compare its existing control interface metadata with the updated metadata, the Workload shall compare the control inferface's:

* file path
* authorizer

Tags:
- Workload
Expand Down
4 changes: 4 additions & 0 deletions agent/src/control_interface/control_interface_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl ControlInterfaceInfo {
self.authorizer
}

// [impl->swdd~agent-compares-control-interface-metadata~1]
pub fn has_same_configuration(&self, other: &ControlInterface) -> bool {
let self_location = self
.workload_instance_name
Expand Down Expand Up @@ -155,6 +156,7 @@ mod tests {
assert!(to_server_sender.same_channel(&new_context_info.get_to_server_sender()));
}

// [utest->swdd~agent-compares-control-interface-metadata~2]
#[test]
fn utest_has_same_configuration_true() {
let run_folder = Path::new(PIPES_LOCATION);
Expand Down Expand Up @@ -186,6 +188,7 @@ mod tests {
assert!(context_info.has_same_configuration(&other_context));
}

// [utest->swdd~agent-compares-control-interface-metadata~2]
#[test]
fn utest_has_same_configuration_with_different_location_returns_false() {
let run_folder = Path::new(PIPES_LOCATION);
Expand All @@ -209,6 +212,7 @@ mod tests {
assert!(!context_info.has_same_configuration(&other_context));
}

// [utest->swdd~agent-compares-control-interface-metadata~2]
#[test]
fn utest_has_same_configuration_with_different_authorizer_returns_false() {
let run_folder = Path::new(PIPES_LOCATION);
Expand Down
12 changes: 6 additions & 6 deletions agent/src/workload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Workload {
});
}

// [impl->swdd~agent-compares-control-interface-metadata~1]
// [impl->swdd~agent-compares-control-interface-metadata~2]
fn is_control_interface_changed(
&self,
control_interface_info: &Option<ControlInterfaceInfo>,
Expand Down Expand Up @@ -263,7 +263,7 @@ mod tests {
));
}

// [utest->swdd~agent-compares-control-interface-metadata~1]
// [utest->swdd~agent-compares-control-interface-metadata~2]
#[test]
fn utest_is_control_interface_changed_set_from_none_to_new_returns_true() {
let (workload_command_sender, _) = WorkloadCommandSender::new();
Expand All @@ -276,7 +276,7 @@ mod tests {
.is_control_interface_changed(&Some(MockControlInterfaceInfo::default())));
}

// [utest->swdd~agent-compares-control-interface-metadata~1]
// [utest->swdd~agent-compares-control-interface-metadata~2]
#[test]
fn utest_is_control_interface_changed_set_from_existing_to_none_returns_true() {
let (workload_command_sender, _) = WorkloadCommandSender::new();
Expand All @@ -290,7 +290,7 @@ mod tests {
assert!(test_workload_with_control_interface.is_control_interface_changed(&None));
}

// [utest->swdd~agent-compares-control-interface-metadata~1]
// [utest->swdd~agent-compares-control-interface-metadata~2]
#[test]
fn utest_is_control_interface_changed_set_from_none_to_none_returns_false() {
let (workload_command_sender, _) = WorkloadCommandSender::new();
Expand All @@ -304,7 +304,7 @@ mod tests {
assert!(!test_workload_with_control_interface.is_control_interface_changed(&None));
}

// [utest->swdd~agent-compares-control-interface-metadata~1]
// [utest->swdd~agent-compares-control-interface-metadata~2]
#[test]
fn utest_is_control_interface_changed_returns_true() {
let (workload_command_sender, _) = WorkloadCommandSender::new();
Expand All @@ -325,7 +325,7 @@ mod tests {
.is_control_interface_changed(&Some(control_interface_info_mock)));
}

// [utest->swdd~agent-compares-control-interface-metadata~1]
// [utest->swdd~agent-compares-control-interface-metadata~2]
#[test]
fn utest_is_control_interface_changed_returns_false() {
let (workload_command_sender, _) = WorkloadCommandSender::new();
Expand Down

0 comments on commit 707e233

Please sign in to comment.