-
Notifications
You must be signed in to change notification settings - Fork 47
fix: Add validation format check for SDK key #351
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
jsonbailey
merged 9 commits into
main
from
devin/1759153910-sdk-1460-add-sdk-key-validation
Sep 30, 2025
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
133b3db
fix: Add validation format check for SDK key
devin-ai-integration[bot] 6b0920b
fix: Correct non-string SDK key validation test
devin-ai-integration[bot] 5891f34
fix: Update SDK key validation to follow dotnet pattern
devin-ai-integration[bot] b7eec96
fix: Add proper docstring formatting with :param and :return: style
devin-ai-integration[bot] e514784
Update logic to align with other validation in repository
jsonbailey b4f8ab6
fix failing tests
jsonbailey 6959036
Merge branch 'main' into devin/1759153910-sdk-1460-add-sdk-key-valida…
jsonbailey a19e5bf
fix lint issues
jsonbailey 6ec6770
validation removes chance of None
jsonbailey 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
Some comments aren't visible on the classic Files Changed page.
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,56 @@ | ||
| import logging | ||
| from unittest.mock import Mock | ||
| from ldclient.impl.util import validate_sdk_key | ||
|
|
||
|
|
||
| def test_validate_sdk_key_valid(): | ||
| """Test validation of valid SDK keys""" | ||
| logger = Mock(spec=logging.Logger) | ||
|
|
||
| valid_keys = [ | ||
| "sdk-12345678-1234-1234-1234-123456789012", | ||
| "valid-sdk-key-123", | ||
| "VALID_SDK_KEY_456" | ||
| ] | ||
|
|
||
| for key in valid_keys: | ||
| assert validate_sdk_key(key, logger) is True | ||
| logger.warning.assert_not_called() | ||
| logger.reset_mock() | ||
|
|
||
|
|
||
| def test_validate_sdk_key_invalid(): | ||
| """Test validation of invalid SDK keys""" | ||
| logger = Mock(spec=logging.Logger) | ||
|
|
||
| invalid_keys = [ | ||
| "sdk-key-with-\x00-null", | ||
| "sdk-key-with-\n-newline", | ||
| "sdk-key-with-\t-tab" | ||
| ] | ||
|
|
||
| for key in invalid_keys: | ||
| assert validate_sdk_key(key, logger) is False | ||
| logger.warning.assert_called_with("SDK key contains invalid characters") | ||
| logger.reset_mock() | ||
|
|
||
|
|
||
| def test_validate_sdk_key_non_string(): | ||
| """Test validation of non-string SDK keys""" | ||
| logger = Mock(spec=logging.Logger) | ||
|
|
||
| non_string_values = [123, None, object(), [], {}] | ||
|
|
||
| for value in non_string_values: | ||
| result = validate_sdk_key(value, logger) | ||
| assert result is False | ||
| logger.warning.assert_called_with("SDK key must be a string") | ||
| logger.reset_mock() | ||
|
|
||
|
cursor[bot] marked this conversation as resolved.
|
||
|
|
||
| def test_validate_sdk_key_empty(): | ||
| """Test validation of empty SDK keys""" | ||
| logger = Mock(spec=logging.Logger) | ||
|
|
||
| assert validate_sdk_key("", logger) is True | ||
| logger.warning.assert_not_called() | ||
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
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.