ATF Help needed. An error comes up if the user is impersonated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2022 05:09 AM
Hello,
So I have to create an ATF test to check an integration.
Basically there is a catalog item and you fill out the form in portal and then a request is generated along with a RITM and SCTASK. The SCTASK is generated rightaway because there is NO line manager approval and in the SCTASK the vendor reference should be filled to know the integration is working.
So I created an ATF test for it and I am running into a bit of an issue with this one. I will list out the test steps:
1) Create a user > give it name, relevant groups and roles, given it a line manager (LM) and a checkbox which says 'Impersonate this user' (this is important)
2) open a catalog item (sp) > open the relevant cat item in portal
3) set variable values (sp) > set its values
4) validate variable values (sp) > validate one of the values
5) click component (custom UI) > click the add to cart button
6) Checkout shopping cart
7) record query > to check if an sctask is created and vendor ref is not empty
The problem is with the first step of create a user. We cannot impersonate a user because its not best practice since what if the user leaves the company, so we have to create one and give them the relevant groups and roles.
So I created a user with all the correct roles and groups and then there is a checkbox at the bottom which says 'Impersonate this user'. If I keep this box unchecked, the test works fine and no errors. However upon watching the execution frame I can see, that I am logged in with my admin account in the portal and then my details are erased from the fields and the test user details are added to the fields but its still me logged in.
If I check the 'Impersonate user' checkbox in the test step 'Create a User' then in the execution frame I can see the test user is logged in, but cannot checkout the shopping cart because it says LM approval is needed. And the test itself also fails at step 6 which says that the shopping cart is empty.
Any idea on why this happens?
I have created other ATF tests very similar to this one with the same steps to check other integrations and left the impersonate this user checkbox checked and have not run into this issue with any of them. So why is it happening with this catalog item.
I have checked in portal in dev and test instances and can see that LM is not needed for this cat item because sctask is generated rightaway.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2022 05:17 AM
Hi
without more details or better screenshots, it is hard to understand your scenario.
But what I really find strange is your first step. The recommended way for ATF tests is always creating a new and then impersonate that user. If that test user needs roles, you have to provide it before impersonating. After the ATF test has finished, ServiceNow deletes automatically. What does this standard procedure have to do with the fact that the user could leave the company? Which user? Your test user wants to leave the company? Really irritating!
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2022 04:33 AM
Hi,
I think I was unclear in my explanation of the creating a user step. So we do follow the best practice and create a test user and give it roles and groups and then impersonate the test user when doing the ATF. The test user obviously cannot leave the company.
I will attach screen shots of what I meant.
So I have created a user and given it the relevant roles and groups, there is a checkbox at the bottom (encircled in blue >>see create-a-user-test-step picture)
that if left unchecked the test runs fine, but in the execution frame, I can see that I am logged in with my admin account in portal and my details get erased and the test user details get filled in
(see portal-login-with-my-details AND fields-with-my-login-details AND test-user-details-in-fields-but-i-am-still-admin pictures)
If I check the impersonate this user check box (the first picture which shows the checkbox)
And then run the test, I can see the test user is logged into the portal but I get an error for line manager approval which this catalog item doesn't need. ( see impersonated-user-logged-into-portal AND lm-approval-error-in-atf pics)
I hope it is a bit more clear now with pictures.
Basically if I don't impersonate the test user, the test works fine and sctask is created. If I impersonate the test user, the test fails and wants a line manager approval which the cat item doesn't need. The test step that fails is checkout cart step which gives the error that the cart is empty in the test results. I can't add more than 6 pics.