Pattern check in request header field

ashwiniashwini Posts: 11

I need to test the pattern of value present against field x-et-user-id, it should follow the pattern - AS000xxx

How to acheive this ?

Below is sample request header for reference.

POST /asasa/zxzzx/zxzxz?asa_wewe_rtrt=024bddd0-5739-11ea-82b4-0242ac1300 HTTP/1.0
Host: abc.com:8443
Content-Type: application/json
Content-Length: 1014
x-et-user-id: AS000001
x-et-request-id: 60b1ea82-54c7-11ea-a2e3-2e728ce88125
x-et-com-indicator: ONLINE
x-et-api-signature: rtrtrtrtrtrttleS1jYTAwMDA5NS0wMDEiLCJjdHkiOiJhcHBsaWNhdGlvblwvanNvbiIsInR5cCI6IkpXVCIsImFsZyI6IlJTMjU2In0.yuyuyuu.Y-kybOKE2wIPGpiGdTEdNQs-ioiooo
x-et-transaction-time: 2023-03-31T23:53:31.00Z
Authorization: bearer sdsdsd.rrtrtr.Y-kybOKE2wIPGpiGdTEdNQs-iuiuiui
x-et-participant-user-id: 12345
x-et-indirect-connector-id: 3456
x-et-api-signature-type: PAYLOAD_DIGEST_SHA256
x-et-retry-indicator: false

Comments

  • benken_parasoftbenken_parasoft Posts: 908 ✭✭✭
    edited April 29

    Chain a Header Data Bank tool to extract the value of the "x-et-user-id" HTTP header to a Data Bank column.

    Next, add a Diff tool. On the Diff tool's Input tab, click "Data Source" radio button then pick the name of your Data Bank column in the "Data source column" box. If for some reason you don't see the "Data Source" radio button you might just need to add a trivial data source to your test suite. On the Tool Settings tab, type the value you want to check against. If you want to check a pattern, you can use a regular expression by selecting the "Regular Expression" box on the Options tab. In your case, I think you want to check a regular expression like "AS000..." (where '.' means any character)

  • ashwiniashwini Posts: 11

    Hi Benken_parasift,
    First of all thanks for your reply.
    But I tried the approach, you suggested but in Diff inside Datasource dropdown Header Data Bank is not coming so I tried to create a datasource by using excel sheet but now problem is that in excel sheet I have value AS000001 and in Diff if I am going with Regular Expression option then if it faiing because in actual request headr there are other field are also present eventhough I have tried with ignore difference also but it is not working and how can I put a regular express now in Regression Control because there value is coming from excel datasource where it is AS000001.

  • ashwiniashwini Posts: 11

    I am getting below error :

    Additional Details:
    Regular Expression:

    AS000001

    Input:

    POST /asasa/zxzzx/zxzxz?asa_wewe_rtrt=024bddd0-5739-11ea-82b4-0242ac1300 HTTP/1.0
    Host: abc.com:8443
    Content-Type: application/json
    Content-Length: 1014
    x-et-user-id: AS000001
    x-et-request-id: 60b1ea82-54c7-11ea-a2e3-2e728ce88125
    x-et-com-indicator: ONLINE
    x-et-api-signature: rtrtrtrtrtrttleS1jYTAwMDA5NS0wMDEiLCJjdHkiOiJhcHBsaWNhdGlvblwvanNvbiIsInR5cCI6IkpXVCIsImFsZyI6IlJTMjU2In0.yuyuyuu.Y-kybOKE2wIPGpiGdTEdNQs-ioiooo
    x-et-transaction-time: 2023-03-31T23:53:31.00Z
    Authorization: bearer sdsdsd.rrtrtr.Y-kybOKE2wIPGpiGdTEdNQs-iuiuiui
    x-et-participant-user-id: 12345
    x-et-indirect-connector-id: 3456
    x-et-api-signature-type: PAYLOAD_DIGEST_SHA256
    x-et-retry-indicator: false

    Source: Request Transport Header

  • benken_parasoftbenken_parasoft Posts: 908 ✭✭✭
    edited April 30

    You misundertand me. You must use a Header Data Bank to extract only "x-et-user-id". This is so you can use it as Input to your Diff tool. It looks like you are sending entire HTTP Request header as Input to your Diff tool which is wrong.

    The "Data Source" radio button on the Diff Tool's Input tab will show up if there is at least one data source present. For example, just create an empty Table data source (no row data). You aren't going to use the data source for anything. If you create a separate Diff tool as a stand alone test, you will be able to select the Header Data Bank column in the list on the Diff Tool's Input tab.

    Another way is to add an Extension Tool with a small script that simply reads the Header Data bank column value and returns it. You can chain a Diff tool to your Extension tool to then check the return value.

  • benken_parasoftbenken_parasoft Posts: 908 ✭✭✭
  • ashwiniashwini Posts: 11

    Dear Benken,

    Thanks a lot for your help !!
    It means a lot for me since I am a newbee to Parasoft SOATest.

Sign In or Register to comment.