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

[GH-744] Add --include-only-org-members flag for channel subscriptions #797

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

burakcakirel
Copy link

Summary

This PR adds --include-only-org-members flag for channel subscriptions

Ticket Link

Fixes #744

@mattermost-build
Copy link
Contributor

Hello @burakcakirel,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

Per the Mattermost Contribution Guide, we need to add you to the list of approved contributors for the Mattermost project.

Please help complete the Mattermost contribution license agreement?
Once you have signed the CLA, please comment with /check-cla and confirm that the CLA check is green.

This is a standard procedure for many open source projects.

Please let us know if you have any questions.

We are very happy to have you join our growing community! If you're not yet a member, please consider joining our Contributors community channel to meet other contributors and discuss new opportunities with the core team.

…e-only-org-members

# Conflicts:
#	README.md
#	server/plugin/webhook.go
Copy link
Member

@mickmister mickmister left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution @burakcakirel! I have just a few comments. LGTM 👍

@@ -350,6 +350,20 @@ func (p *Plugin) excludeConfigOrgMember(user *github.User, subscription *Subscri
return p.isUserOrganizationMember(githubClient, user, organization)
}

func (p *Plugin) includeOnlyConfigOrgMembers(user *github.User, subscription *Subscription) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func (p *Plugin) includeOnlyConfigOrgMembers(user *github.User, subscription *Subscription) bool {
func (p *Plugin) shouldDenyEventDueToNotOrgMember(user *github.User, subscription *Subscription) bool {

Copy link
Author

Choose a reason for hiding this comment

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

Done 👍 23c44b9

Flags: SubscriptionFlags{IncludeOnlyOrgMembers: true},
},
expectWarn: true,
want: false,
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for these tests @burakcakirel 👍 Can we have one that tests the happy path of want: true?

Copy link
Author

Choose a reason for hiding this comment

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

I've tried to test that case but couldn't because the code is unsuitable for testing. I couldn't mock the GetGitHubClient method. Then I've tried to write feature tests for this by mimicking the Jira Plugin tests but couldn't do it again because postIssueEvent method doesn't return anything like in Jira Plugin's PostToChannel method. Hence, this prevents to write a test for this method. Here is the gist file of the tests I've tried to achieve:
https://gist.github.com/burakcakirel/bf8c3da4b67893b70d9871e5032674ae#file-webhook_test-go-L170

return false
}

return !p.isUserOrganizationMember(githubClient, user, p.getConfiguration().GitHubOrg)
Copy link
Member

Choose a reason for hiding this comment

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

Just for readability to have the success state obvious at the bottom of the function

Suggested change
return !p.isUserOrganizationMember(githubClient, user, p.getConfiguration().GitHubOrg)
if !p.isUserOrganizationMember(githubClient, user, p.getConfiguration().GitHubOrg) {
return false
}
return true

Copy link
Author

Choose a reason for hiding this comment

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

Done 👍 f77d0fa

@mickmister mickmister added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Jul 4, 2024
@hanzei hanzei removed their request for review July 5, 2024 05:12
@mattermost-build
Copy link
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

@wiggin77
Copy link
Member

@raghavaggarwal2308 can this be QA'd before merge?

@mattermost-build
Copy link
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester Contributor Lifecycle/1:stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support --include-only-org-members for channel subscriptions
4 participants