Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.

[Automation] How to pass user credentials to the test executor



I would like to trigger the execution of the selected test cases. The documentation is quite clear about this. But I would like the trigger to start an executable jar (list of testcases will be passed as command line argument). This jar will execute the tests and this java applicaton is supposed to send back the results via Testrail API.
Here comes the problematic part. The test executor (the java app) should know the credentials of the user who triggered the execution. How could I pass the logged in user’s credentials? Or could I use some session Id in report API calls?

Shall I somehow request for username and password in UI script and pass this to trigger.php and the credentials will be passed to the Java application? This would not be a nice solution as the user is already logged in, so I would not like to display another authentication form before test run triggering.
Is there any other way to solve this?



Hello Norbert,

Thanks for your posting. We would usually recommend using a separate/static user for the API calls in this case. Passing the username and password to the UI script is not a good idea from a security perspective and we recommend storing the credentials with the trigger script instead. You can look into adding a separate API user in TestRail and only granting the permissions required to implement the automation (e.g. adding test runs and results).

I hope this helps!



How do I create an API only user? Don’t all user logins require a valid email id?


Hello Shiva,

Thanks for your reply! While a user requires a email address as part of the user record, this email address doesn’t necessarily have to exist, so you can also use an inexisting email address for the API user. Or, you could ask your IT to look into adding a TestRail-specific email address.