I have been using plone.api.env.adopt_user in integration tests to great success. However it does not seem to be working in functional tests where I want to actually load a browser page as some user.
file_data = 'egg salad sandwich'
api.content.create(
type='CustomContentType',
id='page1',
container=api.portal.get(),
file=NamedBlobFile(data=file_data)
)
transaction.commit()
with api.env.adopt_user('siteadmin'):
self.browser.open(self.portal_url + '/page1')
A debug breakpoint on that content type's view method shows plone.api.user.get_current().getId() to be 'admin'. I don't have this problem with integration tests, just functional. Is there something particular about the functional test layer that would make this not work? I am using standard functional and integration layers and fixtures created through bobtemplate.