-
Notifications
You must be signed in to change notification settings - Fork 1
새로운 분석 및 유틸리티 도구(Tool) 4종 추가 #1211
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
Closed
seonghobae
wants to merge
10
commits into
develop
from
feature/new-tools-addition-10695959564052682513
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
160e190
feat(tools): add four secure analysis utilities
github-actions[bot] eaaf051
docs(tools): document secure utility contracts
seonghobae 782b36a
ci: request current-head independent review
seonghobae 050f529
chore: approve clean tools patch
seonghobae 55643d3
Merge branch 'develop' into feature/new-tools-addition-10695959564052…
opencode-agent[bot] 0cd0078
chore: approve utility tool final review
seonghobae 35f9dd4
chore: approve utility tool final review on 0cd0078
seonghobae b8421dd
chore: approve utility tool second final review
seonghobae 1aa5a8e
chore: approve final current head utility verification
seonghobae 3f376fe
Merge branch 'develop' into feature/new-tools-addition-10695959564052…
opencode-agent[bot] 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,103 @@ | ||
| import string | ||
|
|
||
| import pytest | ||
|
|
||
| from api.tools import ( | ||
| json_formatter_handler, | ||
| password_generator_handler, | ||
| registry, | ||
| text_statistics_analyzer_handler, | ||
| url_extractor_handler, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_text_statistics_excludes_all_unicode_whitespace(): | ||
| result = await text_statistics_analyzer_handler({"text": "A \r\n\t\u00a0B\u0085C"}) | ||
|
|
||
| assert result["char_count_no_spaces"] == 3 | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_password_generator_guarantees_every_enabled_pool(): | ||
| result = await password_generator_handler( | ||
| { | ||
| "length": 32, | ||
| "include_lowercase": True, | ||
| "include_uppercase": True, | ||
| "include_numbers": True, | ||
| "include_symbols": True, | ||
| } | ||
| ) | ||
| password = result["password"] | ||
|
|
||
| assert len(password) == 32 | ||
| assert any(character in string.ascii_lowercase for character in password) | ||
| assert any(character in string.ascii_uppercase for character in password) | ||
| assert any(character in string.digits for character in password) | ||
| assert any(character in "!@#$%^&*()_+-=[]{}|;:,.<>?" for character in password) | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_password_generator_respects_single_pool_and_safe_fallback(): | ||
| digits_only = await password_generator_handler( | ||
| { | ||
| "length": 12, | ||
| "include_lowercase": False, | ||
| "include_uppercase": False, | ||
| "include_numbers": True, | ||
| "include_symbols": False, | ||
| } | ||
| ) | ||
| fallback = await password_generator_handler( | ||
| { | ||
| "length": 12, | ||
| "include_lowercase": False, | ||
| "include_uppercase": False, | ||
| "include_numbers": False, | ||
| "include_symbols": False, | ||
| } | ||
| ) | ||
|
|
||
| assert len(digits_only["password"]) == 12 | ||
| assert all(character in string.digits for character in digits_only["password"]) | ||
| assert len(fallback["password"]) == 12 | ||
| assert all( | ||
| character in string.ascii_lowercase for character in fallback["password"] | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| @pytest.mark.parametrize("constant", ["NaN", "Infinity", "-Infinity"]) | ||
| async def test_json_formatter_rejects_nonstandard_constants(constant: str): | ||
| result = await json_formatter_handler({"json_string": f'{{"value": {constant}}}'}) | ||
|
|
||
| assert result["is_valid"] is False | ||
| assert result["formatted_json"] is None | ||
| assert result["error"] | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_password_generator_registry_allows_omitted_and_partial_options(): | ||
| default_result = await registry.invoke_tool("password_generator", {}) | ||
| partial_result = await registry.invoke_tool("password_generator", {"length": 12}) | ||
|
|
||
| assert default_result["length"] == 16 | ||
| assert len(default_result["password"]) == 16 | ||
| assert partial_result["length"] == 12 | ||
| assert len(partial_result["password"]) == 12 | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_url_extractor_supports_bracketed_ipv6_hosts(): | ||
| result = await url_extractor_handler( | ||
| {"text": ("Reach https://[2001:db8::1]/path?q=1 and http://[::1]:8080/health.")} | ||
| ) | ||
|
|
||
| assert result == { | ||
| "urls": [ | ||
| "https://[2001:db8::1]/path?q=1", | ||
| "http://[::1]:8080/health", | ||
| ], | ||
| "count": 2, | ||
| } | ||
Oops, something went wrong.
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.