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

Fix coalesced Team permission property #361

Merged
merged 2 commits into from
Dec 15, 2022

Conversation

HowardWolosky
Copy link
Member

@HowardWolosky HowardWolosky commented Jul 26, 2022

Description

When retrieving the permissions granted to a team for a repository, the API returns an array of booleans indicating what individual permissions the team currently has.

name permissions granted
pull pull
triage pull, triage
push pull, triage, push
maintain pull, triage, push, maintain
admin pull, triage, push, maintain, admin

As you can see, each permissions builds on top of the previous
permission. When adding extra properties to this returned object
via Add-GitHubRepositoryTeamPermissionAdditionalProperties, we
also add a new permission property that attempts to represent the
collection of permissions with their current top-permission level.

The logic however incorrectly favored push over maintain and thus
would always said that a Team had push permission when in fact it
may have actually had maintain permission.

This simple change corrects that ordering mistake.

Issues Fixed

Fixes #360

References

Check team permissions for a repository

Checklist

  • You actually ran the code that you just wrote, especially if you did just "one last quick change".
  • Comment-based help added/updated, including examples.
  • Static analysis is reporting back clean.
  • New/changed code adheres to our coding guidelines.
  • Formatters were created for any new types being added.
  • New/changed code continues to support the pipeline.
  • Changes to the manifest file follow the manifest guidance.
  • Unit tests were added/updated and are all passing. See testing guidelines. This includes making sure that all pipeline input variations have been covered.
  • Relevant usage examples have been added/updated in USAGE.md.
  • If desired, ensure your name is added to our Contributors list

When retrieving the permissions granted to a team for a repository,
the API returns an array of booleans indicating what individual
permissions the team currently has.

| name | permissions granted |
| ---- | ------------------ |
| pull | pull |
| triage | pull, triage |
| push | pull, triage, push |
| maintain | pull, triage, push, maintain |
| admin | pull, triage, push, maintain, admin |

As you can see, each permissions builds on top of the previous
permission.  When adding extra properties to this returned object
via `Add-GitHubRepositoryTeamPermissionAdditionalProperties`, we
also add a new `permission` property that attempts to represent the
collection of permissions with their current top-permission level.

The logic however incorrectly favored `push` over `maintain` and thus
would always said that a Team had `push` permission when in fact it
may have actually had `maintain` permission.

This simple change corrects that ordering mistake.
@HowardWolosky HowardWolosky added bug This relates to a bug in the existing module. api-repositories Work to complete the API's defined here: https://developer.github.com/v3/repos/ labels Jul 26, 2022
@HowardWolosky HowardWolosky merged commit d8ee50a into microsoft:master Dec 15, 2022
@HowardWolosky HowardWolosky deleted the fixTeamsPermission branch December 15, 2022 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-repositories Work to complete the API's defined here: https://developer.github.com/v3/repos/ bug This relates to a bug in the existing module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get-GitHubRepositoryTeamPermission incorrectly reports push permission when maintain is available
1 participant