#2405 refactor e2e test, fix uninstalled apps not being removed from the request manager
This commit is contained in:
@@ -1343,7 +1343,7 @@ class Node(SimComponent):
|
||||
else:
|
||||
pass
|
||||
|
||||
if application in self:
|
||||
if application_instance.name in self.software_manager.software:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@@ -1367,7 +1367,7 @@ class Node(SimComponent):
|
||||
application_instance = self.software_manager.software.get(
|
||||
str(application.__name__)
|
||||
) # This works because we can't have two applications with the same name on the same node
|
||||
self.uninstall_application(application_instance)
|
||||
# self.uninstall_application(application_instance)
|
||||
self.software_manager.uninstall(application_instance.name)
|
||||
|
||||
if application_instance.name not in self.software_manager.software:
|
||||
@@ -1406,4 +1406,6 @@ class Node(SimComponent):
|
||||
def __contains__(self, item: Any) -> bool:
|
||||
if isinstance(item, Service):
|
||||
return item.uuid in self.services
|
||||
elif isinstance(item, Application):
|
||||
return item.uuid in self.applications
|
||||
return None
|
||||
|
||||
@@ -51,13 +51,27 @@ def test_application_install_uninstall_on_uc2():
|
||||
_, _, _, _, _ = env.step(0)
|
||||
domcon = env.game.simulation.network.get_node_by_hostname("domain_controller")
|
||||
|
||||
_, _, _, _, _ = env.step(78)
|
||||
# Test we cannot execute the DoSBot app as it is not installed yet
|
||||
_, _, _, _, info = env.step(81)
|
||||
assert info["agent_actions"]["defender"].response.status == "unreachable"
|
||||
|
||||
# Test we can Install the DoSBot app
|
||||
_, _, _, _, info = env.step(78)
|
||||
assert "DoSBot" in domcon.software_manager.software
|
||||
|
||||
_, _, _, _, _ = env.step(79)
|
||||
# Test we can now execute the DoSBot app
|
||||
_, _, _, _, info = env.step(81)
|
||||
assert info["agent_actions"]["defender"].response.status == "success"
|
||||
|
||||
# Test we can Uninstall the DoSBot app
|
||||
_, _, _, _, info = env.step(79)
|
||||
assert "DoSBot" not in domcon.software_manager.software
|
||||
assert "WebBrowser" in domcon.software_manager.software
|
||||
|
||||
_, _, _, _, _ = env.step(80)
|
||||
# Test we cannot execute the DoSBot app as it was uninstalled
|
||||
_, _, _, _, info = env.step(81)
|
||||
assert info["agent_actions"]["defender"].response.status == "unreachable"
|
||||
|
||||
# Test we can uninstall one of the default apps (WebBrowser)
|
||||
assert "WebBrowser" in domcon.software_manager.software
|
||||
_, _, _, _, info = env.step(80)
|
||||
assert "WebBrowser" not in domcon.software_manager.software
|
||||
|
||||
Reference in New Issue
Block a user