-
Notifications
You must be signed in to change notification settings - Fork 500
test: Macae v4 unittestcases kd #790
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
221a8cf
Refactor import paths to use relative imports for consistency across …
Kingshuk-Microsoft 19fd09d
Refactor mocking of v4.models in test settings and plan_to_mplan_conv…
Kingshuk-Microsoft ff91881
Add unit tests for OrchestrationManager with comprehensive mocking
Kingshuk-Microsoft 99b966b
Update test workflow to include demo-v4 branch and ensure consistent …
Kingshuk-Microsoft 6577ea0
Remove macae-v4-unittestcases-kd branch from test workflow triggers
Kingshuk-Microsoft bdd15df
Add quiet mode to pytest command in test workflow for cleaner output
Kingshuk-Microsoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,3 @@ | ||
| """ | ||
| Empty __init__.py file for auth tests package. | ||
| """ |
This file contains hidden or 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,63 @@ | ||
| """ | ||
| Test configuration for auth module tests. | ||
| """ | ||
|
|
||
| import pytest | ||
| import sys | ||
| import os | ||
| from unittest.mock import MagicMock, patch | ||
| import base64 | ||
| import json | ||
|
|
||
| # Add the backend directory to the Python path for imports | ||
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', 'backend')) | ||
|
|
||
| @pytest.fixture | ||
| def mock_sample_headers(): | ||
| """Mock headers with EasyAuth authentication data.""" | ||
| return { | ||
| "x-ms-client-principal-id": "12345678-1234-1234-1234-123456789012", | ||
| "x-ms-client-principal-name": "testuser@example.com", | ||
| "x-ms-client-principal-idp": "aad", | ||
| "x-ms-token-aad-id-token": "sample.jwt.token", | ||
| "x-ms-client-principal": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsInRpZCI6IjEyMzQ1Njc4LTEyMzQtMTIzNC0xMjM0LTEyMzQ1Njc4OTAxMiJ9" | ||
| } | ||
|
|
||
| @pytest.fixture | ||
| def mock_empty_headers(): | ||
| """Mock headers without authentication data.""" | ||
| return { | ||
| "content-type": "application/json", | ||
| "user-agent": "test-agent" | ||
| } | ||
|
|
||
| @pytest.fixture | ||
| def mock_valid_base64_principal(): | ||
| """Mock valid base64 encoded principal with tenant ID.""" | ||
| mock_data = { | ||
| "typ": "JWT", | ||
| "alg": "RS256", | ||
| "tid": "87654321-4321-4321-4321-210987654321", | ||
| "oid": "12345678-1234-1234-1234-123456789012", | ||
| "preferred_username": "testuser@example.com", | ||
| "name": "Test User" | ||
| } | ||
|
|
||
| json_str = json.dumps(mock_data) | ||
| return base64.b64encode(json_str.encode('utf-8')).decode('utf-8') | ||
|
|
||
| @pytest.fixture | ||
| def mock_invalid_base64_principal(): | ||
| """Mock invalid base64 encoded principal.""" | ||
| return "invalid_base64_string!" | ||
|
|
||
| @pytest.fixture | ||
| def sample_user_mock(): | ||
| """Mock sample_user data for testing.""" | ||
| return { | ||
| "x-ms-client-principal-id": "00000000-0000-0000-0000-000000000000", | ||
| "x-ms-client-principal-name": "testusername@contoso.com", | ||
| "x-ms-client-principal-idp": "aad", | ||
| "x-ms-token-aad-id-token": "your_aad_id_token", | ||
| "x-ms-client-principal": "your_base_64_encoded_token" | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The
if ...; then ... else "No tests found"logic will treat any pytest failure (including real test failures/import errors) as “no tests found” and not fail the job, because both pytest commands are inside theifcondition and the first command silences all output. Consider explicitly handling pytest exit code 5 (no tests collected) and failing on any other non-zero exit; also avoid depending onbc(may be missing) by doing the threshold comparison in Python.