diff --git a/tests/tests_graphql.py b/tests/tests_graphql.py index a057fb737..cc7d4a6fa 100644 --- a/tests/tests_graphql.py +++ b/tests/tests_graphql.py @@ -25,8 +25,6 @@ class TestsGraphQL(TestCase): _subject = None - _ioc_count = 0 - _user_count = 0 @classmethod def setUpClass(cls) -> None: @@ -41,13 +39,6 @@ def tearDownClass(cls) -> None: def tearDown(self): self._subject.clear_database() - # Note: this method is necessary because the state of the database is not reset between each test - # and we want to work with distinct object in each test - @classmethod - def _generate_new_dummy_ioc_value(cls): - cls._ioc_count += 1 - return f'IOC value #{cls._ioc_count}' - @staticmethod def _get_first_case(body): for case in body['data']['cases']['edges']: @@ -89,7 +80,7 @@ def test_graphql_cases_should_have_a_global_identifier(self): def test_graphql_create_ioc_should_not_fail(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() + ioc_value = 'IOC value' payload = { 'query': f'''mutation {{ iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ @@ -103,10 +94,9 @@ def test_graphql_create_ioc_should_not_fail(self): def test_graphql_delete_ioc_should_not_fail(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() payload = { 'query': f'''mutation {{ - iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ + iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "IOC value") {{ ioc {{ iocId }} }} }}''' @@ -126,10 +116,9 @@ def test_graphql_delete_ioc_should_not_fail(self): def test_graphql_create_ioc_should_allow_optional_description_to_be_set(self): case_identifier = self._create_case() description = 'Some description' - ioc_value = self._generate_new_dummy_ioc_value() payload = { 'query': f'''mutation {{ - iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}", + iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "IOC value", description: "{description}") {{ ioc {{ iocDescription }} }} @@ -141,10 +130,9 @@ def test_graphql_create_ioc_should_allow_optional_description_to_be_set(self): def test_graphql_create_ioc_should_allow_optional_tags_to_be_set(self): case_identifier = self._create_case() tags = 'tag1,tag2' - ioc_value = self._generate_new_dummy_ioc_value() payload = { 'query': f'''mutation {{ - iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}", + iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "IOC value", tags: "{tags}") {{ ioc {{ iocTags }} }} @@ -155,7 +143,7 @@ def test_graphql_create_ioc_should_allow_optional_tags_to_be_set(self): def test_graphql_update_ioc_should_update_tlp(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() + ioc_value = 'IOC value' payload = { 'query': f'''mutation {{ iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ @@ -177,7 +165,7 @@ def test_graphql_update_ioc_should_update_tlp(self): def test_graphql_update_ioc_should_not_update_typeId(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() + ioc_value = 'IOC value' payload = { 'query': f'''mutation {{ iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ @@ -200,7 +188,7 @@ def test_graphql_update_ioc_should_not_update_typeId(self): def test_graphql_update_ioc_should_fail_when_missing_iocId(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() + ioc_value = 'IOC value' payload = { 'query': f'''mutation {{ iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ @@ -221,7 +209,7 @@ def test_graphql_update_ioc_should_fail_when_missing_iocId(self): def test_graphql_update_ioc_should_not_update_tlpId(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() + ioc_value = 'IOC value' payload = { 'query': f'''mutation {{ iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ @@ -244,10 +232,9 @@ def test_graphql_update_ioc_should_not_update_tlpId(self): def test_graphql_update_ioc_should_not_update_value(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() payload = { 'query': f'''mutation {{ - iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ + iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "IOC value") {{ ioc {{ iocId iocValue }} }} }}''' @@ -267,7 +254,7 @@ def test_graphql_update_ioc_should_not_update_value(self): def test_graphql_update_ioc_should_update_optional_parameter_description(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() + ioc_value = 'IOC value' payload = { 'query': f'''mutation {{ iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ @@ -291,7 +278,7 @@ def test_graphql_update_ioc_should_update_optional_parameter_description(self): def test_graphql_update_ioc_should_update_optional_parameter_tags(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() + ioc_value = 'IOC value' payload = { 'query': f'''mutation {{ iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ @@ -327,10 +314,9 @@ def test_graphql_case_should_return_a_case_by_its_identifier(self): def test_graphql_iocs_should_return_all_iocs_of_a_case(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() payload = { 'query': f'''mutation {{ - iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ + iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "IOC value") {{ ioc {{ iocId }} }} }}''' @@ -362,10 +348,9 @@ def test_graphql_case_should_return_error_log_uuid_when_permission_denied(self): def test_graphql_case_should_return_error_ioc_when_permission_denied(self): user = self._subject.create_dummy_user() case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() payload = { 'query': f'''mutation {{ - iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ + iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "IOC value") {{ ioc {{ iocId iocValue }} }} }}''' @@ -612,7 +597,7 @@ def test_graphql_update_case_with_optional_parameter_reviewStatusId(self): def test_graphql_query_ioc_should_not_fail(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() + ioc_value = 'IOC value' payload = { 'query': f'''mutation {{ iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ @@ -642,7 +627,7 @@ def test_graphql_cases_should_not_fail(self): def test_graphql_update_ioc_should_update_misp(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() + ioc_value = 'IOC value' payload = { 'query': f'''mutation {{ iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ @@ -665,7 +650,7 @@ def test_graphql_update_ioc_should_update_misp(self): def test_graphql_update_ioc_should_update_userId(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() + ioc_value = 'IOC value' payload = { 'query': f'''mutation {{ iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ @@ -687,7 +672,7 @@ def test_graphql_update_ioc_should_update_userId(self): def test_graphql_update_ioc_should_update_iocEnrichment(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() + ioc_value = 'IOC value' payload = { 'query': f'''mutation {{ iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{ @@ -710,7 +695,7 @@ def test_graphql_update_ioc_should_update_iocEnrichment(self): def test_graphql_update_ioc_should_update_modificationHistory(self): case_identifier = self._create_case() - ioc_value = self._generate_new_dummy_ioc_value() + ioc_value = 'IOC value' payload = { 'query': f'''mutation {{ iocCreate(caseId: {case_identifier}, typeId: 1, tlpId: 1, value: "{ioc_value}") {{