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

Add ClientState and tests #40

Merged
merged 7 commits into from
Mar 19, 2020
Merged

Conversation

MatthewDorner
Copy link
Collaborator

Summary

  • Generate random ClientState when creating a new subscription
  • Tests to verify that ClientState is checked for incoming webhooks
  • Fixed bug in mscalendar/notification.go involving conditional call to MakeClient
  • Fixed logging typos

Ticket Link

Fixes #13

@MatthewDorner
Copy link
Collaborator Author

MatthewDorner commented Mar 1, 2020

I had to copy the definition of the webhook struct type into my test since it's defined in the msgraph package (in remote/msgraph/handle_webhook.go) and isn't exported, and I need it for my test remote.Notification object. What's the correct solution to this? Just change it to be exported?

@hanzei hanzei requested a review from mickmister March 2, 2020 12:19
@hanzei hanzei added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Mar 2, 2020
@mickmister
Copy link
Contributor

I had to copy the definition of the webhook struct type into my test since it's defined in the msgraph package (in remote/msgraph/handle_webhook.go) and isn't exported, and I need it for my test remote.Notification object. What's the correct solution to this? Just change it to be exported?

@MatthewDorner We can create a mock of remote.Notification to be used in the tests. We will need to add a line here to generate the mock, then run make mock in your terminal. Then we can use the mock in tests.

Example init

Example usage

@MatthewDorner
Copy link
Collaborator Author

Never mind, I guess I didn't even need that field for my test.

@MatthewDorner
Copy link
Collaborator Author

MatthewDorner commented Mar 2, 2020

Should I also be using MockLogger in the test? It's outputting log messages into the test output, so I'm guessing I should mock it. I just used &bot.TestLogger{TB: t} since I saw it in other tests.

EDIT: Or bot.NilLogger?

@mickmister
Copy link
Contributor

@MatthewDorner I would say that you don't need to mock it unless you want to check the logger's output. This can cause brittle tests that need to be unnecessarily updated if there are more logging additions later.

I think the difference between TestLogger and NilLogger is whether or not you want the logs to show up in the test run's output. 0/5 NilLogger sounds like a fine choice.

Copy link
Contributor

@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.

@MatthewDorner Great job on implementing this! No functional issues found, mostly just some suggestions on tests.

server/mscalendar/notification_test.go Outdated Show resolved Hide resolved
server/mscalendar/notification_test.go Outdated Show resolved Hide resolved
server/mscalendar/notification_test.go Outdated Show resolved Hide resolved
server/mscalendar/notification_test.go Outdated Show resolved Hide resolved
server/mscalendar/notification_test.go Outdated Show resolved Hide resolved
server/remote/msgraph/subscription.go Outdated Show resolved Hide resolved
@mickmister mickmister requested a review from levb March 4, 2020 23:36
server/remote/msgraph/subscription.go Show resolved Hide resolved
@MatthewDorner
Copy link
Collaborator Author

Anything else needed for this PR? I believe all requested changes should be addressed.

Copy link
Contributor

@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.

@MatthewDorner Thanks for addressing the testing concerns, LGTM!

@mickmister
Copy link
Contributor

@DHaussermann Testing here will be a smoke test for setting up a subscription and verifying that we can successfully process a notification.

@mickmister mickmister removed the 2: Dev Review Requires review by a core committer label Mar 10, 2020
@mickmister
Copy link
Contributor

/update-branch

@mickmister
Copy link
Contributor

@DHaussermann I think we're good to merge this and test on master

Copy link

@DHaussermann DHaussermann left a comment

Choose a reason for hiding this comment

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

Agreed. Thanks @mickmister
This can be covered with smoke testing post merge.

@DHaussermann DHaussermann added QA Review Done PR has been approved by QA and removed 3: QA Review Requires review by a QA tester labels Mar 18, 2020
@mickmister mickmister added the 4: Reviews Complete All reviewers have approved the pull request label Mar 19, 2020
@mickmister mickmister merged commit 4ad02af into mattermost:master Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request QA Review Done PR has been approved by QA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate cilentState (a secret) when a new subscription is created
6 participants