ISAITB / gitb

This is the fork maintained by the European Commission DG DIGIT based on the work of the GITB CEN Workshop Agreement. The original version of this software is the GITB PoC hosted at https://github.com/srdc/gitb.
https://joinup.ec.europa.eu/solution/interoperability-test-bed/about
Other
16 stars 4 forks source link

Multiple expected code status #49

Closed EliottPaillard closed 2 months ago

EliottPaillard commented 2 months ago

Hello! When using the inside a after my simulated actor sent an httpmessaging to my SUT, I would expect one among two possible code status. I didn't find any way to do that so far. Am I missing something or this is not possible at the moment? If it's not, could it be feasable to implement this? Thank you!

costas80 commented 2 months ago

Hi @EliottPaillard. I have the impression some parts of your question were omitted. What do you mean when you say

When using the inside a after...

If its a matter of checking one value (the HTTP status code), against two possible values that's quite easy to do. One option for example is to use the ExpressionValidator as illustrated below:

<assign to="code1">"200"</assign>
<assign to="code2">"201"</assign>
<assign to="code3">"202"</assign>
<!-- Success -->
<verify handler="ExpressionValidator" desc="Validate code 1">
    <input name="expression">$code1 = "200" or $code1 = "201"</input>
</verify>
<!-- Success -->
<verify handler="ExpressionValidator" desc="Validate code 2">
    <input name="expression">$code2 = "200" or $code2 = "201"</input>
</verify>
<!-- Failure -->
<verify handler="ExpressionValidator" desc="Validate code 3">
    <input name="expression">$code3 = "200" or $code3 = "201"</input>
</verify>

Is this what you're going for? Note that alternatively you could also use something like the RegExpValidator for something more complex.

EliottPaillard commented 2 months ago

Hey, Thank you for the quick answer! Once again, the xml tags I wrote in my message, are not seeable. But you understood well what I meant. I wanted to know if it's possible to do that with the config tag and name="status.code". But ok if not I see how I would do it with a validator. Though I don't know how to catch the status code from the received response

costas80 commented 2 months ago

Indeed, the HttpMessaging handler did not return the received HTTP status code as part of its outputs. We just published a fix for this on the development branch and our nightly build channel, that includes a http_status in the receive step's outputs.

The following TDL snippet illustrates how you could accept responses with any status code and check it in a separate step:

<receive id="dataReceived" desc="Receive response" from="A" to="B" txnId="t1"/>
<verify handler="ExpressionValidator" desc="Validate response status as 200 or 204">
   <input name="expression">$dataReceived{http_status} = "200" or $dataReceived{http_status} = "204"</input>
</verify>   

Can you confirm @EliottPaillard that this covers what you need?