-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
90 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
Methods that execute specific queries against the SQLite database for the SERIVCES table. | ||
This supports the policy_sentry query functionality | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from policy_sentry.shared.iam_data import iam_definition | ||
|
||
|
||
def get_services_data() -> list[dict[str, str]]: | ||
return [ | ||
{ | ||
"prefix": service_prefix, | ||
"service_name": data["service_name"], | ||
} | ||
for service_prefix, data in iam_definition.items() | ||
if isinstance(data, dict) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import unittest | ||
|
||
from policy_sentry.querying.services import get_services_data | ||
|
||
|
||
class QueryServicesTestCase(unittest.TestCase): | ||
def test_get_services_data(self): | ||
# when | ||
results = get_services_data() | ||
|
||
# then | ||
self.assertGreater(len(results), 400) # in 07/24 it was 405 | ||
|
||
# both should be a non-empty string | ||
self.assertTrue(results[0]["prefix"]) | ||
self.assertTrue(results[0]["service_name"]) |