-
Notifications
You must be signed in to change notification settings - Fork 7
Added creation of test users which was previously included in the image #972
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
+60
−3
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
78ef92a
Added creation of test users which was previously included in the image
ToreMerkely 88b711f
Do not pull down remote server image if running from local image
ToreMerkely d62b5e9
Update after comment from reviewer
ToreMerkely 5831a8b
ci: exclude test-user fixture from Snyk Code scan
ToreMerkely 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
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,47 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| # Creates the standalone test users used by the Kosli CLI integration tests. | ||
| # | ||
| # This script is owned by the CLI repo (the test users are CLI test data). It is | ||
| # mounted into the server container at /app/test via docker-compose and executed | ||
| # there, so it relies on the server's `lib` and `model` packages being importable | ||
| # via PYTHONPATH=/app/src. | ||
|
|
||
| import hashlib | ||
|
|
||
| from lib import Sku | ||
| from model import Organizations, Users | ||
|
|
||
| # key == person-id, value == api-key | ||
| CLI_TEST_USERS = { | ||
| "docs-cmd-test-user": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6ImNkNzg4OTg5In0.e8i_lA_QrEhFncb05Xw6E_tkCHU9QfcY4OLTVUCHffY", | ||
| "acme-org": "v3OWZiYWu9G2IMQStYg9BcPQUQ88lJNNnTJTNq8jfvmkR1C5wVpHSs7F00JcB5i6OGeUzrKt3CwRq7ndcN4TTfMeo8ASVJ5NdHpZT7DkfRfiFvm8s7GbsIHh2PtiQJYs2UoN13T8DblV5C4oKb6-yWH73h67OhotPlKfVKazR-c", | ||
| "iu-org": "qM9u2_grv6pJLbACwsMMMT5LIQy82tQj2k1zjZnlXti1smnFaGwCKW4jzk0La7ae9RrSYvEwCXSsXknD6YZqd-onLaaIUUKtEn6-B6yh53vWIe9EC5u85FCbKZjFbaicp_d0Me0Zcqq_KcCgrAZRX9xggl_pBb2oaCsNdllqNjk", | ||
| "system-tests-user": "95-IeGBfyKdTteLdKidiAnXk6uMmV6jTkGM9v3DEtrQ", | ||
| } | ||
|
|
||
|
|
||
| def create_standalone_test_users(test_users): | ||
| users = Users() | ||
| orgs = Organizations() | ||
|
|
||
| for user_name, api_key in test_users.items(): | ||
| uid = hashlib.sha256(user_name.encode("utf-8")).hexdigest()[0:24] | ||
| login_data = { | ||
| "userId": uid, | ||
| "name": user_name, | ||
| "email": "[email protected]", | ||
| "picture": "", | ||
| } | ||
| users.create("descope", login_data) | ||
| user = users.find_by_auth_user_id(login_data["userId"]) | ||
| user.completed_signup = True | ||
| user.add_api_key(api_key=api_key, setting_user=user, expires_at=0, description="") | ||
| # fixed auth_token so tests have a stable session token to authenticate with | ||
| user.auth_token = "213c18081df7f738ec479107b86f97ec678b1d54" | ||
|
|
||
| orgs.create_shared(f"{user_name}-shared", sku=Sku().existing_orgs, owner=user) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| create_standalone_test_users(CLI_TEST_USERS) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.