Error unimpersonating users during ATF

Anthony10
Giga Contributor

I recently began creating automated tests to validate some of the functionality of our Service Portal. I'm running into an error when the tests try to complete (Regardless of whether the steps were successful or not), shown in the attached screenshot.

It seems that ATF test runner isn't able to unimpersonate users that don't have the 'snc_internal' role. In order impersonate another (or myself) I'm forced to log out and log back in. Again, this only happens when I try to impersonate users without the 'snc_internal' (only 'snc_external') role through ATF. Impersonating one of these users manually causes no problem when I try to then impersonate someone else.

1 ACCEPTED SOLUTION

Are you in London? Impersonation of sn_external users in ATF is support from the Madrid release. Please find below snipped from the docs and it's link:

"Server test steps support impersonation of users with the snc_external role, which allows testing users who do not have login access."

https://docs.servicenow.com/bundle/madrid-release-notes/page/release-notes/application-development/a...

Kindly mark my answer as Correct and Helpful based on the Impact.

Regards,

Alok

View solution in original post

10 REPLIES 10

SatheeshKumar
Kilo Sage

I faced the same issue while doing it manually, I think, it will be the same for your case also.

 try to do it manually, and check for errors.

When I impersonate to a user having snc_external , I can't Impersonate back to my Account. i need to logout and then login again to come back to my account.

It was not an issue in ATF , but an issue related to impersonation with snc_external role.

That's actually a separate issue. I had opened a HI ticket with ServiceNow regarding my issue and they actually ended up solving the problem you are referring to instead.

They had to go in and deactivate some components from a security hotfix that were supposed to be deactivated when London was released

morgang
Giga Expert

I get the same under Madrid; it throws "Running tests and test suites is disabled while impersonating another user." and in the test itself it throws "Error during unimpersonation! Any further action will be done as user:<username>"   Then it doesn't seem to un-impersonate at the end (I can return to impersonating myself to get back to my regular account) and won't let me run further tests until I log out completely and then back in.   Is there a required step to impersonate back to your regular account (i.e., is this user error on my part)? 

 

The test itself seems to be performed, as long as I repeatedly dismiss any errors - individual steps pass until the last step which fails with "Error ending impersonation in the UI session". 

 

Ivana Flegar
Kilo Contributor

Hi, I get the same error in New York. I (as an admin) am writing automated tests and the first step is to create an user without any roles to the system (since the user is accessing the Service Portal only). This step and all steps after that execute successfully, only the last step results in failure due to this error.

After that, I need to log out from the instance and log in again in order to do anything.

How to overcome this issue?

Thanks in advance for any help!

Kind regards,
Ivana

That seems to be an issue related to some code that ServiceNow meant to deactivate related to external user security (See my reply to Satheesh). As admins, we do not have access to this code.

When I had opened up a ticket with ServiceNow, that was the problem they ended up solving for me. I'm not sure if it's been fixed in a later patch of New York, but if it's still happening to people I assume it hasn't.

I would recommend opening a ticket with ServiceNow and describing the problem to them.