Skip to content
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

Update permissions #2661

Merged
merged 43 commits into from
Mar 8, 2023
Merged

Update permissions #2661

merged 43 commits into from
Mar 8, 2023

Conversation

notauserx
Copy link
Contributor

@notauserx notauserx commented Jan 23, 2023

Resolves #2323


Behavior

Before the change?

  • App Installations and Collaborators endpoints do not contain the correct permissions on the request and response contracts.

After the change?

  • Permissions are updated to match GitHub's open API specs

Additional info

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Added the appropriate label for the given change

Does this introduce a breaking change?

  • Yes (Please add the Type: Breaking change label)
  • No

If Yes, what's the impact:

  • Permissions have been updated for App Installation and Collaborator endpoints to match the updated spec

Pull request type

  • Bugfix: Type: Bug Type: Breaking Change

@notauserx notauserx changed the title Update permissions [wip] Update permissions Jan 23, 2023
@notauserx
Copy link
Contributor Author

There are some integration tests failing for IRepoCollaboratorsClient's GetAll method. The tests are adding a collaborator and expecting the collaborator count to be updated. However, adding a collaborator will send an invitation and the collaborator has to accept the invitation before the count will be updated.

The integration tests for ReviewPermission also follow the same route, a collaborator is added with 'write' permission and the test expects a collaborator with 'write' permission, without waiting for the collaborator to accept the invitation.

In these tests octokitnet-test1 and m-zuber-octokit-integration-tests accounts are used for adding a collaborator, and I don't have their creds to accept the invitation.

This probably is out of scope for this issue, but we probably should create a new issue and think about possible workarounds.

For app installation permissions, there are some permissions that have only 'read' as a value, some have only 'write', most with 'read' and 'write', and some with 'read', 'write' and 'admin'.

I have named the enums InstallationReadPermissionLevel, InstallationWritePermissionLevel, InstallationReadWritePermissionLevel, and InstallationReadWriteAdminPermissionLevel respectively.

I have also moved the Permission.cs to the common folder because it houses all the permissions from the API surface.

@kfcampbell
Copy link
Member

@notauserx is the [wip] description in the PR still valid?

@notauserx
Copy link
Contributor Author

@kfcampbell I have completed updating all references the old Permission enums and made them context-specific. I was also planning to update some endpoints that use the updated permission in request/response.

However, the integration tests are failing for some of these endpoints, as I've mentioned in my previous comments. I do need some feedback on how to proceed.

@kfcampbell
Copy link
Member

The integration testing question with the invites is a tough one. As far as I know, we don't have a convenient way to do that. I'll have to think about that more and ask my team.

@nickfloyd
Copy link
Contributor

nickfloyd commented Feb 6, 2023

Hey @notauserx, Thanks again for these contributions ❤️ . As you've detailed above, we need to rethink some of the strategies in our integration tests. I cannot be 100% certain, but the workflow for the ones you referenced has changed since they were originally implemented.

We have a few options here:

  1. We can skip to unblock this by adding the skip attribute i.e., [Fact(Skip = "Reference to this PR")]. That will give us more time to figure out what we want to do without looking at code context clues or outright deleting them.
  2. We can delete the tests, looking at the ones here some of these seems a bit contrived and fragile (as you discovered).
  3. We can see if there is an alternate strategy and implement that - at its most basic, GetAll could check for something else or check that it pulled back the one contributor it already has.
  4. We could rework things so that it is dependent on less fragile and more public fixtures - though I think we'd probably still run into what you are running into around account access.

I don't want to get into philosophical aspects of how useful functional tests are - especially since there is already pretty good unit test coverage on RepoCollaboratorsClient, for instance - so I'll leave the decision on how to proceed up to you. We trust your judgment. I see this as a valuable change and would like to get it in.

I appreciate you highlighting this fragile part of this SDK's coverage. We're working daily to try to improve this for everyone, and I'm glad you've decided to come alongside us and do the same ❤️ !

@notauserx
Copy link
Contributor Author

@nickfloyd thank you for sharing your thoughts. Among the options you suggested, I am more biased toward either removing or skipping the failing tests.

I do understand that with GitHub updating their REST APIs, there will be times when this SDK gets out of sync, and with breaking changes and workflow updates some workflows do get outdated.

I will think through your suggestions and incorporate them into this PR, which I plan to resume next week.

And for the contributions, I am glad to offer my PRs.

@notauserx notauserx changed the title [wip] Update permissions Update permissions Feb 14, 2023
@notauserx
Copy link
Contributor Author

This PR is now ready for review. Please give me some feedback and I will update the PR accordingly.

Copy link
Contributor

@nickfloyd nickfloyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for getting this in ❤️

@nickfloyd nickfloyd added Priority: Normal Type: Feature New feature or request labels Mar 8, 2023
@nickfloyd nickfloyd merged commit 1300427 into octokit:main Mar 8, 2023
@notauserx notauserx deleted the update-permissions branch March 8, 2023 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Team model uses wrong Permission enum
3 participants