-
Notifications
You must be signed in to change notification settings - Fork 792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1996 remove current server #2015
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2015 +/- ##
===========================================
+ Coverage 56.63% 56.66% +0.02%
===========================================
Files 463 464 +1
Lines 12894 12885 -9
===========================================
- Hits 7303 7301 -2
+ Misses 5591 5584 -7
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not create a new subpackage (cc
) yet. When we merge the communication mechanisms, this subpackage won't provide any value.
@@ -184,7 +180,11 @@ def _setup(self): | |||
def _build_master(self): | |||
local_network_interfaces = InfectionMonkey._get_local_network_interfaces() | |||
|
|||
control_channel = ControlChannel(self._default_server, GUID) | |||
# TODO control_channel and control_client have same responsibilities, merge them |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
It will be easier to merge them once we finish stripping out everything unnecessary from ControlClient
and decoupling it from WormConfiguration
monkey/tests/unit_tests/infection_monkey/post_breach/actions/test_users_custom_pba.py
Outdated
Show resolved
Hide resolved
This is done to refactor ControlClient from a global
* Workaround global class attribute
* It removes whole island_server section from internal config
5be015b
to
5631eb8
Compare
* leftover from renaming credential_classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made some more comments, but the PR is too large and has at least two distinct goals. Split it up into 2 or more PRs, each of which accomplishes a single goal.
class ControlClient: | ||
# TODO When we have mechanism that support telemetry messenger | ||
# with control clients, then this needs to be removed | ||
# Ref: infection_monkey.telemetry.base_telem.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a GitHub permalink instead of the file path. The file name or contents could change, which would make this comment less useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you get that permalink?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -11,5 +13,6 @@ def _spy_send_telemetry(telem_category, data): | |||
|
|||
_spy_send_telemetry.telem_category = None | |||
_spy_send_telemetry.data = None | |||
monkeypatch.setattr(ControlClient, "send_telemetry", _spy_send_telemetry) | |||
ControlClient.control_client_object = MagicMock() | |||
monkeypatch.setattr(ControlClient.control_client_object, "send_telemetry", _spy_send_telemetry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
monkeypatch.setattr(ControlClient.control_client_object, "send_telemetry", _spy_send_telemetry) | |
ControlClient.control_client_object.send_telemetry = MagicMock(side_effect=_spy_send_telemetry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference? Why do you prefer it that way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://stackoverflow.com/a/47101194 Not really some difference between.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That answer doesn't have anything to do with why I prefer using the MagicMock here.
If you monkey patch the object, then the object still has the capability to do all sorts of things. Monkey patching send_telemetry()
but leaving all of the other methods intact could result in unexpected behavior down the road if the code decides to try and use any of those methods.
Using a mock object, we're sure it only does the things we've programmed it to do within the confines of what we want to test.
I disagree. It makes it easier to find the files that have the same responsibility until then and it costs nothing to move them back. I'm not sure why you say that it won't provide any value once we merge the |
Split up the PR. First part is in #2016 |
@VakarisZ It may contain more than one file, or it may not. As we simplify the API on the Island, the agent should also become simpler. Adding layers in a hierarchy can add difficulty, so unless there's a distinct benefit to do it, it should be avoided. In this specific case, it introduces a circular dependency between the parent and child packages. |
What does this PR do?
Fixes part of #1996 .
Add any further explanations here.
PR Checklist
Testing Checklist
Explain Changes
Are the commit messages enough? If not, elaborate.