Layer 7 API Management

Expand all | Collapse all

Externalize code in JavaScript assertion

Jump to Best Answer
  • 1.  Externalize code in JavaScript assertion

    Posted 08-28-2019 08:35 AM
    Hi there,

    Is there a way to get the JavaScript source code that normally goes inside the text box in the assertion fetched from an URL for example as it happens with XSLT? If not, could it be another way to externalize this code?

    Thanks in advance,

    Antonio


  • 2.  RE: Externalize code in JavaScript assertion

    Posted 08-28-2019 09:49 AM
    Hello Antonio,

    I'm not sure If I understood properly, but if you are fetching an html page, since HTML is based on XML, you could use the XML Assertion to navigate to the script tag and get the internal code of the same.

    Kind regards,
    Albert.

    ------------------------------
    Security Engineer
    ELCA
    ------------------------------



  • 3.  RE: Externalize code in JavaScript assertion

    Posted 08-29-2019 07:10 AM
    Hi Albert,

    No, that is not my use case. I would like to bring javascript code from external source like in the XSLT assertion that you can fetch your XSL stylesheet from somewhere else like from a S3/repo url.



    Thanks for your reply,

    Antonio


  • 4.  RE: Externalize code in JavaScript assertion
    Best Answer

    Posted 08-29-2019 08:04 AM
    Hello Antonio,

    Unfortunately I don't think that you have that possibility on the ootb assertions. I might be wrong and it would be a great discovery, so if anybody knows how to do that (without custom code) let us know!!

    I imagine that you want to be able to change the code without having to access and change the assertion. Unfortunately the DevOps of ca gateway is quite complex using GMU ... To keep all your development under control I recommend you APIIDA solution (https://apiida.com/).

    Kind regards,
    Albert.



    Kind regards,
    Albert.


    ------------------------------
    Security Engineer
    ELCA
    ------------------------------



  • 5.  RE: Externalize code in JavaScript assertion

    Posted 09-30-2019 06:09 AM
    Hi Albert,

    Finally, I did manage to do it using restman. At first I Get a policy by name, then update it with XSLT adding Javascript and finally doing a PUT with the Id extracted from first response. The Gradle Plugin wasn't useful here because it downloads all the Gateway files and after that filters with the one that you need, but this behaviour is not worth for achieving this goal.

    Kind Regards,

    Antonio


  • 6.  RE: Externalize code in JavaScript assertion

    Posted 09-30-2019 08:43 AM
    Hi Albert,

    Just reacting to your statement: "Unfortunately the DevOps of CA gateway is quite complex using GMU". The GMU is a java program that calls the Gateway RESTMAN APIs for managing the gateways. We are expanding in this area as well with the usage of a Gradle plugin to faciliate the construction of CI/CD pipelines. More information can be found here:
    • https://github.com/CAAPIM/APIM-Gateway-Developer-Tools/wiki/Beta-Release-Repositories-and-Reference-Implementations
    • https://github.com/CAAPIM/gateway-developer-plugin/wiki
    • https://github.com/CAAPIM/APIM-Gateway-Developer-Tools/wiki/Ephemeral-Gateway-Reference-Architecture
    Best regards,
    Christian