Skip to content

Conversation

ilija-lazoroski
Copy link
Contributor

@ilija-lazoroski ilija-lazoroski commented Jul 13, 2021

What does this PR do?

Fixes #1241 get mode endpoint.

Add any further explanations here.

PR Checklist

  • Have you added an explanation of what your changes do and why you'd like to include them?
  • Is the TravisCI build passing?
  • Was the CHANGELOG.md updated to reflect the changes?
  • Was the documentation framework updated to reflect the changes?

Testing Checklist

  • Added relevant unit tests?
  • Have you successfully tested your changes locally? Elaborate:

    Tested by {Running the Monkey locally with relevant config/running Island/...}

  • If applicable, add screenshots or log transcripts of the feature working

Explain Changes

Are the commit messages enough? If not, elaborate.

@codecov
Copy link

codecov bot commented Jul 13, 2021

Codecov Report

Merging #1320 (2d1a3ef) into develop (00426c6) will decrease coverage by 19.58%.
The diff coverage is 27.43%.

❗ Current head 2d1a3ef differs from pull request most recent head 56b5e8b. Consider uploading reports for the commit 56b5e8b to get more accurate results
Impacted file tree graph

@@             Coverage Diff              @@
##           develop    #1320       +/-   ##
============================================
- Coverage    59.89%   40.30%   -19.59%     
============================================
  Files          147      471      +324     
  Lines         4787    13823     +9036     
============================================
+ Hits          2867     5571     +2704     
- Misses        1920     8252     +6332     
Impacted Files Coverage Δ
monkey/common/cloud/instance.py 66.66% <ø> (ø)
monkey/common/common_consts/__init__.py 100.00% <ø> (ø)
monkey/common/network/segmentation_utils.py 100.00% <ø> (ø)
monkey/common/utils/exploit_enum.py 100.00% <ø> (ø)
monkey/common/utils/mongo_utils.py 0.00% <0.00%> (ø)
monkey/common/utils/wmi_utils.py 0.00% <0.00%> (ø)
monkey/infection_monkey/dropper.py 0.00% <0.00%> (ø)
monkey/infection_monkey/exploit/drupal.py 0.00% <0.00%> (ø)
monkey/infection_monkey/exploit/elasticgroovy.py 0.00% <0.00%> (ø)
monkey/infection_monkey/exploit/hadoop.py 0.00% <0.00%> (ø)
... and 564 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c84e70...56b5e8b. Read the comment docs.



@pytest.mark.parametrize("mode", ["ransomware", "advanced"])
def test_island_mode_get(flask_client, uses_database, mode):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this also tests the post. Maybe we don't need the test_island_mode_post__set_model and test_island_mode_post__set_invalid_model tests anymore?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests should be individual i.e. testing one kind of behaviour. You should set IslandMode.objects and then test just the post request.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to make unit tests too granular. The result of the post is that get returns the mode posted. There's no need to tie the unit test to the mechanism of how the mode is saved. If we decide to switch the database we won't need to re-do unit tests, for example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree. If the test fails, you're now left debugging more than if the tests were granular.
I don't think our motive behind writing unit tests should be to not have to redo them ever again. It should be to make debugging and catching issues easier.

@ilija-lazoroski ilija-lazoroski changed the title Island: Add inital get method to island mode Ransomware quickstart - Add get method for island mode Jul 14, 2021


@pytest.mark.parametrize("mode", ["ransomware", "advanced"])
def test_island_mode_get(flask_client, uses_database, mode):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests should be individual i.e. testing one kind of behaviour. You should set IslandMode.objects and then test just the post request.

Copy link
Contributor

@VakarisZ VakarisZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the UT's that interact with models directly and we'll be GTG

@ilija-lazoroski ilija-lazoroski force-pushed the 1241/ransomware-quickstart-get-mode branch from 2d1a3ef to 56b5e8b Compare July 14, 2021 09:25
@VakarisZ VakarisZ merged commit bf517bf into develop Jul 14, 2021
@VakarisZ VakarisZ deleted the 1241/ransomware-quickstart-get-mode branch July 14, 2021 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ransomware quickstart
3 participants