A robot test fails on wrong roles [updated]

A view method uses plone.api.user.get_roles. The robot test throws a plone.api.user.UserNotFoundError, so roles are not as expected.

There is a difference between




Robot tests fail on getMemberById(username) in get_roles because plone.app.robotframework uses for keyword "Enable autologin as" DomainAuthHelper. Would it be better to use another authentication in plone.app.robotframwork or what do I miss to understand the situation?

You are doing nothing wrong, but the documentation is missing example to map auto login to real users.

The following examples should work:

Enable autologin as  Manager
Create user  my-test-user  Member  fullname=Jane Doe
Set autologin username my-test-user


Enable autologin as  Manager
Create user  my-test-user  Member  Editor  fullname=Jane Doe
Set autologin username my-test-user

At first, Manager is required for creating a real user. Then the real use is created with some roles. Finally, autologin is reconfigured to map to real user (instead of just roles).

Thank you Asko. That points me in a good direction. Although its not yet fixed.

I'm interested in using plone.app.robotframeworks for Plone 5. And if I do get it right Plone 5 selectors are not completely supported. And also found a bug in keyword for creating user with roles. Before I dive deeper into robot tests I would be happy about some feedback on https://github.com/plone/plone.app.robotframework/issues/45
Thank you all

@ksuess Could you please tell more about the issue? The library was supposed to support multiple roles. Are you sure you separated roles with two spaces?

Create user johndoe Contributor Editor Reviewer

creates a user with roles (Member,) due to plone.app.robotframework/src/plone/app/robotframework/users.py at 17fc0000e6fa9bcd0d792c106c5c7b15c30396a7 · plone/plone.app.robotframework · GitHub which ignores non-keyworded arguments and expects keyworded argument 'role'.

Create user janedoe roles=Contributor,Site Administrator

or something like this does not hand over roles to portal_registration.addMember as list, so also here a user without the roles Contributer and Site Administrator is created.

Instead of

roles = properties.pop('roles', ('Member', ))

I propose something like

roles.extend(eval(properties.pop('roles', '()')))

@ksuess Please, open an issue. That's terrible regression and I'm very sorry about that.

Hopefully there's a workaround with the current version by using keyword arguments and a list type robot variable for roles:

@{roles} =  Create list  Contributor  Site Administrator
Create user  janedoe  roles=@{roles}

(Create list is a built-in keywor http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Create%20List)