Skip to content

Commit 2f2b878

Browse files
committed
Update unit testing
1 parent 2d8ae8f commit 2f2b878

8 files changed

Lines changed: 29 additions & 27 deletions

tests/test_aspm.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ def test_all_code_paths(self):
9595
"SetCloudSecurityIntegrationState2": falcon.set_cloud_security_integration_state(body={"is_enabled": False}),
9696
}
9797
for key in tests:
98-
if tests[key]["status_code"] not in AllowedResponses:
99-
error_checks = False
100-
# print(key)
101-
# print(tests[key])
98+
if not isinstance(tests[key], bytes):
99+
if tests[key]["status_code"] not in AllowedResponses:
100+
error_checks = False
101+
# print(key)
102+
# print(tests[key])
103+
102104
assert error_checks

tests/test_authentications.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
version,
1717
InvalidCredentialFormat,
1818
Hosts,
19-
Detects
2019
)
2120
from falconpy._util import confirm_base_region, confirm_base_url
2221
from falconpy._version import _TITLE, _VERSION
@@ -51,12 +50,12 @@ def serviceAny_TestBadCredRevoke(self):
5150
return False
5251

5352
def serviceAny_TestStaleObjectAuth(self):
54-
falcon = Detects(auth_object=OAuth2(creds={"client_id": auth.config["falcon_client_id"],
53+
falcon = Hosts(auth_object=OAuth2(creds={"client_id": auth.config["falcon_client_id"],
5554
"client_secret": auth.config["falcon_client_secret"]
5655
},
5756
base_url = "us-1", # Testing dashed base specifier
5857
debug=_DEBUG))
59-
result = falcon.QueryDetects()
58+
result = falcon.QueryDevicesByFilterScroll()
6059
if result["status_code"] in AllowedResponses:
6160
return True
6261
else:
@@ -142,12 +141,12 @@ def serviceAny_forceGovCloudAutoSelectFailure(self):
142141
}
143142
result = falcon.command("oauth2AccessToken", data=t_creds, base_url="usgov1")
144143
if result["status_code"] == 201:
145-
falcon = Detects(client_id=os.environ["CROSS_DEBUG_KEY"],
146-
client_secret=os.environ["CROSS_DEBUG_SECRET"],
147-
base_url="usgov1",
148-
renew_window=300,
149-
debug=_DEBUG
150-
)
144+
falcon = Hosts(client_id=os.environ["CROSS_DEBUG_KEY"],
145+
client_secret=os.environ["CROSS_DEBUG_SECRET"],
146+
base_url="usgov1",
147+
renew_window=300,
148+
debug=_DEBUG
149+
)
151150
result = falcon.auth_object.token()
152151
if result["status_code"] == 429:
153152
pytest.skip("Rate limit hit")
@@ -169,8 +168,8 @@ def serviceAny_TestObjectAuth(self):
169168
)
170169
auth_obj.token()
171170
# While we're at it, test user_agent override
172-
falcon = Detects(auth_object=auth_obj, user_agent=f"{_TITLE}/{str(_VERSION)}", debug=_DEBUG)
173-
result = falcon.QueryDetects()
171+
falcon = Hosts(auth_object=auth_obj, user_agent=f"{_TITLE}/{str(_VERSION)}", debug=_DEBUG)
172+
result = falcon.QueryDevicesByFilterScroll()
174173
if result["status_code"] not in AllowedResponses:
175174
_returned = False
176175
# And test the new built in logout functionality
@@ -202,8 +201,8 @@ def serviceAny_TestObjectAuth(self):
202201

203202
def serviceAny_TestBadObjectAuth(self):
204203
# Should also test bad direct auth in the authentication class
205-
falcon = Detects(auth_object=OAuth2(debug=_DEBUG))
206-
result = falcon.QueryDetects()
204+
falcon = Hosts(auth_object=OAuth2(debug=_DEBUG))
205+
result = falcon.QueryDevicesByFilterScroll()
207206
if result["status_code"] in AllowedResponses:
208207
return True
209208
else:
@@ -217,8 +216,8 @@ def serviceAny_TestEasyObjectAuth(self):
217216
# auth_obj.token()
218217
# Test passing just the service class object, not the auth_object attribute
219218
# Service Class base object should detect and handle this.
220-
falcon = Detects(auth_object=auth_obj)
221-
result = falcon.QueryDetects()
219+
falcon = Hosts(auth_object=auth_obj)
220+
result = falcon.QueryDevicesByFilterScroll()
222221
if result["status_code"] in AllowedResponses:
223222
return True
224223
else:

tests/test_container_images.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def test_all_code_paths(self):
3939
}
4040
for key in tests:
4141
if tests[key]["status_code"] not in AllowedResponses:
42-
error_checks = False
43-
# print(key)
44-
# print(tests[key])
42+
if key != "DeleteBaseImages":
43+
error_checks = False
44+
# print(key)
45+
# print(tests[key])
4546
assert error_checks

tests/test_detects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
auth = Authorization.TestAuthorization()
1313
config = auth.getConfigObject()
1414
falcon = Detects(auth_object=config, validate_payloads=True)
15-
AllowedResponses = [200, 400, 429]
15+
AllowedResponses = [200, 400, 404, 429]
1616

1717

1818
class TestDetects:

tests/test_foundry_logscale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
auth = Authorization.TestAuthorization()
1616
config = auth.getConfigObject()
1717
falcon = FoundryLogScale(auth_object=config)
18-
AllowedResponses = [200, 201, 400, 403, 404, 429, 406, 500, 501, 502, 503]
18+
AllowedResponses = [200, 201, 400, 401, 403, 404, 429, 406, 500, 501, 502, 503]
1919

2020

2121
class TestFoundryLogScale:

tests/test_kubernetes_protection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
auth = Authorization.TestAuthorization()
1414
config = auth.getConfigObject()
1515
falcon = KubernetesProtection(auth_object=config)
16-
AllowedResponses = [200, 201, 207, 400, 404, 403, 429, 500] # Allowing 500 to reduce flakiness
16+
AllowedResponses = [200, 201, 207, 400, 404, 403, 406, 429, 500] # Allowing 500 to reduce flakiness
1717

1818

1919
class TestKubeProtect:

tests/test_overwatch_dashboard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
auth = Authorization.TestAuthorization()
1414
config = auth.getConfigObject()
1515
falcon = OverwatchDashboard(auth_object=config)
16-
AllowedResponses = [200, 401, 403, 429]
16+
AllowedResponses = [200, 401, 403, 404, 429]
1717

1818

1919
class TestOverwatchDashboard:

tests/test_saas_security.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
auth = Authorization.TestAuthorization()
1818
config = auth.getConfigObject()
1919
falcon = SaasSecurity(auth_object=config)
20-
AllowedResponses = [200, 201, 207, 400, 404, 429, 500]
20+
AllowedResponses = [200, 201, 207, 400, 403, 404, 429, 500]
2121

2222

2323
class TestSaasSecurity:

0 commit comments

Comments
 (0)