def mock_user(monkeypatch, client, roles):
    user = AppUser('someUserId', roles)

    monkeypatch.setattr('auth_provider.AuthProvider.get_authenticated_user',
                        lambda self, auth_code: user)
    monkeypatch.setattr('auth_provider.AuthProvider.get_user',
                        lambda self, user_id: user)

    # Invoke login callback to simulate successful login
    client.get('/login/callback?code=someUserId')
Esempio n. 2
0
 def get_user(self, user_id):
     return AppUser(user_id, self.get_roles(user_id))