-
Notifications
You must be signed in to change notification settings - Fork 980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow marking projects as "archived" #17005
Open
facutuesca
wants to merge
5
commits into
pypi:main
Choose a base branch
from
trail-of-forks:add-archived-project-status
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2c2853b
feat: allow marking projects as archived
facutuesca 83193e3
disallow uploads on archived projects
facutuesca ce387c2
remove dead code
facutuesca 2f3fa08
move archive functions
facutuesca 5f07641
add admin UI to archive/unarchive projects
facutuesca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -365,6 +365,100 @@ def test_acl_for_quarantined_project(self, db_session): | |||||||
key=lambda x: x[1], | ||||||||
) | ||||||||
|
||||||||
def test_acl_for_archived_project(self, db_session): | ||||||||
""" | ||||||||
If a Project is archived, the Project ACL should disallow uploads. | ||||||||
""" | ||||||||
project = DBProjectFactory.create(lifecycle_status="archived") | ||||||||
owner1 = DBRoleFactory.create(project=project) | ||||||||
owner2 = DBRoleFactory.create(project=project) | ||||||||
|
||||||||
# Maintainers should not appear in the ACLs, since they only have | ||||||||
# upload permissions, and anchived projects don't allow upload | ||||||||
DBRoleFactory.create(project=project, role_name="Maintainer") | ||||||||
DBRoleFactory.create(project=project, role_name="Maintainer") | ||||||||
Comment on lines
+378
to
+379
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor optimization, useful if same params and return value not used
Suggested change
|
||||||||
|
||||||||
organization = DBOrganizationFactory.create() | ||||||||
owner3 = DBOrganizationRoleFactory.create(organization=organization) | ||||||||
DBOrganizationProjectFactory.create(organization=organization, project=project) | ||||||||
|
||||||||
team = DBTeamFactory.create() | ||||||||
owner4 = DBTeamRoleFactory.create(team=team) | ||||||||
DBTeamProjectRoleFactory.create( | ||||||||
team=team, project=project, role_name=TeamProjectRoleType.Owner | ||||||||
) | ||||||||
|
||||||||
# Publishers should not appear in the ACLs, since they only have upload | ||||||||
# permissions, and archived projects don't allow upload | ||||||||
GitHubPublisherFactory.create(projects=[project]) | ||||||||
|
||||||||
acls = [] | ||||||||
for location in lineage(project): | ||||||||
try: | ||||||||
acl = location.__acl__ | ||||||||
except AttributeError: | ||||||||
continue | ||||||||
|
||||||||
if acl and callable(acl): | ||||||||
acl = acl() | ||||||||
|
||||||||
acls.extend(acl) | ||||||||
|
||||||||
_perms_read_and_write = [ | ||||||||
Permissions.ProjectsRead, | ||||||||
Permissions.ProjectsWrite, | ||||||||
] | ||||||||
assert acls == [ | ||||||||
( | ||||||||
Allow, | ||||||||
"group:admins", | ||||||||
( | ||||||||
Permissions.AdminDashboardSidebarRead, | ||||||||
Permissions.AdminObservationsRead, | ||||||||
Permissions.AdminObservationsWrite, | ||||||||
Permissions.AdminProhibitedProjectsWrite, | ||||||||
Permissions.AdminProhibitedUsernameWrite, | ||||||||
Permissions.AdminProjectsDelete, | ||||||||
Permissions.AdminProjectsRead, | ||||||||
Permissions.AdminProjectsSetLimit, | ||||||||
Permissions.AdminProjectsWrite, | ||||||||
Permissions.AdminRoleAdd, | ||||||||
Permissions.AdminRoleDelete, | ||||||||
), | ||||||||
), | ||||||||
( | ||||||||
Allow, | ||||||||
"group:moderators", | ||||||||
( | ||||||||
Permissions.AdminDashboardSidebarRead, | ||||||||
Permissions.AdminObservationsRead, | ||||||||
Permissions.AdminObservationsWrite, | ||||||||
Permissions.AdminProjectsRead, | ||||||||
Permissions.AdminProjectsSetLimit, | ||||||||
Permissions.AdminRoleAdd, | ||||||||
Permissions.AdminRoleDelete, | ||||||||
), | ||||||||
), | ||||||||
( | ||||||||
Allow, | ||||||||
"group:observers", | ||||||||
Permissions.APIObservationsAdd, | ||||||||
), | ||||||||
( | ||||||||
Allow, | ||||||||
Authenticated, | ||||||||
Permissions.SubmitMalwareObservation, | ||||||||
), | ||||||||
] + sorted( | ||||||||
[ | ||||||||
(Allow, f"user:{owner1.user.id}", _perms_read_and_write), | ||||||||
(Allow, f"user:{owner2.user.id}", _perms_read_and_write), | ||||||||
(Allow, f"user:{owner3.user.id}", _perms_read_and_write), | ||||||||
(Allow, f"user:{owner4.user.id}", _perms_read_and_write), | ||||||||
], | ||||||||
key=lambda x: x[1], | ||||||||
) | ||||||||
|
||||||||
def test_repr(self, db_request): | ||||||||
project = DBProjectFactory() | ||||||||
assert isinstance(repr(project), str) | ||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: