-
Notifications
You must be signed in to change notification settings - Fork 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
Support arbitrary transformations in request and response record fields #53
Comments
Hi! I need to read once again your suggestion, but is it correct (not necessarily enough to reach the ultimate goal, but in the right direction) to split it as
One other way, is to allow for {
"response": "{{<nonce_response}}"
} This pattern would allow for complex scenarios, maybe even making things like Does this sound like a possible/better alternative? |
Or how would you envision bringing about params manipulation? |
Given such a solution, my example from before could be rewritten as:
I haven't given the format
|
Oh, no, no. What I meant is KATT could have an extra callback e.g. The blueprint markup would not require any change at all, since you'd write your That's why I wrote that |
Ok, I think I understand what you mean. I do think it's unfortunate if the callback invocations are implicit, as you mention yourself. And how would you control the invocation of a callback on a test case basis Also, given your reply, would it make sense to have an additional |
I don't follow this part. Care to explain?
Yes, or have a generic |
Regarding controlling the callback invocation: In my syntax-altering proposal, the invocation is controlled explicitly, i.e. before a transaction request or response; you have to specify a given eval block before each request/response. As I understand your proposal, you would have a To give you an example, say we define a I'm thinking perhaps a header akin to |
As a solution for the problem that made me submit this issue, I have made this temporary solution: As in
In my case, I match against the http method, passing through unless method is |
KATT wouldn't know. It would call the callback fun every time, and pass in decisional information e.g. the upcoming request information. Based on that, the callback might just return asap, or do actual processing. |
How about specifying something like this:
And then in the bluprint, you would have
That way, the callback would pop the |
@andreineculau Any comments to my |
@ptrf hej, i'm sorry, but i've been caught up in other things. I'll get back to you and the topic within the next week |
@ptrf I apologize for not keeping to my word, but 28 days later... I submit a PR to address this |
@andreineculau and I apologize for being slow to answer. The PR looks good from a cursory look, so I'll get back to you when I have had a thorough look. Thanks! |
introduce transform callback. fixes #53
@ptrf I have merged my PR. It won't get better the older it gets :) |
@andreineculau Thank you very much! The fix addresses our issues well. |
Would it be of interest to support arbitrary transformations in requests and response?
The gist of this proposal is to perform additional computation in
katt:make_katt_request/3
andkatt:make_katt_response/3
which evaluates transformations parametrized with the currentParams
set, substituting the result of these transformations into the appropriate request / response fields.Background
Given a set of transactions in a blueprint, the response of one transaction may contain a value that is stored via
{{>var}}
. In one or more of the following transactions, rather than substituting the contents ofvar
using{{<var}}
, it may be more interesting to substitute a transformation of the contents ofvar
- loosely, something like{{{ "type": "erlang", "eval": "mod:transform/1" }}}
, wheremod:transform/1
is parametrized overParams
, and thus accessingvar
usingproplists:get_value/2
.Example
A very made up example could be a client requesting a nonce for challenge, then answering it:
However, the evaluation shouldn't necessary be limited to the body, but also be allowed in url and headers (think JWT).
Remarks
The
runtime_value
validation computation supports some type of arbitrary evaluation, but is only available in the (expected) body of the response. The substitution of params values is performed bykatt_callbacks:recall/4
, before the contents of theerlang
orshell
field is evaluated. Although there is some overlap between the expressiveness of this feature andruntime_value
validation, this feature is different as it is run before the validation step.Also, in relation to the discussion in #29 and #33, the type/eval field construction would allow for language independence (in principle), although there are open questions as to how to pass the
Params
array to the shell function, assuming we are restricted to for instance POSIX sh(1).The text was updated successfully, but these errors were encountered: