OpenApi Driver - adding cookies after Import

Hi there,

I’m wanting to use OpenAPI Driver for API testing within my Automated tests. I’m having some issues with authentication for my API and so I’d decided to go the route of using Robot Browser to automate out my sign-on process (within Suite Setup) and then attempt to use OpenAPI Driver to then test the API (thinking that any cookies/JWT associated with the session would be inherited). This doesn’t seem to be the case, as my OpenAPIDriver tests are just getting redirected back to our sign on page (which is technically returning a 200 status - but is the wrong page completely).

What I’m wanting to try now, is to save any cookies that are created in the Suite Setup and then assign these to the cookies configuration of OpenAPI driver. As described in the Importing section here: OpenApiDriver (marketsquare.github.io)

Is there a way to assign a value to this config, after the import of OpenAPI Driver? Something a little like this:

*** Settings ***
Resource  ./../../ImportList/Imports.resource
Suite Setup         Suite Setup
Test Teardown       Test Teardown
Suite Teardown      Suite Teardown
Library             OpenApiDriver
...                 source=./swagger.json
...                 origin=https://mywebapp.com
...                 base_path=
...                 recursion_limit=0
...                 mappings_path=C:/development_path/API/custom_user_mappings.py
...                 cookies=${COOKIES} 

Hope I am making my question clear - happy to try elaborate further.

The cookies argument is directly passed to the requests library when requests are made. If your Suite Setup sets the ${COOKIES} variable to a dict or a CookieJar instance.

You should be able to extract the required cookie from your Browser session with the Get Cookies keyword (or the Get Cookie keyword, if you know the name of the cookie). You might need to convert the received dict (a dotdict if I read the documentation correctly) to a regular dict for requests to accept it.