-
Notifications
You must be signed in to change notification settings - Fork 14
GEN-1909 new SDK function - set_secret #16
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 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
405d4a6
allow setting a secret via sdk
hrgreene d62cc7d
messing w/ CI
hrgreene b2f732d
bool -> None
hrgreene 062a628
linting, add a test
hrgreene b3a87cc
adjust error handling
hrgreene 462762f
more error adjustment
hrgreene 9ee7e13
final error adjust
hrgreene fc81e77
fix import linting
hrgreene 16d05c2
more syntax fixing
hrgreene 1002a71
adjust comment
hrgreene bc555c0
use pytest.raises
hrgreene 2fe1ea5
fix pymssql import for local testing
hrgreene d914771
Merge remote-tracking branch 'origin' into GEN-1909-update-secret-via…
hrgreene 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [flake8] | ||
| max-line-length = 150 | ||
| ignore = E401,F401,W503 |
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 |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| # local configs | ||
| env.*.local | ||
| .vscode | ||
|
|
||
| # Byte-compiled / optimized / DLL files | ||
| __pycache__/ | ||
|
|
||
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
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,19 @@ | ||
| from urllib.error import HTTPError | ||
|
|
||
| from . import utils, context, errors | ||
|
|
||
|
|
||
| def set_secret(secret_key: str, secret_val: str) -> None: | ||
| process_details = context.get_process() | ||
| lair_id = process_details["lair_id"] | ||
| client = utils.WayScriptClient() | ||
| response = client.set_lair_secret(lair_id, secret_key, secret_val) | ||
|
|
||
| # Handle unhelpful error cases | ||
| try: | ||
| response.raise_for_status() | ||
| except HTTPError as e: | ||
| if response.code == 403: | ||
| raise errors.UnauthorizedUserError from None | ||
| else: | ||
| raise e | ||
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
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
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,23 @@ | ||
| import responses | ||
|
|
||
| from wayscript import secret_manager | ||
| from wayscript.errors import UnauthorizedUserError | ||
|
|
||
|
|
||
| @responses.activate | ||
| def test_set_secret(patch_client_get_url): | ||
| """Test set secret""" | ||
| responses.add(responses.POST, patch_client_get_url, json={}, status=200) | ||
|
|
||
| secret_manager.set_secret("test_key", "test_val") | ||
|
|
||
|
|
||
| @responses.activate | ||
| def test_set_secret_unauthorized_user(patch_client_get_url): | ||
| """Test that set secret raises the appropriate error for unauthorized users""" | ||
| responses.add(responses.POST, patch_client_get_url, json={}, status=403) | ||
|
|
||
| try: | ||
| secret_manager.set_secret("test_key", "test_val") | ||
| except UnauthorizedUserError: | ||
| assert True | ||
aroxby-wayscript marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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
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.