Cleaned up imports and added no inspection comments to pass flake

This commit is contained in:
VakarisZ 2021-02-18 10:13:23 +02:00
parent 414dbf0665
commit a977ec4397
10 changed files with 13 additions and 18 deletions

View File

@ -1 +1,3 @@
from monkey_island.cc.test_common.fixtures import *
# Without these imports pytests can't use fixtures,
# because they are not found
from monkey_island.cc.test_common.fixtures import * # noqa: F401,F403

View File

@ -8,9 +8,6 @@ from __future__ import annotations
from mongoengine import Document, StringField
import common.common_consts.zero_trust_consts as zero_trust_consts
# Dummy import for mongoengine.
# noinspection PyUnresolvedReferences
from monkey_island.cc.models.zero_trust.monkey_finding_details import MonkeyFindingDetails
class Finding(Document):

View File

@ -46,7 +46,8 @@ class Authenticate(flask_restful.Resource):
secret = credentials["password"]
# If the user and password have been previously registered
if self._authenticate(username, secret):
access_token = flask_jwt_extended.create_access_token(identity=user_store.UserStore.username_table[username].id)
access_token = flask_jwt_extended.create_access_token(
identity=user_store.UserStore.username_table[username].id)
logger.debug(f"Created access token for user {username} that begins with {access_token[:4]}")
return make_response({"access_token": access_token, "error": ""}, 200)
else:

View File

@ -12,9 +12,9 @@ def check_new_user_communication(current_monkey, success, message):
MonkeyZTFindingService.create_or_add_to_existing(test=zero_trust_consts.TEST_COMMUNICATE_AS_NEW_USER,
status=status,
events=[
get_attempt_event(current_monkey),
get_result_event(current_monkey, message, success)
])
get_attempt_event(current_monkey),
get_result_event(current_monkey, message, success)
])
def get_attempt_event(current_monkey):

View File

@ -11,6 +11,7 @@ from monkey_island.cc.services.zero_trust.test_common.raw_scoutsute_data import
class ExampleRules(Enum):
NON_EXSISTENT_RULE = 'bogus_rule'
ALL_PORTS_OPEN = EC2Rules.SECURITY_GROUP_ALL_PORTS_TO_ALL
EXPECTED_RESULT = {'description': 'Security Group Opens All Ports to All',

View File

@ -1,6 +1,5 @@
import pytest
from common.common_consts import zero_trust_consts
from monkey_island.cc.models.zero_trust.finding import Finding
from monkey_island.cc.models.zero_trust.scoutsuite_finding import ScoutSuiteFinding
from monkey_island.cc.services.zero_trust.scoutsuite.scoutsuite_zt_finding_service import ScoutSuiteZTFindingService

View File

@ -73,5 +73,3 @@ def get_scoutsuite_details_dto() -> ScoutSuiteFindingDetails:
scoutsuite_details.scoutsuite_rules.append(RULES[0])
scoutsuite_details.scoutsuite_rules.append(RULES[1])
return scoutsuite_details

View File

@ -45,6 +45,3 @@ def test_get_all_findings():
assert findings[0] == expected_finding0
assert findings[1] == expected_finding1

View File

@ -1,2 +1,4 @@
from .fixture_enum import FixtureEnum
from .mongomock_fixtures import *
# Without these imports pytests can't use fixtures,
# because they are not found
from .fixture_enum import FixtureEnum # noqa: F401
from .mongomock_fixtures import * # noqa: F401,F403

View File

@ -1,4 +1,2 @@
class FixtureEnum:
USES_DATABASE = 'uses_database'