-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from Yelp/fuzz_only_input_tags
Allow developers to whitelist tags for fuzzing
- Loading branch information
Showing
11 changed files
with
135 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,21 @@ | ||
from typing import Callable | ||
from typing import Iterable | ||
|
||
from fuzz_lightyear.datastore import get_included_tags | ||
|
||
|
||
def tags(func: Callable[[], Iterable[str]]) -> Callable: | ||
"""Allows developers to specify Swagger tags which | ||
should be fuzzed. | ||
Example: | ||
Only fuzz operations with the 'user_account' tag. | ||
>>> @fuzz_lightyear.include.tags | ||
... def a(): | ||
... return ['user_account'] | ||
""" | ||
tags_to_include = func() | ||
if tags_to_include: | ||
get_included_tags().update(tags_to_include) | ||
|
||
return func |
This file contains 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 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 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 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 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,29 @@ | ||
import pytest | ||
|
||
import fuzz_lightyear | ||
from fuzz_lightyear.datastore import get_included_tags | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'included_tags, expected_result', | ||
[ | ||
( | ||
['tag1', 'tag2'], | ||
{'tag1', 'tag2'}, | ||
), | ||
( | ||
set(['tag1', 'tag2']), | ||
{'tag1', 'tag2'}, | ||
), | ||
( | ||
[], | ||
set(), | ||
), | ||
], | ||
) | ||
def test_include_tags(included_tags, expected_result): | ||
def foobar(): | ||
return included_tags | ||
|
||
fuzz_lightyear.include.tags(foobar) | ||
assert get_included_tags() == expected_result |