-
Notifications
You must be signed in to change notification settings - Fork 385
test: generate live fake Entra data #10348
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?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Pull Request Overview
This PR introduces a comprehensive script for generating realistic test data in Microsoft Entra ID directories to support testing of the new Entra sync implementation. The script can create users, groups with hierarchical structures, and group memberships at scale while providing robust cleanup capabilities.
Key changes:
- Added a Python script that creates fake Entra ID test data with configurable parameters
- Implemented proper rate limiting, error handling, and retry mechanisms for Microsoft Graph API interactions
- Added comprehensive cleanup functionality using unique tags to identify test data
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| scripts/generators/requirements.txt | Dependencies for the Entra test data generation script |
| scripts/generators/entra.py | Main Python script for creating and managing Entra ID test data |
| scripts/generators/README.md | Basic documentation for the generators directory |
| .tool-versions | Updated Python version from 3.11.9 to 3.11.13 |
Co-authored-by: Copilot <[email protected]> Signed-off-by: Jamil <[email protected]>
Co-authored-by: Copilot <[email protected]> Signed-off-by: Jamil <[email protected]>
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.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
scripts/generators/entra.py
Outdated
| "mailNickname": unique_username, | ||
| "userPrincipalName": f"{unique_username}@{self.entra_config.tenant_domain}", | ||
| "passwordProfile": { | ||
| "password": "TempPassword123!", |
Copilot
AI
Sep 14, 2025
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.
Hard-coded password poses a security risk. Consider generating random passwords or making the password configurable through environment variables.
| for resp in error_json["responses"][:3]: # Log first 3 errors | ||
| if resp.get("status") != 201: | ||
| logger.error(f"Individual error: {resp}") | ||
| except: |
Copilot
AI
Sep 14, 2025
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.
Bare except clause catches all exceptions including system exceptions. Use a specific exception type like Exception or ValueError for better error handling.
| except: | |
| except Exception: |
| # The message typically says "try after X seconds" | ||
| self.rate_limit_until = time.time() + 150 # Default 150 seconds |
Copilot
AI
Sep 14, 2025
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 magic number 150 should be defined as a named constant at the class level for better maintainability and configurability.
As part of testing the new Entra sync implementation, it would be helpful to have a larger directory to build against. Since the Entra free plan allows unlimited users, groups, and members, this PR introduces a script that create create (and teardown) an arbitrary amount of test data in a given Entra directory.
Related: #6294
Related: #10324