Skip to content
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

Add ResponseProperties object and example refactor #213

Closed
wants to merge 3 commits into from

Conversation

azgabur
Copy link
Contributor

@azgabur azgabur commented Jun 2, 2023

Based on commit b042b30 in #212

Usage of dynamic response function is quite common in tests to expose and check Authorino internal variables. I propose creating new object for easier definition of this function without the need to construct complicated dictionaries in tests.

Contains fix of Value class to dataclass.

This PR also contains example refactor of https://github.com/Kuadrant/testsuite/tree/main/testsuite/tests/kuadrant/authorino/response tests.

@azgabur azgabur requested review from pehala and jsmolar June 2, 2023 00:09
@azgabur azgabur force-pushed the responses_refactor branch 2 times, most recently from 2acf655 to 75fe3a3 Compare June 5, 2023 16:50
@azgabur
Copy link
Contributor Author

azgabur commented Jul 3, 2023

After #214 will get merged I will refactor it to use ResponseProperties object.

@azgabur azgabur force-pushed the responses_refactor branch from 75fe3a3 to 06e120b Compare July 4, 2023 11:16
@@ -14,7 +15,7 @@ def header_name(request):
def responses(header_name):
"""Returns response to be added to the AuthConfig"""
return [
{"name": "header", "wrapperKey": header_name, "json": {"properties": [{"name": "anything", "value": "one"}]}}
ResponseProperties(name="header", wrapperKey=header_name, properties=[JsonProperty("anything", Value("one"))])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sold on the need to use it everywhere, I would rather see it used in the backend e.g. replacing it only in AuthConfig, but leave the test as is, @jsmolar WDYT?

testsuite/objects/__init__.py Outdated Show resolved Hide resolved
@averevki
Copy link
Contributor

Some elements from this PR were used in the reformat of the AuthConfig responses section #220.

@azgabur azgabur force-pushed the responses_refactor branch from 06e120b to 9d0ef8b Compare July 20, 2023 12:55
@azgabur
Copy link
Contributor Author

azgabur commented Jul 20, 2023

I rewrote most of the PR for better usage

def __init__(self, value=None, jsonPath=None) -> None:
super().__init__()
if not (value is None) ^ (jsonPath is None):
value: Optional[Union[str, list, dict]] = None
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the type be Optional[Any] ?

@azgabur azgabur force-pushed the responses_refactor branch from 5a39f66 to 8a33579 Compare July 21, 2023 07:45


@dataclass
class ExtendedProperty(JsonProperty):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExtendedProperty has only one additional "feature" then JsonProperty (overwrite)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@azgabur azgabur marked this pull request as draft August 3, 2023 11:30
@azgabur azgabur force-pushed the responses_refactor branch from 8a33579 to 971c4c0 Compare August 3, 2023 11:43
@azgabur
Copy link
Contributor Author

azgabur commented Aug 3, 2023

Closing in favor of #220

@azgabur azgabur closed this Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants