Impersonation via custom step configuration not registered in atf client test runner

tpiwko
Tera Contributor
Hello,
I am implementing a custom step configuration, that impersonates a user with a sys_id that was passed from previous custom step configurations through client data (gs.getSession().putClientData(...)).
I cant really use the Impersonate step, that servicenow offers by default for my use case. So now I am calling this code in the step execution script: 
var impUser = new GlideImpersonate();
var prevUser = impUser.impersonate(userSysId);
I can verify via logging that the user sys_id of gs.getUserId() changes after impersonation, but that change is not reflected in the client test runner. In the top left corner of the window, the name in the "Currently executing as"-field does not change to the impersonated users name. 
 
Is there any way to update this field, so it reflects the correct name after impersonation?
1 REPLY 1

tpiwko
Tera Contributor

I just noticed that it seems like the impersonation does not really work via code in atf. E.g. the user lacks a role to view an app. My account has that role. I added a test step to check the visibility of that app to the user i am impersonating (that does not have the role). Still the step fails and says that the app was visible in the menu, although it should not have been visible. It seems like the test is still executed with my account - this would explain, why the client test runner does not update the "currently executing as"-field. But in the session-object when i call e.g. gs.getRoles() or gs.getUserDisplayName() it correctly shows the values of the user, that i impersonated.

 

Has anyone experienced this or found a workaround?