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

Testrail External Auth (LDAP) + API fails


#1

Edit: “New users can only post 2 links per post” made me break a few of my links.

Our Testrail instance fails to authenticate using API keys.

I’ve seen a few threads on this topic, but the solutions did not help me.

We use the LDAP external auth script with Testrail. The API works fine when users use their username and LDAP password, but for many reasons this is not ideal.

I have tested using the Testrail API with API keys per the guide:

Command: curl -H "Content-Type: application/json" \ -u “$MYUSERNAME:$MYAPIKEY” \ "testrail.$MYHOSTNAME.net/index.php?/api/v2/get_case/1"

Response: {"error":"External auth: Could not validate LDAP user, please check user name and password."}

I have also tried using my email address instead of username:

Command: curl -H "Content-Type: application/json" \ -u “$MYEMAILADDRESS:$MYAPIKEY” \ "testrail.$MYHOSTNAME.net/index.php?/api/v2/get_case/1"

Response: {"error":"Authentication failed: invalid or missing user\/password or session cookie."}

Note: in our system, LDAP usernames are email addresses. I’m thinking that this might be the cause of the issue.

Any help would be greatly appreciated!

Miles Crabill
Operations Engineer, Mozilla


#2

Hi Miles,

Thanks for your post! TestRail would always check API keys first, and this is independent of any external auth that has been configured. API keys only work with email addresses, so you would just need to be sure that you’re still using the e-mail address to authenticate when using the API key. Please note that when adding API keys, it’s important to save the My Settings form via the ‘Save Settings’ button after adding this in order to permanently store the API key in TestRail. Hope this helps!

Regards,
Marco