How to End Inpersonation in ATF

senon
Tera Sage

Hi experts!

I did an Impersonate user on ATF and performed a certain action. Then I am looking for a way to End Impersonation or pretend to be the first user to log in.

But I can't find the End Impersonation section in the ATF.

          find_real_file.png

Is there a good way to do this?

Best regards.

senon

 

1 ACCEPTED SOLUTION

Gerald Onyia
Kilo Guru

Hi Senon,

Not sure if I'm late to the party, but there is an "End Impersonation" that I came up with. I haven't seen it elsewhere so far. See below:

1. Start your ATF Test with a 'Run Server Side Script' Step. Clear all the 'Test script' contents, and copy/paste this - "outputs.record_id=gs.getUserID();" and save. What this does is record the User ID of the person who kicked off the ATF Test.

2. Next, create and impersonate your Test User.

3. Once ready to end the impersonation, all you have to do is to impersonate the person in Step 1 by referencing. This goes back to you or whoever kicked off the ATF Test.

Let me know if this helps or if you need some screenshots. I'd be more than happy to provide.

Regards,

Gerald

View solution in original post

6 REPLIES 6

BryanS413339635
Tera Guru

Just initiate another impersonate back to the original user. Something like this

Step 1. Impersonate ATF Change Manager

Step 2-4. Do stuff

Step 5. Impersonate ITIL user

Step 6-8. Do more stuff

Step 9. Impersonate ATF Change Manager

And so on.

Hitoshi Ozawa
Giga Sage
Giga Sage

As bryanshaw replied, there's no end impersonation in ATF nor in script. You'll just have to impersonate back to the original user. Impersonating user would also end if the test is completed.

Also, starting with New York, ServiceNow recommends Create User step instead of impersonating user because impersonating user would require the user to exist and be active. Otherwise, the test would fail. With Create user, this would not happen.

https://developer.servicenow.com/blog.do?p=/post/ny-atf/

Gerald Onyia
Kilo Guru

Hi Senon,

Not sure if I'm late to the party, but there is an "End Impersonation" that I came up with. I haven't seen it elsewhere so far. See below:

1. Start your ATF Test with a 'Run Server Side Script' Step. Clear all the 'Test script' contents, and copy/paste this - "outputs.record_id=gs.getUserID();" and save. What this does is record the User ID of the person who kicked off the ATF Test.

2. Next, create and impersonate your Test User.

3. Once ready to end the impersonation, all you have to do is to impersonate the person in Step 1 by referencing. This goes back to you or whoever kicked off the ATF Test.

Let me know if this helps or if you need some screenshots. I'd be more than happy to provide.

Regards,

Gerald

You have presented me with the way I really wanted to do it.

It worked successfully.

 

Thank you so much.

 

senon