web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Security Role Testing

(0) ShareShare
ReportReport
Posted on by

I am exploring testing - both unit and scenario - specifically in regards to security role access. I have created a form with corresponding table and limited access to a specific role that I have created and assigned for a practice user. I am attempting to test access to the form under different roles (when I specify the correct role the test would pass, otherwise it would fail). In my unit test, I use the constructFromEntryPoint and isTableOperationAllowed methods from the SecurityContext class to test access to the table that is shown on my form. As shown in my screenshot, I have decorated the class with a SysTestSecurityAttribute specifying my default persona as having the necessary role (JPWClassAdmin). I expect this to run the test under the correct user context, causing the test to pass, however this does not work. 

I have fiddled with the SysTestSecurityContext class, specifically the setCurrentPersona method but have not been able to get it working.

Any tips for running tests under specific user/security contexts would be greatly appreciated. I am having the same problem running a task-recording based test on the same form, if that requires different advice.

Thank you for the help.

Test-Screenshot.png

*This post is locked for comments

I have the same question (0)
  • Verified answer
    OrangeRocks Profile Picture
    700 on at
    RE: Security Role Testing

    Hi, have you tried to follow this article blogs.msdn.microsoft.com/.../automated-testing-guidance-for-ax-7  and keeping eye on SysTestSecurityAttribute.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Mea_ Profile Picture

Mea_ 4

#3
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans