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

Trying to trigger automation from hosted account, 'same origin' issue


#1

I’ve been working with the sample code provided here:

https://github.com/gurock/testrail-custom/tree/master/automation/trigger-run-example/4.x

…to try and get TestRail to trigger my automation after creating a Run. I am using a hosted TestRail account, however, so I can’t perform the ajax call to the external URL where my webserver is hosting the PHP trigger code (‘same origin’ issue to prevent xsite scripting).

Is there another way to do this? Is there a way I can POST to the trigger script from my hosted TestRail account with the runID and then let the code on my server take it from there?

Thanks,

-Kent


#2

Hello Kent,

Thanks for your posting. You can look into issuing a regular non-ajax request (e.g. by dynamically creating and submitting a form) with target="_blank" (so that the new request opens in a new window). Would this work for you?

Regards,
Tobias


#3

[quote=tgurock]Hello Kent,

Thanks for your posting. You can look into issuing a regular non-ajax request (e.g. by dynamically creating and submitting a form) with target="_blank" (so that the new request opens in a new window). Would this work for you?

Regards,
Tobias[/quote]

I’ll try this and get back to you. Thanks!

-Kent


#4

You are welcome, Kent.

Regards,
Tobias


#5

I cobbled this together from information I found, but I don’t know if I’m calling the function correctly. This code is clearly broken as the button no longer appears on a Run screen. May be close though.

Edit: I realize now that I put the js function in the wrong part of the code. Things are moving forward (a bit) now. :slight_smile:


#6

Now I get to the PHP, but that’s failing with a 301 error. I have the url printing in the error message text and when I try to GET that with Postman it works fine.

Please let me know if you’ve seen this before, Tobias, otherwise I’ll keep plugging along and see what I can do.


#7

Okay, after reading the error text more closely, it looks like I needed to update the TESTRAIL_API_ADDRESS to use ‘https://…’ instead of ‘http://…’.

Now I get no errors (just a blank page) but I’m not seeing the test status change (expected random change).

I’ll look over the php code more closely now to make sure I understand what’s supposed to happen at this point. Once I understand that, I feel pretty confident that I can flesh it out to work with my own tests one step at a time.


#8

Hold everything…I am getting status updates! I must have forgot to refresh the page or something.

Very cool! It’s up to me now to weave this into our existing architecture.

:smiley:


#9

Hello Kent,

Thanks for the update and great to hear that you got it working :slight_smile:

Please let us know in case any questions come up about the actual integration or API usage, we are happy to help.

Regards,
Tobias