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

Annotate captcha assessments #1043

Merged
merged 9 commits into from
Jun 26, 2024

Conversation

rajivnathan
Copy link
Contributor

@rajivnathan rajivnathan commented Jun 18, 2024

https://issues.redhat.com/browse/SANDBOX-626

Adds logic to the usersignup controller to annotate a previous captcha assessment when a user is banned or unbanned.

When a user is banned the assessment is annotated as FRAUDULENT and if a user was banned mistakenly and approved again then it is annotated as LEGITIMATE.

Added configuration setup for recaptcha client to work: d0e0d02
I tested it on a dev cluster and it worked.

Added unit tests: 80ccd44

// shouldAnnotateCaptchaAssessment determines whether the previous assessment should be annotated
// returns LEGITIMATE or FRAUDULENT if the assessment should be annotated
// returns ANNOTATION_UNSPECIFIED otherwise
func (r *Reconciler) shouldAnnotateCaptchaAssessment(userSignup *toolchainv1alpha1.UserSignup, newState string) recaptchapb.AnnotateAssessmentRequest_Annotation {
Copy link
Contributor

Choose a reason for hiding this comment

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

The function name is a bit misleading, isn't it? It doesn't determine if it should be annotated or not but rather always returns a new/expected assessment annotation, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was using ANNOTATION_UNSPECIFIED as the base case where we don't actually do the annotation. In the other function we check whether it's ANNOTATION_UNSPECIFIED and if so we skip annotating the assessment. But I'm fine to change it if it's confusing. Do you have a suggestion to make it more clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed the function to getCaptchaAssessmentAnnotation, let me know if you think another name would be better

controllers/usersignup/usersignup_controller.go Outdated Show resolved Hide resolved
controllers/usersignup/usersignup_controller.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jun 25, 2024

Codecov Report

Attention: Patch coverage is 75.38462% with 16 lines in your changes missing coverage. Please review.

Project coverage is 84.85%. Comparing base (8bf5cf5) to head (a8b3ca6).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1043      +/-   ##
==========================================
+ Coverage   84.83%   84.85%   +0.02%     
==========================================
  Files          55       55              
  Lines        4919     4972      +53     
==========================================
+ Hits         4173     4219      +46     
- Misses        572      580       +8     
+ Partials      174      173       -1     
Files Coverage Δ
controllers/toolchainconfig/configuration.go 92.63% <100.00%> (+0.63%) ⬆️
controllers/usersignup/usersignup_controller.go 76.01% <68.62%> (+0.57%) ⬆️

Copy link
Contributor

@alexeykazakov alexeykazakov left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks!

Copy link

openshift-ci bot commented Jun 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexeykazakov, rajivnathan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [alexeykazakov,rajivnathan]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rajivnathan rajivnathan merged commit e48a299 into codeready-toolchain:master Jun 26, 2024
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants