-
Notifications
You must be signed in to change notification settings - Fork 5
Add missing TestWorkflowSecurity and TestEdgeCases classes to iteration status emails workflow tests #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add missing TestWorkflowSecurity and TestEdgeCases classes to iteration status emails workflow tests #177
Changes from all commits
ccb286c
7297a02
e385b83
de7e8e3
d0e4a25
81c07ed
16640ba
b0d5e54
cfc5882
b8dcb56
9a9acd3
625eb2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -54,6 +54,14 @@ def workflow_content(workflow_raw): | |||||||||||
| return yaml.safe_load(workflow_raw) | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| @pytest.fixture(scope='module') | ||||||||||||
| def jobs(workflow_content): | ||||||||||||
| """ | ||||||||||||
| Module-scoped fixture for jobs configuration. | ||||||||||||
| """ | ||||||||||||
| return workflow_content.get('jobs', {}) | ||||||||||||
|
Comment on lines
+57
to
+62
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| @pytest.fixture(scope='module') | ||||||||||||
| def dashboard_path(): | ||||||||||||
| """ | ||||||||||||
|
|
@@ -292,7 +300,7 @@ def test_setup_documentation_has_secrets_section(self): | |||||||||||
| assert 'SMTP_USERNAME' in content or 'email' in content.lower() | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| class TestSecurityBestPractices: | ||||||||||||
| class TestWorkflowSecurity: | ||||||||||||
| """Tests for security considerations.""" | ||||||||||||
|
|
||||||||||||
| def test_no_hardcoded_credentials(self, workflow_raw): | ||||||||||||
|
|
@@ -331,5 +339,97 @@ def test_uses_secure_connection(self, workflow_content): | |||||||||||
| assert with_config['secure'] is True or with_config['secure'] == 'true' | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| class TestEdgeCases: | ||||||||||||
| """Test edge cases and error handling in the workflow.""" | ||||||||||||
|
|
||||||||||||
| def test_no_tabs_in_yaml(self, workflow_raw): | ||||||||||||
| """Test that workflow uses spaces, not tabs.""" | ||||||||||||
| assert '\t' not in workflow_raw, "YAML should use spaces, not tabs" | ||||||||||||
|
|
||||||||||||
| def test_consistent_indentation(self, workflow_raw): | ||||||||||||
| """Test that indentation is consistent (a multiple of 2 spaces).""" | ||||||||||||
| lines = workflow_raw.split('\n') | ||||||||||||
| for i, line in enumerate(lines, 1): | ||||||||||||
| if line.strip() and not line.strip().startswith('#'): | ||||||||||||
| leading_spaces = len(line) - len(line.lstrip(' ')) | ||||||||||||
| if leading_spaces > 0: | ||||||||||||
| assert leading_spaces % 2 == 0, \ | ||||||||||||
| f"Line {i} has indentation that is not a multiple of 2 spaces" | ||||||||||||
|
|
||||||||||||
| def test_no_duplicate_job_names(self, workflow_content): | ||||||||||||
| """Test that there are no duplicate job names.""" | ||||||||||||
| job_names = list(workflow_content['jobs'].keys()) | ||||||||||||
|
||||||||||||
| job_names = list(workflow_content['jobs'].keys()) | |
| jobs = workflow_content.get('jobs') | |
| assert jobs is not None, "Workflow must define jobs" | |
| job_names = list(jobs.keys()) |
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_no_duplicate_step_ids assumes every step is a dict; if the YAML contains an empty step (None) or a non-mapping value, if 'id' in s will raise. Consider asserting isinstance(step, dict) (or filtering to dicts) before inspecting keys so the test fails cleanly on malformed steps.
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has_triggers = 'on' in workflow_content or True in workflow_content.keys() can produce false positives because True == 1 in Python (so a numeric key 1 would satisfy it). Use the same approach as the other trigger tests (workflow_content.get('on') or workflow_content.get(True)) or check boolean keys with identity (e.g., any(k is True for k in keys)).
| has_triggers = 'on' in workflow_content or True in workflow_content.keys() | |
| has_triggers = ( | |
| 'on' in workflow_content | |
| or any(k is True for k in workflow_content.keys()) | |
| ) |
Uh oh!
There was an error while loading. Please reload this page.