Layer7 API Management

  • 1.  How I compare a single valued variable with a multivalued context variable

    Posted Apr 05, 2017 08:24 AM

    Hello everyone,

     

    I am relatively new to the API world so I hope my question won't be trivial.

     

    I want to compare a single valued variable with a multivalued context variable (table) that is being created after I perform a JDBC query. (column from a database). The idea is to compare the credentials inserted from the user with the list of authorized credentials that are being stored in the database that is called through MySQL queries.

     

    The 'Compare Assertion' gives the chance to use all values of the variable that we take as basis, but not the opposite (at least to my understanding).

     

    I can do it manually by writing multiple assertions specifying single valued variables from the JDBC query, but this has big limitations as you to pre-specify the number of variables.

     

    Any help appreciated!

     

    Thanks in advance.



  • 2.  Re: How I compare a single valued variable with a multivalued context variable
    Best Answer

    Broadcom Employee
    Posted Apr 05, 2017 07:20 PM

    Hello karpa08 ,

    There are few ways, set a new string context variable as ${multivalued variable} -- ${multivalued variable} will be extended to v1, v2, v3 ... at run time, then you can use compare assertion and see if it "contains" the singlevalued variable.

    For more details, you may refer to Multivalued Context Variables - CA API Gateway - 9.2 - CA Technologies Documentation 

     

    Another way is the use Run Assertions for Each Item Assertion to loop all the values of a multivalued variable. For more details and samples, please refer to Run Assertions for Each Item Assertion - CA API Gateway - 9.2 - CA Technologies Documentation 

     

    Regards,

    Mark



  • 3.  Re: How I compare a single valued variable with a multivalued context variable

    Posted Apr 11, 2017 10:19 AM

    Hello Mark,

     

    Thanks a lot for the reply, it indicated where I should look at.

    Best regards,

     

    Panagiotis