ATF - Server steps to create new Group, assign Role(s), validate

andrea_s
Tera Expert

Is it possible to create test groups and assign them roles within a test?

 

I am testing the functionality of a form to be edited by different user categories.

 

Since the user categories are not strictly defined with the help of user groups, my solution so far is to create dedicated user groups for testing, something in the line of:

  • TestGroup.AuthorizedUser
  • TestGroup.UnauthorizedUser
  • TestGroup.AuthorizedManager

It is a requirement that in the test step Create a user the group is assigned, not the roles.

 

I would like to create the test groups within the test, and have them disappear at the end. This way I won't clutter the groups table, nor the groups naming (TestGroup.AuthorizedUser is clear within the context of a test, whereas in the groups table I might need to specify something like TestGroupChangeRequest.AuthorizedUser, TestGroupCreateIncident.AuthorizedUser, etc).

 

I tried with the server steps Record Insert, Record Update, and Record Validation, but I cannot make it work. In particular, I am not able to assign roles to the group.

 

Likely there are other/better ways to approach this task. Any idea on how to do so would be much appreciated!

1 ACCEPTED SOLUTION

andrea_s
Tera Expert

Meanwhile a colleague helped me out with the answer: yes, it is possible to create test groups and assign them roles within a test

 

In order to do so, at least three test steps are required

  1. Create a User with permission to create groups and assign them roles, for example an admin
  2. Record Insert - Create the group in sys_user_group
  3. Record Insert - Assign the roles to the group with an entry to the table

    sys_group_has_role

On the consequences of manipulating sys tables within a test I cannot tell much, apart from the fact that there are plenty of warnings to tell the user to be careful about it. So, there might be better ways to approach this task.

 

View solution in original post

1 REPLY 1

andrea_s
Tera Expert

Meanwhile a colleague helped me out with the answer: yes, it is possible to create test groups and assign them roles within a test

 

In order to do so, at least three test steps are required

  1. Create a User with permission to create groups and assign them roles, for example an admin
  2. Record Insert - Create the group in sys_user_group
  3. Record Insert - Assign the roles to the group with an entry to the table

    sys_group_has_role

On the consequences of manipulating sys tables within a test I cannot tell much, apart from the fact that there are plenty of warnings to tell the user to be careful about it. So, there might be better ways to approach this task.