def test_issue_update_with_project_change(client): user1 = f.UserFactory.create() user2 = f.UserFactory.create() user3 = f.UserFactory.create() user4 = f.UserFactory.create() project1 = f.ProjectFactory() project2 = f.ProjectFactory() issue_status1 = f.IssueStatusFactory.create(project=project1) issue_status2 = f.IssueStatusFactory.create(project=project2) priority1 = f.PriorityFactory.create(project=project1) priority2 = f.PriorityFactory.create(project=project2) severity1 = f.SeverityFactory.create(project=project1) severity2 = f.SeverityFactory.create(project=project2) issue_type1 = f.IssueTypeFactory.create(project=project1) issue_type2 = f.IssueTypeFactory.create(project=project2) project1.default_issue_status = issue_status1 project2.default_issue_status = issue_status2 project1.default_priority = priority1 project2.default_priority = priority2 project1.default_severity = severity1 project2.default_severity = severity2 project1.default_issue_type = issue_type1 project2.default_issue_type = issue_type2 project1.save() project2.save() membership1 = f.MembershipFactory(project=project1, user=user1, role__project=project1, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) membership2 = f.MembershipFactory(project=project2, user=user1, role__project=project2, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) membership3 = f.MembershipFactory(project=project1, user=user2, role__project=project1, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) membership4 = f.MembershipFactory(project=project2, user=user3, role__project=project2, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) issue = f.IssueFactory.create(project=project1) url = reverse('issues-detail', kwargs={"pk": issue.pk}) # Test user with permissions in both projects client.login(user1) issue_data = IssueSerializer(issue).data issue_data["project"] = project2.id issue_data = json.dumps(issue_data) response = client.put(url, data=issue_data, content_type="application/json") assert response.status_code == 200 issue.project = project1 issue.save() # Test user with permissions in only origin project client.login(user2) issue_data = IssueSerializer(issue).data issue_data["project"] = project2.id issue_data = json.dumps(issue_data) response = client.put(url, data=issue_data, content_type="application/json") assert response.status_code == 403 issue.project = project1 issue.save() # Test user with permissions in only destionation project client.login(user3) issue_data = IssueSerializer(issue).data issue_data["project"] = project2.id issue_data = json.dumps(issue_data) response = client.put(url, data=issue_data, content_type="application/json") assert response.status_code == 403 issue.project = project1 issue.save() # Test user without permissions in the projects client.login(user4) issue_data = IssueSerializer(issue).data issue_data["project"] = project2.id issue_data = json.dumps(issue_data) response = client.put(url, data=issue_data, content_type="application/json") assert response.status_code == 403 issue.project = project1 issue.save()
def data(): m = type("Models", (object, ), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.public_project = f.ProjectFactory( is_private=False, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)) + ["comment_task"], owner=m.project_owner, tasks_csv_uuid=uuid.uuid4().hex) m.public_project = attach_project_extra_info( Project.objects.all()).get(id=m.public_project.id) m.private_project1 = f.ProjectFactory( is_private=True, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), owner=m.project_owner, tasks_csv_uuid=uuid.uuid4().hex) m.private_project1 = attach_project_extra_info( Project.objects.all()).get(id=m.private_project1.id) m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, tasks_csv_uuid=uuid.uuid4().hex) m.private_project2 = attach_project_extra_info( Project.objects.all()).get(id=m.private_project2.id) m.blocked_project = f.ProjectFactory( is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, tasks_csv_uuid=uuid.uuid4().hex, blocked_code=project_choices.BLOCKED_BY_STAFF) m.blocked_project = attach_project_extra_info( Project.objects.all()).get(id=m.blocked_project.id) m.public_membership = f.MembershipFactory(project=m.public_project, user=m.project_member_with_perms, role__project=m.public_project, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.private_membership1 = f.MembershipFactory( project=m.private_project1, user=m.project_member_with_perms, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, role__project=m.private_project1, role__permissions=[]) m.private_membership2 = f.MembershipFactory( project=m.private_project2, user=m.project_member_with_perms, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, role__project=m.private_project2, role__permissions=[]) m.blocked_membership = f.MembershipFactory( project=m.blocked_project, user=m.project_member_with_perms, role__project=m.blocked_project, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.blocked_project, user=m.project_member_without_perms, role__project=m.blocked_project, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.blocked_project, user=m.project_owner, is_admin=True) milestone_public_task = f.MilestoneFactory(project=m.public_project) milestone_private_task1 = f.MilestoneFactory(project=m.private_project1) milestone_private_task2 = f.MilestoneFactory(project=m.private_project2) milestone_blocked_task = f.MilestoneFactory(project=m.blocked_project) m.public_task = f.TaskFactory(project=m.public_project, status__project=m.public_project, milestone=milestone_public_task, user_story__project=m.public_project, user_story__milestone=milestone_public_task) m.public_task = attach_task_extra_info( Task.objects.all()).get(id=m.public_task.id) m.private_task1 = f.TaskFactory( project=m.private_project1, status__project=m.private_project1, milestone=milestone_private_task1, user_story__project=m.private_project1, user_story__milestone=milestone_private_task1) m.private_task1 = attach_task_extra_info( Task.objects.all()).get(id=m.private_task1.id) m.private_task2 = f.TaskFactory( project=m.private_project2, status__project=m.private_project2, milestone=milestone_private_task2, user_story__project=m.private_project2, user_story__milestone=milestone_private_task2) m.private_task2 = attach_task_extra_info( Task.objects.all()).get(id=m.private_task2.id) m.blocked_task = f.TaskFactory( project=m.blocked_project, status__project=m.blocked_project, milestone=milestone_blocked_task, user_story__project=m.blocked_project, user_story__milestone=milestone_blocked_task) m.blocked_task = attach_task_extra_info( Task.objects.all()).get(id=m.blocked_task.id) m.public_project.default_task_status = m.public_task.status m.public_project.save() m.private_project1.default_task_status = m.private_task1.status m.private_project1.save() m.private_project2.default_task_status = m.private_task2.status m.private_project2.save() m.blocked_project.default_task_status = m.blocked_task.status m.blocked_project.save() return m
def data(): m = type("Models", (object,), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.public_project = f.ProjectFactory(is_private=False, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), owner=m.project_owner, slug="public") m.private_project1 = f.ProjectFactory(is_private=True, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), owner=m.project_owner, slug="private1") m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, slug="private2") m.public_membership = f.MembershipFactory(project=m.public_project, user=m.project_member_with_perms, role__project=m.public_project, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.private_membership1 = f.MembershipFactory(project=m.private_project1, user=m.project_member_with_perms, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, role__project=m.private_project1, role__permissions=[]) m.private_membership2 = f.MembershipFactory(project=m.private_project2, user=m.project_member_with_perms, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, role__project=m.private_project2, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_admin=True) m.view_only_membership = f.MembershipFactory(project=m.private_project2, user=m.other_user, role__project=m.private_project2, role__permissions=["view_project"]) m.epic = f.EpicFactory(project=m.private_project2, ref=4) m.us = f.UserStoryFactory(project=m.private_project2, ref=1) m.task = f.TaskFactory(project=m.private_project2, ref=2) m.issue = f.IssueFactory(project=m.private_project2, ref=3) m.milestone = f.MilestoneFactory(project=m.private_project2, slug="milestone-test-1") return m
def membership(self, class_session, user): group = factories.PropertyGroupFactory(granted={self.GRANTED_NAME}, denied={self.DENIED_NAME}) return factories.MembershipFactory(group=group, user=user, includes_today=True)
def data(): m = type("Models", (object, ), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.public_project = f.ProjectFactory( is_private=False, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)), owner=m.project_owner) m.private_project1 = f.ProjectFactory( is_private=True, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)), owner=m.project_owner) m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner) m.public_membership = f.MembershipFactory(project=m.public_project, user=m.project_member_with_perms, role__project=m.public_project, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.private_membership1 = f.MembershipFactory( project=m.private_project1, user=m.project_member_with_perms, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, role__project=m.private_project1, role__permissions=[]) m.private_membership2 = f.MembershipFactory( project=m.private_project2, user=m.project_member_with_perms, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, role__project=m.private_project2, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_owner=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_owner=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_owner=True) m.public_points = f.PointsFactory(project=m.public_project) m.private_points1 = f.PointsFactory(project=m.private_project1) m.private_points2 = f.PointsFactory(project=m.private_project2) m.public_role_points = f.RolePointsFactory( role=m.public_project.roles.all()[0], points=m.public_points, user_story__project=m.public_project) m.private_role_points1 = f.RolePointsFactory( role=m.private_project1.roles.all()[0], points=m.private_points1, user_story__project=m.private_project1) m.private_role_points2 = f.RolePointsFactory( role=m.private_project2.roles.all()[0], points=m.private_points2, user_story__project=m.private_project2) m.public_user_story = m.public_role_points.user_story m.private_user_story1 = m.private_role_points1.user_story m.private_user_story2 = m.private_role_points2.user_story return m
def data(): m = type("Models", (object, ), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.public_project = f.ProjectFactory( is_private=False, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), owner=m.project_owner) m.private_project1 = f.ProjectFactory( is_private=True, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), owner=m.project_owner) m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner) m.public_membership = f.MembershipFactory(project=m.public_project, user=m.project_member_with_perms, role__project=m.public_project, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.private_membership1 = f.MembershipFactory( project=m.private_project1, user=m.project_member_with_perms, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, role__project=m.private_project1, role__permissions=[]) m.private_membership2 = f.MembershipFactory( project=m.private_project2, user=m.project_member_with_perms, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, role__project=m.private_project2, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_admin=True) return m
def test_task_update_with_project_change(client): user1 = f.UserFactory.create() user2 = f.UserFactory.create() user3 = f.UserFactory.create() user4 = f.UserFactory.create() project1 = f.ProjectFactory() project2 = f.ProjectFactory() task_status1 = f.TaskStatusFactory.create(project=project1) task_status2 = f.TaskStatusFactory.create(project=project2) project1.default_task_status = task_status1 project2.default_task_status = task_status2 project1.save() project2.save() membership1 = f.MembershipFactory(project=project1, user=user1, role__project=project1, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) membership2 = f.MembershipFactory(project=project2, user=user1, role__project=project2, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) membership3 = f.MembershipFactory(project=project1, user=user2, role__project=project1, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) membership4 = f.MembershipFactory(project=project2, user=user3, role__project=project2, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) task = f.TaskFactory.create(project=project1) url = reverse('tasks-detail', kwargs={"pk": task.pk}) # Test user with permissions in both projects client.login(user1) task_data = TaskSerializer(task).data task_data["project"] = project2.id task_data = json.dumps(task_data) response = client.put(url, data=task_data, content_type="application/json") assert response.status_code == 200 task.project = project1 task.save() # Test user with permissions in only origin project client.login(user2) task_data = TaskSerializer(task).data task_data["project"] = project2.id task_data = json.dumps(task_data) response = client.put(url, data=task_data, content_type="application/json") assert response.status_code == 403 task.project = project1 task.save() # Test user with permissions in only destionation project client.login(user3) task_data = TaskSerializer(task).data task_data["project"] = project2.id task_data = json.dumps(task_data) response = client.put(url, data=task_data, content_type="application/json") assert response.status_code == 403 task.project = project1 task.save() # Test user without permissions in the projects client.login(user4) task_data = TaskSerializer(task).data task_data["project"] = project2.id task_data = json.dumps(task_data) response = client.put(url, data=task_data, content_type="application/json") assert response.status_code == 403 task.project = project1 task.save()
def test_user_story_put_update_with_project_change(client): user1 = f.UserFactory.create() user2 = f.UserFactory.create() user3 = f.UserFactory.create() user4 = f.UserFactory.create() project1 = f.ProjectFactory() project2 = f.ProjectFactory() us_status1 = f.UserStoryStatusFactory.create(project=project1) us_status2 = f.UserStoryStatusFactory.create(project=project2) points1 = f.PointsFactory.create(project=project1) points2 = f.PointsFactory.create(project=project2) project1.default_us_status = us_status1 project2.default_us_status = us_status2 project1.default_points = points1 project2.default_points = points2 project1.save() project2.save() project1 = attach_project_extra_info(Project.objects.all()).get(id=project1.id) project2 = attach_project_extra_info(Project.objects.all()).get(id=project2.id) f.MembershipFactory(project=project1, user=user1, role__project=project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=project2, user=user1, role__project=project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=project1, user=user2, role__project=project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=project2, user=user3, role__project=project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) us = f.UserStoryFactory.create(project=project1) us = attach_userstory_extra_info(UserStory.objects.all()).get(id=us.id) url = reverse('userstories-detail', kwargs={"pk": us.pk}) # Test user with permissions in both projects client.login(user1) us_data = UserStorySerializer(us).data us_data["project"] = project2.id del us_data["points"] us_data = json.dumps(us_data) response = client.put(url, data=us_data, content_type="application/json") assert response.status_code == 200 us.project = project1 us.save() # Test user with permissions in only origin project client.login(user2) us_data = UserStorySerializer(us).data us_data["project"] = project2.id del us_data["points"] us_data = json.dumps(us_data) response = client.put(url, data=us_data, content_type="application/json") assert response.status_code == 403 us.project = project1 us.save() # Test user with permissions in only destionation project client.login(user3) us_data = UserStorySerializer(us).data us_data["project"] = project2.id del us_data["points"] us_data = json.dumps(us_data) response = client.put(url, data=us_data, content_type="application/json") assert response.status_code == 403 us.project = project1 us.save() # Test user without permissions in the projects client.login(user4) us_data = UserStorySerializer(us).data us_data["project"] = project2.id del us_data["points"] us_data = json.dumps(us_data) response = client.put(url, data=us_data, content_type="application/json") assert response.status_code == 403 us.project = project1 us.save()
def data(): m = type("Models", (object, ), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.public_project = f.ProjectFactory( is_private=False, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)) + ["comment_issue"], owner=m.project_owner, issues_csv_uuid=uuid.uuid4().hex) m.public_project = attach_project_extra_info( Project.objects.all()).get(id=m.public_project.id) m.private_project1 = f.ProjectFactory( is_private=True, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), owner=m.project_owner, issues_csv_uuid=uuid.uuid4().hex) m.private_project1 = attach_project_extra_info( Project.objects.all()).get(id=m.private_project1.id) m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, issues_csv_uuid=uuid.uuid4().hex) m.private_project2 = attach_project_extra_info( Project.objects.all()).get(id=m.private_project2.id) m.blocked_project = f.ProjectFactory( is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, issues_csv_uuid=uuid.uuid4().hex, blocked_code=project_choices.BLOCKED_BY_STAFF) m.blocked_project = attach_project_extra_info( Project.objects.all()).get(id=m.blocked_project.id) m.public_membership = f.MembershipFactory(project=m.public_project, user=m.project_member_with_perms, role__project=m.public_project, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.private_membership1 = f.MembershipFactory( project=m.private_project1, user=m.project_member_with_perms, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, role__project=m.private_project1, role__permissions=[]) m.private_membership2 = f.MembershipFactory( project=m.private_project2, user=m.project_member_with_perms, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, role__project=m.private_project2, role__permissions=[]) m.blocked_membership = f.MembershipFactory( project=m.blocked_project, user=m.project_member_with_perms, role__project=m.blocked_project, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.blocked_project, user=m.project_member_without_perms, role__project=m.blocked_project, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.blocked_project, user=m.project_owner, is_admin=True) m.public_issue = f.IssueFactory(project=m.public_project, status__project=m.public_project, severity__project=m.public_project, priority__project=m.public_project, type__project=m.public_project, milestone__project=m.public_project) m.public_issue = attach_issue_extra_info( Issue.objects.all()).get(id=m.public_issue.id) m.private_issue1 = f.IssueFactory(project=m.private_project1, status__project=m.private_project1, severity__project=m.private_project1, priority__project=m.private_project1, type__project=m.private_project1, milestone__project=m.private_project1) m.private_issue1 = attach_issue_extra_info( Issue.objects.all()).get(id=m.private_issue1.id) m.private_issue2 = f.IssueFactory(project=m.private_project2, status__project=m.private_project2, severity__project=m.private_project2, priority__project=m.private_project2, type__project=m.private_project2, milestone__project=m.private_project2) m.private_issue2 = attach_issue_extra_info( Issue.objects.all()).get(id=m.private_issue2.id) m.blocked_issue = f.IssueFactory(project=m.blocked_project, status__project=m.blocked_project, severity__project=m.blocked_project, priority__project=m.blocked_project, type__project=m.blocked_project, milestone__project=m.blocked_project) m.blocked_issue = attach_issue_extra_info( Issue.objects.all()).get(id=m.blocked_issue.id) return m
def test_epic_put_update_with_project_change(client): user1 = f.UserFactory.create() user2 = f.UserFactory.create() user3 = f.UserFactory.create() user4 = f.UserFactory.create() project1 = f.ProjectFactory() project2 = f.ProjectFactory() epic_status1 = f.EpicStatusFactory.create(project=project1) epic_status2 = f.EpicStatusFactory.create(project=project2) project1.default_epic_status = epic_status1 project2.default_epic_status = epic_status2 project1.save() project2.save() project1 = attach_project_extra_info( Project.objects.all()).get(id=project1.id) project2 = attach_project_extra_info( Project.objects.all()).get(id=project2.id) f.MembershipFactory(project=project1, user=user1, role__project=project1, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=project2, user=user1, role__project=project2, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=project1, user=user2, role__project=project1, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=project2, user=user3, role__project=project2, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) epic = f.EpicFactory.create(project=project1) epic = attach_epic_extra_info(Epic.objects.all()).get(id=epic.id) url = reverse('epics-detail', kwargs={"pk": epic.pk}) # Test user with permissions in both projects client.login(user1) epic_data = EpicSerializer(epic).data epic_data["project"] = project2.id epic_data = json.dumps(epic_data) response = client.put(url, data=epic_data, content_type="application/json") assert response.status_code == 200 epic.project = project1 epic.save() # Test user with permissions in only origin project client.login(user2) epic_data = EpicSerializer(epic).data epic_data["project"] = project2.id epic_data = json.dumps(epic_data) response = client.put(url, data=epic_data, content_type="application/json") assert response.status_code == 403 epic.project = project1 epic.save() # Test user with permissions in only destionation project client.login(user3) epic_data = EpicSerializer(epic).data epic_data["project"] = project2.id epic_data = json.dumps(epic_data) response = client.put(url, data=epic_data, content_type="application/json") assert response.status_code == 403 epic.project = project1 epic.save() # Test user without permissions in the projects client.login(user4) epic_data = EpicSerializer(epic).data epic_data["project"] = project2.id epic_data = json.dumps(epic_data) response = client.put(url, data=epic_data, content_type="application/json") assert response.status_code == 403 epic.project = project1 epic.save()
def data(): m = type("Models", (object,), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.public_points = f.PointsFactory() m.public_project = f.ProjectFactory(is_private=False, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)) + ["comment_us"], owner=m.project_owner, userstories_csv_uuid=uuid.uuid4().hex, default_points=m.public_points) m.public_project = attach_project_extra_info(Project.objects.all()).get(id=m.public_project.id) m.private_points1 = f.PointsFactory() m.private_project1 = f.ProjectFactory(is_private=True, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), owner=m.project_owner, userstories_csv_uuid=uuid.uuid4().hex, default_points=m.private_points1) m.private_project1 = attach_project_extra_info(Project.objects.all()).get(id=m.private_project1.id) m.private_sprint1 = f.MilestoneFactory.create(project=m.private_project1, owner=m.project_owner) m.private_points2 = f.PointsFactory() m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, userstories_csv_uuid=uuid.uuid4().hex, default_points=m.private_points2) m.private_project2 = attach_project_extra_info(Project.objects.all()).get(id=m.private_project2.id) m.blocked_points = f.PointsFactory() m.blocked_project = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, userstories_csv_uuid=uuid.uuid4().hex, blocked_code=project_choices.BLOCKED_BY_STAFF, default_points=m.blocked_points) m.blocked_project = attach_project_extra_info(Project.objects.all()).get(id=m.blocked_project.id) m.public_membership = f.MembershipFactory( project=m.public_project, user=m.project_member_with_perms, role__project=m.public_project, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.private_membership1 = f.MembershipFactory( project=m.private_project1, user=m.project_member_with_perms, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, role__project=m.private_project1, role__permissions=[]) m.private_membership2 = f.MembershipFactory( project=m.private_project2, user=m.project_member_with_perms, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, role__project=m.private_project2, role__permissions=[]) m.blocked_membership = f.MembershipFactory( project=m.blocked_project, user=m.project_member_with_perms, role__project=m.blocked_project, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.blocked_project, user=m.project_member_without_perms, role__project=m.blocked_project, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.blocked_project, user=m.project_owner, is_admin=True) m.public_user_story = f.UserStoryFactory(project=m.public_project, milestone__project=m.public_project, status__project=m.public_project) m.public_user_story = attach_userstory_extra_info(UserStory.objects.all()).get(id=m.public_user_story.id) m.private_user_story1 = f.UserStoryFactory(project=m.private_project1, milestone__project=m.private_project1, status__project=m.private_project1) m.private_user_story1 = attach_userstory_extra_info(UserStory.objects.all()).get(id=m.private_user_story1.id) m.private_user_story2 = f.UserStoryFactory(project=m.private_project2, milestone__project=m.private_project2, status__project=m.private_project2) m.private_user_story2 = attach_userstory_extra_info(UserStory.objects.all()).get(id=m.private_user_story2.id) m.blocked_user_story = f.UserStoryFactory(project=m.blocked_project, milestone__project=m.blocked_project, status__project=m.blocked_project) m.blocked_user_story = attach_userstory_extra_info(UserStory.objects.all()).get(id=m.blocked_user_story.id) return m
def data(): m = type("Models", (object,), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.public_project = f.ProjectFactory(is_private=False, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)), owner=m.project_owner, userstories_csv_uuid=uuid.uuid4().hex) m.private_project1 = f.ProjectFactory(is_private=True, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)), owner=m.project_owner, userstories_csv_uuid=uuid.uuid4().hex) m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, userstories_csv_uuid=uuid.uuid4().hex) m.blocked_project = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, userstories_csv_uuid=uuid.uuid4().hex, blocked_code=project_choices.BLOCKED_BY_STAFF) m.public_membership = f.MembershipFactory(project=m.public_project, user=m.project_member_with_perms, role__project=m.public_project, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.private_membership1 = f.MembershipFactory(project=m.private_project1, user=m.project_member_with_perms, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, role__project=m.private_project1, role__permissions=[]) m.private_membership2 = f.MembershipFactory(project=m.private_project2, user=m.project_member_with_perms, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, role__project=m.private_project2, role__permissions=[]) m.blocked_membership = f.MembershipFactory(project=m.blocked_project, user=m.project_member_with_perms, role__project=m.blocked_project, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.blocked_project, user=m.project_member_without_perms, role__project=m.blocked_project, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.blocked_project, user=m.project_owner, is_admin=True) m.public_points = f.PointsFactory(project=m.public_project) m.private_points1 = f.PointsFactory(project=m.private_project1) m.private_points2 = f.PointsFactory(project=m.private_project2) m.blocked_points = f.PointsFactory(project=m.blocked_project) m.public_role_points = f.RolePointsFactory(role=m.public_project.roles.all()[0], points=m.public_points, user_story__project=m.public_project, user_story__milestone__project=m.public_project, user_story__status__project=m.public_project) m.private_role_points1 = f.RolePointsFactory(role=m.private_project1.roles.all()[0], points=m.private_points1, user_story__project=m.private_project1, user_story__milestone__project=m.private_project1, user_story__status__project=m.private_project1) m.private_role_points2 = f.RolePointsFactory(role=m.private_project2.roles.all()[0], points=m.private_points2, user_story__project=m.private_project2, user_story__milestone__project=m.private_project2, user_story__status__project=m.private_project2) m.blocked_role_points = f.RolePointsFactory(role=m.blocked_project.roles.all()[0], points=m.blocked_points, user_story__project=m.blocked_project, user_story__milestone__project=m.blocked_project, user_story__status__project=m.blocked_project) m.public_user_story = m.public_role_points.user_story m.private_user_story1 = m.private_role_points1.user_story m.private_user_story2 = m.private_role_points2.user_story m.blocked_user_story = m.blocked_role_points.user_story return m
def data(): m = type("Models", (object, ), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.public_project = f.ProjectFactory( is_private=False, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)), owner=m.project_owner) m.private_project1 = f.ProjectFactory( is_private=True, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)), owner=m.project_owner) m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner) m.blocked_project = f.ProjectFactory( is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, blocked_code=project_choices.BLOCKED_BY_STAFF) m.public_membership = f.MembershipFactory(project=m.public_project, user=m.project_member_with_perms, role__project=m.public_project, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.private_membership1 = f.MembershipFactory( project=m.private_project1, user=m.project_member_with_perms, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, role__project=m.private_project1, role__permissions=[]) m.private_membership2 = f.MembershipFactory( project=m.private_project2, user=m.project_member_with_perms, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, role__project=m.private_project2, role__permissions=[]) m.blocked_membership = f.MembershipFactory( project=m.blocked_project, user=m.project_member_with_perms, role__project=m.blocked_project, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.blocked_project, user=m.project_member_without_perms, role__project=m.blocked_project, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.blocked_project, user=m.project_owner, is_admin=True) m.public_wiki_page = f.WikiPageFactory(project=m.public_project) m.private_wiki_page1 = f.WikiPageFactory(project=m.private_project1) m.private_wiki_page2 = f.WikiPageFactory(project=m.private_project2) m.blocked_wiki_page = f.WikiPageFactory(project=m.blocked_project) m.public_wiki_link = f.WikiLinkFactory(project=m.public_project) m.private_wiki_link1 = f.WikiLinkFactory(project=m.private_project1) m.private_wiki_link2 = f.WikiLinkFactory(project=m.private_project2) m.blocked_wiki_link = f.WikiLinkFactory(project=m.blocked_project) return m
def test_wiki_page_put_update_with_project_change(client): user1 = f.UserFactory.create() user2 = f.UserFactory.create() user3 = f.UserFactory.create() user4 = f.UserFactory.create() project1 = f.ProjectFactory() project2 = f.ProjectFactory() membership1 = f.MembershipFactory(project=project1, user=user1, role__project=project1, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) membership2 = f.MembershipFactory(project=project2, user=user1, role__project=project2, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) membership3 = f.MembershipFactory(project=project1, user=user2, role__project=project1, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) membership4 = f.MembershipFactory(project=project2, user=user3, role__project=project2, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) wiki_page = f.WikiPageFactory.create(project=project1) url = reverse('wiki-detail', kwargs={"pk": wiki_page.pk}) # Test user with permissions in both projects client.login(user1) wiki_page_data = WikiPageSerializer(wiki_page).data wiki_page_data["project"] = project2.id wiki_page_data = json.dumps(wiki_page_data) response = client.put(url, data=wiki_page_data, content_type="application/json") assert response.status_code == 200 wiki_page.project = project1 wiki_page.save() # Test user with permissions in only origin project client.login(user2) wiki_page_data = WikiPageSerializer(wiki_page).data wiki_page_data["project"] = project2.id wiki_page_data = json.dumps(wiki_page_data) response = client.put(url, data=wiki_page_data, content_type="application/json") assert response.status_code == 403 wiki_page.project = project1 wiki_page.save() # Test user with permissions in only destionation project client.login(user3) wiki_page_data = WikiPageSerializer(wiki_page).data wiki_page_data["project"] = project2.id wiki_page_data = json.dumps(wiki_page_data) response = client.put(url, data=wiki_page_data, content_type="application/json") assert response.status_code == 403 wiki_page.project = project1 wiki_page.save() # Test user without permissions in the projects client.login(user4) wiki_page_data = WikiPageSerializer(wiki_page).data wiki_page_data["project"] = project2.id wiki_page_data = json.dumps(wiki_page_data) response = client.put(url, data=wiki_page_data, content_type="application/json") assert response.status_code == 403 wiki_page.project = project1 wiki_page.save()
def data(): m = type("Models", (object, ), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.public_project = f.ProjectFactory( is_private=False, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)), owner=m.project_owner, issues_csv_uuid=uuid.uuid4().hex) m.private_project1 = f.ProjectFactory( is_private=True, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)), owner=m.project_owner, issues_csv_uuid=uuid.uuid4().hex) m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, issues_csv_uuid=uuid.uuid4().hex) m.public_membership = f.MembershipFactory(project=m.public_project, user=m.project_member_with_perms, role__project=m.public_project, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.private_membership1 = f.MembershipFactory( project=m.private_project1, user=m.project_member_with_perms, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, role__project=m.private_project1, role__permissions=[]) m.private_membership2 = f.MembershipFactory( project=m.private_project2, user=m.project_member_with_perms, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, role__project=m.private_project2, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_owner=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_owner=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_owner=True) m.public_issue = f.IssueFactory(project=m.public_project, status__project=m.public_project, severity__project=m.public_project, priority__project=m.public_project, type__project=m.public_project, milestone__project=m.public_project) m.private_issue1 = f.IssueFactory(project=m.private_project1, status__project=m.private_project1, severity__project=m.private_project1, priority__project=m.private_project1, type__project=m.private_project1, milestone__project=m.private_project1) m.private_issue2 = f.IssueFactory(project=m.private_project2, status__project=m.private_project2, severity__project=m.private_project2, priority__project=m.private_project2, type__project=m.private_project2, milestone__project=m.private_project2) return m
def data(): m = type("Models", (object,), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.public_project = f.ProjectFactory(is_private=False, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), owner=m.project_owner) m.public_project = attach_project_extra_info(Project.objects.all()).get(id=m.public_project.id) m.private_project1 = f.ProjectFactory(is_private=True, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), owner=m.project_owner) m.private_project1 = attach_project_extra_info(Project.objects.all()).get(id=m.private_project1.id) m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner) m.private_project2 = attach_project_extra_info(Project.objects.all()).get(id=m.private_project2.id) m.blocked_project = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, blocked_code=project_choices.BLOCKED_BY_STAFF) m.blocked_project = attach_project_extra_info(Project.objects.all()).get(id=m.blocked_project.id) m.public_membership = f.MembershipFactory( project=m.public_project, user=m.project_member_with_perms, role__project=m.public_project, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.private_membership1 = f.MembershipFactory( project=m.private_project1, user=m.project_member_with_perms, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, role__project=m.private_project1, role__permissions=[]) m.private_membership2 = f.MembershipFactory( project=m.private_project2, user=m.project_member_with_perms, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, role__project=m.private_project2, role__permissions=[]) m.blocked_membership = f.MembershipFactory( project=m.blocked_project, user=m.project_member_with_perms, role__project=m.blocked_project, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.blocked_project, user=m.project_member_without_perms, role__project=m.blocked_project, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.blocked_project, user=m.project_owner, is_admin=True) m.public_milestone = f.MilestoneFactory(project=m.public_project) m.public_milestone = attach_milestone_extra_info(Milestone.objects.all()).get(id=m.public_milestone.id) m.private_milestone1 = f.MilestoneFactory(project=m.private_project1) m.private_milestone1 = attach_milestone_extra_info(Milestone.objects.all()).get(id=m.private_milestone1.id) m.private_milestone2 = f.MilestoneFactory(project=m.private_project2) m.private_milestone2 = attach_milestone_extra_info(Milestone.objects.all()).get(id=m.private_milestone2.id) m.blocked_milestone = f.MilestoneFactory(project=m.blocked_project) m.blocked_milestone = attach_milestone_extra_info(Milestone.objects.all()).get(id=m.blocked_milestone.id) return m
def data(): m = type("Models", (object, ), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.superuser = f.UserFactory.create(is_superuser=True) m.public_project = f.ProjectFactory( is_private=False, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)), owner=m.project_owner) m.private_project1 = f.ProjectFactory( is_private=True, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)), owner=m.project_owner) m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner) m.blocked_project = f.ProjectFactory( is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, blocked_code=project_choices.BLOCKED_BY_STAFF) m.public_membership = f.MembershipFactory( project=m.public_project, user=m.project_member_with_perms, email=m.project_member_with_perms.email, role__project=m.public_project, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.private_membership1 = f.MembershipFactory( project=m.private_project1, user=m.project_member_with_perms, email=m.project_member_with_perms.email, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, email=m.project_member_without_perms.email, role__project=m.private_project1, role__permissions=[]) m.private_membership2 = f.MembershipFactory( project=m.private_project2, user=m.project_member_with_perms, email=m.project_member_with_perms.email, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, email=m.project_member_without_perms.email, role__project=m.private_project2, role__permissions=[]) m.blocked_membership = f.MembershipFactory( project=m.blocked_project, user=m.project_member_with_perms, email=m.project_member_with_perms.email, role__project=m.blocked_project, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.blocked_project, user=m.project_member_without_perms, email=m.project_member_without_perms.email, role__project=m.blocked_project, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_owner=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_owner=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_owner=True) f.MembershipFactory(project=m.blocked_project, user=m.project_owner, is_owner=True) m.public_issue_ca = f.IssueCustomAttributeFactory(project=m.public_project) m.private_issue_ca1 = f.IssueCustomAttributeFactory( project=m.private_project1) m.private_issue_ca2 = f.IssueCustomAttributeFactory( project=m.private_project2) m.blocked_issue_ca = f.IssueCustomAttributeFactory( project=m.blocked_project) m.public_issue = f.IssueFactory(project=m.public_project, status__project=m.public_project, severity__project=m.public_project, priority__project=m.public_project, type__project=m.public_project, milestone__project=m.public_project) m.private_issue1 = f.IssueFactory(project=m.private_project1, status__project=m.private_project1, severity__project=m.private_project1, priority__project=m.private_project1, type__project=m.private_project1, milestone__project=m.private_project1) m.private_issue2 = f.IssueFactory(project=m.private_project2, status__project=m.private_project2, severity__project=m.private_project2, priority__project=m.private_project2, type__project=m.private_project2, milestone__project=m.private_project2) m.blocked_issue = f.IssueFactory(project=m.blocked_project, status__project=m.blocked_project, severity__project=m.blocked_project, priority__project=m.blocked_project, type__project=m.blocked_project, milestone__project=m.blocked_project) m.public_issue_cav = m.public_issue.custom_attributes_values m.private_issue_cav1 = m.private_issue1.custom_attributes_values m.private_issue_cav2 = m.private_issue2.custom_attributes_values m.blocked_issue_cav = m.blocked_issue.custom_attributes_values return m
def data(): m = type("Models", (object, ), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.superuser = f.UserFactory.create(is_superuser=True) m.public_project = f.ProjectFactory( is_private=False, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)), owner=m.project_owner) m.private_project1 = f.ProjectFactory( is_private=True, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)), owner=m.project_owner) m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner) m.public_membership = f.MembershipFactory( project=m.public_project, user=m.project_member_with_perms, email=m.project_member_with_perms.email, role__project=m.public_project, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.private_membership1 = f.MembershipFactory( project=m.private_project1, user=m.project_member_with_perms, email=m.project_member_with_perms.email, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, email=m.project_member_without_perms.email, role__project=m.private_project1, role__permissions=[]) m.private_membership2 = f.MembershipFactory( project=m.private_project2, user=m.project_member_with_perms, email=m.project_member_with_perms.email, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, email=m.project_member_without_perms.email, role__project=m.private_project2, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_owner=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_owner=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_owner=True) m.public_task_ca = f.TaskCustomAttributeFactory(project=m.public_project) m.private_task_ca1 = f.TaskCustomAttributeFactory( project=m.private_project1) m.private_task_ca2 = f.TaskCustomAttributeFactory( project=m.private_project2) m.public_task = f.TaskFactory(project=m.public_project, status__project=m.public_project, milestone__project=m.public_project, user_story__project=m.public_project) m.private_task1 = f.TaskFactory(project=m.private_project1, status__project=m.private_project1, milestone__project=m.private_project1, user_story__project=m.private_project1) m.private_task2 = f.TaskFactory(project=m.private_project2, status__project=m.private_project2, milestone__project=m.private_project2, user_story__project=m.private_project2) m.public_task_cav = m.public_task.custom_attributes_values m.private_task_cav1 = m.private_task1.custom_attributes_values m.private_task_cav2 = m.private_task2.custom_attributes_values return m
def data(): m = type("Models", (object, ), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.superuser = f.UserFactory.create(is_superuser=True) m.public_project = f.ProjectFactory(is_private=False, anon_permissions=['view_project'], public_permissions=['view_project']) m.public_project = attach_extra_info( project_models.Project.objects.all()).get(id=m.public_project.id) m.private_project1 = f.ProjectFactory(is_private=True, anon_permissions=['view_project'], public_permissions=['view_project'], owner=m.project_owner) m.private_project1 = attach_extra_info( project_models.Project.objects.all()).get(id=m.private_project1.id) m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner) m.private_project2 = attach_extra_info( project_models.Project.objects.all()).get(id=m.private_project2.id) m.blocked_project = f.ProjectFactory( is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, blocked_code=project_choices.BLOCKED_BY_STAFF) m.blocked_project = attach_extra_info( project_models.Project.objects.all()).get(id=m.blocked_project.id) f.RoleFactory(project=m.public_project) m.membership = f.MembershipFactory(project=m.private_project1, user=m.project_member_with_perms, role__project=m.private_project1, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.membership = f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, role__project=m.private_project1, role__permissions=[]) m.membership = f.MembershipFactory(project=m.private_project2, user=m.project_member_with_perms, role__project=m.private_project2, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.membership = f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, role__project=m.private_project2, role__permissions=[]) m.membership = f.MembershipFactory(project=m.blocked_project, user=m.project_member_with_perms, role__project=m.blocked_project, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.membership = f.MembershipFactory(project=m.blocked_project, user=m.project_member_without_perms, role__project=m.blocked_project, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, role__project=m.public_project, is_admin=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, role__project=m.private_project1, is_admin=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, role__project=m.private_project2, is_admin=True) f.MembershipFactory(project=m.blocked_project, user=m.project_owner, role__project=m.blocked_project, is_admin=True) ContentType = apps.get_model("contenttypes", "ContentType") Project = apps.get_model("projects", "Project") project_ct = ContentType.objects.get_for_model(Project) f.LikeFactory(content_type=project_ct, object_id=m.public_project.pk, user=m.project_member_with_perms) f.LikeFactory(content_type=project_ct, object_id=m.public_project.pk, user=m.project_owner) f.LikeFactory(content_type=project_ct, object_id=m.private_project1.pk, user=m.project_member_with_perms) f.LikeFactory(content_type=project_ct, object_id=m.private_project1.pk, user=m.project_owner) f.LikeFactory(content_type=project_ct, object_id=m.private_project2.pk, user=m.project_member_with_perms) f.LikeFactory(content_type=project_ct, object_id=m.private_project2.pk, user=m.project_owner) f.LikeFactory(content_type=project_ct, object_id=m.blocked_project.pk, user=m.project_member_with_perms) f.LikeFactory(content_type=project_ct, object_id=m.blocked_project.pk, user=m.project_owner) return m
def data(): m = type("Models", (object, ), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.public_project = f.ProjectFactory( is_private=False, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), owner=m.project_owner, epics_csv_uuid=uuid.uuid4().hex) m.public_project = attach_project_extra_info( Project.objects.all()).get(id=m.public_project.id) m.private_project1 = f.ProjectFactory( is_private=True, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), owner=m.project_owner, epics_csv_uuid=uuid.uuid4().hex) m.private_project1 = attach_project_extra_info( Project.objects.all()).get(id=m.private_project1.id) m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, epics_csv_uuid=uuid.uuid4().hex) m.private_project2 = attach_project_extra_info( Project.objects.all()).get(id=m.private_project2.id) m.blocked_project = f.ProjectFactory( is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, epics_csv_uuid=uuid.uuid4().hex, blocked_code=project_choices.BLOCKED_BY_STAFF) m.blocked_project = attach_project_extra_info( Project.objects.all()).get(id=m.blocked_project.id) m.public_membership = f.MembershipFactory(project=m.public_project, user=m.project_member_with_perms, role__project=m.public_project, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.private_membership1 = f.MembershipFactory( project=m.private_project1, user=m.project_member_with_perms, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, role__project=m.private_project1, role__permissions=[]) m.private_membership2 = f.MembershipFactory( project=m.private_project2, user=m.project_member_with_perms, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, role__project=m.private_project2, role__permissions=[]) m.blocked_membership = f.MembershipFactory( project=m.blocked_project, user=m.project_member_with_perms, role__project=m.blocked_project, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.blocked_project, user=m.project_member_without_perms, role__project=m.blocked_project, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_admin=True) f.MembershipFactory(project=m.blocked_project, user=m.project_owner, is_admin=True) m.public_epic = f.EpicFactory(project=m.public_project, status__project=m.public_project) m.public_epic = attach_epic_extra_info( Epic.objects.all()).get(id=m.public_epic.id) m.private_epic1 = f.EpicFactory(project=m.private_project1, status__project=m.private_project1) m.private_epic1 = attach_epic_extra_info( Epic.objects.all()).get(id=m.private_epic1.id) m.private_epic2 = f.EpicFactory(project=m.private_project2, status__project=m.private_project2) m.private_epic2 = attach_epic_extra_info( Epic.objects.all()).get(id=m.private_epic2.id) m.blocked_epic = f.EpicFactory(project=m.blocked_project, status__project=m.blocked_project) m.blocked_epic = attach_epic_extra_info( Epic.objects.all()).get(id=m.blocked_epic.id) m.public_us = f.UserStoryFactory(project=m.public_project) m.private_us1 = f.UserStoryFactory(project=m.private_project1) m.private_us2 = f.UserStoryFactory(project=m.private_project2) m.blocked_us = f.UserStoryFactory(project=m.blocked_project) m.public_related_us = f.RelatedUserStory(epic=m.public_epic, user_story=m.public_us) m.private_related_us1 = f.RelatedUserStory(epic=m.private_epic1, user_story=m.private_us1) m.private_related_us2 = f.RelatedUserStory(epic=m.private_epic2, user_story=m.private_us2) m.blocked_related_us = f.RelatedUserStory(epic=m.blocked_epic, user_story=m.blocked_us) m.public_project.default_epic_status = m.public_epic.status m.public_project.save() m.private_project1.default_epic_status = m.private_epic1.status m.private_project1.save() m.private_project2.default_epic_status = m.private_epic2.status m.private_project2.save() m.blocked_project.default_epic_status = m.blocked_epic.status m.blocked_project.save() return m
def data(): m = type("Models", (object, ), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.public_project = f.ProjectFactory( is_private=False, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)), owner=m.project_owner, tasks_csv_uuid=uuid.uuid4().hex) m.private_project1 = f.ProjectFactory( is_private=True, anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)), public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)), owner=m.project_owner, tasks_csv_uuid=uuid.uuid4().hex) m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner, tasks_csv_uuid=uuid.uuid4().hex) m.public_membership = f.MembershipFactory(project=m.public_project, user=m.project_member_with_perms, role__project=m.public_project, role__permissions=list( map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.private_membership1 = f.MembershipFactory( project=m.private_project1, user=m.project_member_with_perms, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, role__project=m.private_project1, role__permissions=[]) m.private_membership2 = f.MembershipFactory( project=m.private_project2, user=m.project_member_with_perms, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, role__project=m.private_project2, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_owner=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_owner=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_owner=True) milestone_public_task = f.MilestoneFactory(project=m.public_project) milestone_private_task1 = f.MilestoneFactory(project=m.private_project1) milestone_private_task2 = f.MilestoneFactory(project=m.private_project2) m.public_task = f.TaskFactory(project=m.public_project, status__project=m.public_project, milestone=milestone_public_task, user_story__project=m.public_project, user_story__milestone=milestone_public_task) m.private_task1 = f.TaskFactory( project=m.private_project1, status__project=m.private_project1, milestone=milestone_private_task1, user_story__project=m.private_project1, user_story__milestone=milestone_private_task1) m.private_task2 = f.TaskFactory( project=m.private_project2, status__project=m.private_project2, milestone=milestone_private_task2, user_story__project=m.private_project2, user_story__milestone=milestone_private_task2) m.public_project.default_task_status = m.public_task.status m.public_project.save() m.private_project1.default_task_status = m.private_task1.status m.private_project1.save() m.private_project2.default_task_status = m.private_task2.status m.private_project2.save() return m
def data(): m = type("Models", (object,), {}) m.registered_user = f.UserFactory.create() m.project_member_with_perms = f.UserFactory.create() m.project_member_without_perms = f.UserFactory.create() m.project_owner = f.UserFactory.create() m.other_user = f.UserFactory.create() m.superuser = f.UserFactory.create(is_superuser=True) m.public_project = f.ProjectFactory(is_private=False, anon_permissions=['view_project'], public_permissions=['view_project']) m.private_project1 = f.ProjectFactory(is_private=True, anon_permissions=['view_project'], public_permissions=['view_project'], owner=m.project_owner) m.private_project2 = f.ProjectFactory(is_private=True, anon_permissions=[], public_permissions=[], owner=m.project_owner) f.RoleFactory(project=m.public_project) m.membership = f.MembershipFactory(project=m.private_project1, user=m.project_member_with_perms, role__project=m.private_project1, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.membership = f.MembershipFactory(project=m.private_project1, user=m.project_member_without_perms, role__project=m.private_project1, role__permissions=[]) m.membership = f.MembershipFactory(project=m.private_project2, user=m.project_member_with_perms, role__project=m.private_project2, role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS))) m.membership = f.MembershipFactory(project=m.private_project2, user=m.project_member_without_perms, role__project=m.private_project2, role__permissions=[]) f.MembershipFactory(project=m.public_project, user=m.project_owner, is_owner=True) f.MembershipFactory(project=m.private_project1, user=m.project_owner, is_owner=True) f.MembershipFactory(project=m.private_project2, user=m.project_owner, is_owner=True) ContentType = apps.get_model("contenttypes", "ContentType") Project = apps.get_model("projects", "Project") project_ct = ContentType.objects.get_for_model(Project) f.VoteFactory(content_type=project_ct, object_id=m.public_project.pk, user=m.project_member_with_perms) f.VoteFactory(content_type=project_ct, object_id=m.public_project.pk, user=m.project_owner) f.VoteFactory(content_type=project_ct, object_id=m.private_project1.pk, user=m.project_member_with_perms) f.VoteFactory(content_type=project_ct, object_id=m.private_project1.pk, user=m.project_owner) f.VoteFactory(content_type=project_ct, object_id=m.private_project2.pk, user=m.project_member_with_perms) f.VoteFactory(content_type=project_ct, object_id=m.private_project2.pk, user=m.project_owner) f.VotesFactory(content_type=project_ct, object_id=m.public_project.pk, count=2) f.VotesFactory(content_type=project_ct, object_id=m.private_project1.pk, count=2) f.VotesFactory(content_type=project_ct, object_id=m.private_project2.pk, count=2) f.WatchedFactory(content_type=project_ct, object_id=m.public_project.pk, user=m.project_member_with_perms) f.WatchedFactory(content_type=project_ct, object_id=m.public_project.pk, user=m.project_owner) f.WatchedFactory(content_type=project_ct, object_id=m.private_project1.pk, user=m.project_member_with_perms) f.WatchedFactory(content_type=project_ct, object_id=m.private_project1.pk, user=m.project_owner) f.WatchedFactory(content_type=project_ct, object_id=m.private_project2.pk, user=m.project_member_with_perms) f.WatchedFactory(content_type=project_ct, object_id=m.private_project2.pk, user=m.project_owner) return m