Skip to content

Commit

Permalink
Remove the assert called once statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Wout Feys committed Nov 15, 2024
1 parent 833208d commit 6e004dc
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 49 deletions.
15 changes: 0 additions & 15 deletions aikido_zen/sinks/tests/motor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ async def test_find_one(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.find"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand All @@ -127,7 +126,6 @@ async def test_count_documents(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.count_documents"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand All @@ -144,7 +142,6 @@ async def test_find_one_and_delete(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.find_one_and_delete"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand All @@ -163,7 +160,6 @@ async def test_find_one_and_replace(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.find_one_and_replace"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand All @@ -180,7 +176,6 @@ async def test_find_one_and_update(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.find_one_and_update"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand Down Expand Up @@ -208,7 +203,6 @@ async def test_find_not_empty(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.find"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand All @@ -225,7 +219,6 @@ async def test_find_raw_batches(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.find_raw_batches"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand All @@ -242,7 +235,6 @@ async def test_distinct(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.distinct"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand All @@ -259,7 +251,6 @@ async def test_distinct_kwargs(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.distinct"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand Down Expand Up @@ -297,7 +288,6 @@ async def test_aggregate(db):
assert called_with["args"][0] == pipeline
assert called_with["op"] == "pymongo.collection.Collection.aggregate"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand All @@ -323,7 +313,6 @@ async def test_aggregate_key(db):
assert called_with["args"][0] == pipeline
assert called_with["op"] == "pymongo.collection.Collection.aggregate"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand Down Expand Up @@ -351,7 +340,6 @@ async def test_aggregate_raw_batches_key(db):
called_with["op"] == "pymongo.collection.Collection.aggregate_raw_batches"
)
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand Down Expand Up @@ -379,7 +367,6 @@ async def test_aggregate_raw_batches(db):
called_with["op"] == "pymongo.collection.Collection.aggregate_raw_batches"
)
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand All @@ -406,7 +393,6 @@ async def test_watch(db):
assert called_with["args"][0] == pipeline
assert called_with["op"] == "pymongo.collection.Collection.watch"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand All @@ -433,7 +419,6 @@ async def test_watch_key(db):
assert called_with["args"][0] == pipeline
assert called_with["op"] == "pymongo.collection.Collection.watch"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


@pytest.mark.asyncio
Expand Down
15 changes: 0 additions & 15 deletions aikido_zen/sinks/tests/pymongo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def test_find_one(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.find"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_count_documents(db):
Expand All @@ -134,7 +133,6 @@ def test_count_documents(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.count_documents"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_find_one_and_delete(db):
Expand All @@ -150,7 +148,6 @@ def test_find_one_and_delete(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.find_one_and_delete"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_find_one_and_replace(db):
Expand All @@ -166,7 +163,6 @@ def test_find_one_and_replace(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.find_one_and_replace"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_find_one_and_update(db):
Expand All @@ -182,7 +178,6 @@ def test_find_one_and_update(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.find_one_and_update"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_find_empty(db):
Expand All @@ -208,7 +203,6 @@ def test_find_not_empty(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.find"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_find_raw_batches(db):
Expand All @@ -224,7 +218,6 @@ def test_find_raw_batches(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.find_raw_batches"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_distinct(db):
Expand All @@ -240,7 +233,6 @@ def test_distinct(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.distinct"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_distinct_kwargs(db):
Expand All @@ -256,7 +248,6 @@ def test_distinct_kwargs(db):
assert called_with["args"][0] == _filter
assert called_with["op"] == "pymongo.collection.Collection.distinct"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_distinct_empty(db):
Expand Down Expand Up @@ -291,7 +282,6 @@ def test_aggregate(db):
assert called_with["args"][0] == pipeline
assert called_with["op"] == "pymongo.collection.Collection.aggregate"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_aggregate_key(db):
Expand All @@ -315,7 +305,6 @@ def test_aggregate_key(db):
assert called_with["args"][0] == pipeline
assert called_with["op"] == "pymongo.collection.Collection.aggregate"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_aggregate_raw_batches_key(db):
Expand All @@ -341,7 +330,6 @@ def test_aggregate_raw_batches_key(db):
called_with["op"] == "pymongo.collection.Collection.aggregate_raw_batches"
)
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_aggregate_raw_batches(db):
Expand All @@ -367,7 +355,6 @@ def test_aggregate_raw_batches(db):
called_with["op"] == "pymongo.collection.Collection.aggregate_raw_batches"
)
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_watch(db):
Expand All @@ -392,7 +379,6 @@ def test_watch(db):
assert called_with["args"][0] == pipeline
assert called_with["op"] == "pymongo.collection.Collection.watch"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_watch_key(db):
Expand All @@ -417,7 +403,6 @@ def test_watch_key(db):
assert called_with["args"][0] == pipeline
assert called_with["op"] == "pymongo.collection.Collection.watch"
assert called_with["kind"] == "nosql_injection"
mock_run_vulnerability_scan.assert_called_once()


def test_bulk_write(db):
Expand Down
19 changes: 0 additions & 19 deletions aikido_zen/sinks/tests/pymysql_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ def test_cursor_execute(database_conn):
called_with_args = mock_run_vulnerability_scan.call_args[1]["args"]
assert called_with_args[0] == query
assert isinstance(called_with_args[1], MySQL)
mock_run_vulnerability_scan.assert_called_once()

cursor.fetchall()
database_conn.close()
mock_run_vulnerability_scan.assert_called_once()


def test_cursor_execute_context(database_conn):
Expand All @@ -46,11 +44,9 @@ def test_cursor_execute_context(database_conn):
called_with_args = mock_run_vulnerability_scan.call_args[1]["args"]
assert called_with_args[0] == query
assert isinstance(called_with_args[1], MySQL)
mock_run_vulnerability_scan.assert_called_once()

cursor.fetchall()
database_conn.close()
mock_run_vulnerability_scan.assert_called_once()


def test_cursor_execute_parameterized(database_conn):
Expand All @@ -68,11 +64,9 @@ def test_cursor_execute_parameterized(database_conn):
== "INSERT INTO dogs (dog_name, isAdmin) VALUES (%s, %s)"
)
assert isinstance(called_with_args[1], MySQL)
mock_run_vulnerability_scan.assert_called_once()

database_conn.commit()
database_conn.close()
mock_run_vulnerability_scan.assert_called_once()


def test_cursor_executemany(database_conn):
Expand All @@ -93,13 +87,9 @@ def test_cursor_executemany(database_conn):
== "INSERT INTO dogs (dog_name, isAdmin) VALUES (%s, %s)"
)
assert isinstance(called_with_args[1], MySQL)
mock_run_vulnerability_scan.assert_called_once()
database_conn.commit()
mock_run_vulnerability_scan.assert_called_once()

cursor.close()
database_conn.close()
mock_run_vulnerability_scan.assert_called_once()


def test_cursor_execute_with_fstring(database_conn):
Expand All @@ -119,13 +109,9 @@ def test_cursor_execute_with_fstring(database_conn):
called_with_args[0] == "INSERT INTO dogs (dog_name, isAdmin) VALUES (%s, 1)"
)
assert isinstance(called_with_args[1], MySQL)
mock_run_vulnerability_scan.assert_called_once()
database_conn.commit()
mock_run_vulnerability_scan.assert_called_once()

cursor.close()
database_conn.close()
mock_run_vulnerability_scan.assert_called_once()


def test_cursor_execute_no_args(database_conn):
Expand All @@ -144,11 +130,6 @@ def test_cursor_execute_no_args(database_conn):
== 'INSERT INTO dogs (dog_name, isAdmin) VALUES ("Doggo", TRUE)'
)
assert isinstance(called_with_args[1], MySQL)

mock_run_vulnerability_scan.assert_called_once()
cursor.fetchall()
mock_run_vulnerability_scan.assert_called_once()

cursor.close()
database_conn.close()
mock_run_vulnerability_scan.assert_called_once()

0 comments on commit 6e004dc

Please sign in to comment.