def test_multi_roles(self, wsgi): body = {'username': fake.word(), 'password': fake.word()} with patch('github.AuthenticatedUser.AuthenticatedUser' ) as github_user_mock: # TODO: create role role1 github_user = github_user_mock.return_value github_user.create_authorization.return_value = Authorization( None, [], {"token": "123456789"}, completed=True) github_user.login = '******' admin_team = Team(None, [], {"name": "sandwich-admin"}, completed=True) admin_team.has_in_members = MagicMock(return_value=True) prefix_team = Team(None, [], {"name": "sandwich-role1"}, completed=True) prefix_team.has_in_members = MagicMock(return_value=True) org = Organization(None, [], {"login": "******"}, completed=True) org.get_teams = MagicMock(return_value=[admin_team, prefix_team]) github_user.get_orgs.return_value = [org] self.post(wsgi, '/v1/auth/github/authorization', body=body)
def test_ok(self, wsgi): body = {'username': fake.word(), 'password': fake.word()} with patch('github.AuthenticatedUser.AuthenticatedUser' ) as github_user_mock: github_user = github_user_mock.return_value github_user.create_authorization.return_value = Authorization( None, [], {"token": "123456789"}, completed=True) github_user.login = '******' org = Organization(None, [], {"login": "******"}, completed=True) org.get_teams = MagicMock(return_value=[]) github_user.get_orgs.return_value = [org] self.post(wsgi, '/v1/auth/github/authorization', body=body)
def test_not_in_org(self, wsgi): body = {'username': fake.word(), 'password': fake.word()} with patch('github.AuthenticatedUser.AuthenticatedUser') as github_user_mock, \ patch('github.Organization.Organization') as github_org: github_user = github_user_mock.return_value github_user.create_authorization.return_value = Authorization( None, [], {"token": "123456789"}, completed=True) github_user.login = '******' github_user.get_orgs.return_value = [] github_org.has_in_members.return_value = False self.post(wsgi, '/v1/auth/github/authorization', body=body, status=403)