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

#2697 captcha to feedback from submission #2792

Merged
merged 18 commits into from
Sep 1, 2022
3 changes: 0 additions & 3 deletions verification/curator-service/api/src/controllers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {
resetPasswordWithTokenLimiter,
} from '../util/single-window-rate-limiters';


// Global variable for newsletter acceptance
let isNewsletterAccepted: boolean;

Expand Down Expand Up @@ -223,7 +222,6 @@ export class AuthController {
"Unfortunately, you didn't pass the captcha. Please, try again later.",
});


passport.authenticate(
'register',
(error: Error, user: IUser, info: any) => {
Expand Down Expand Up @@ -261,7 +259,6 @@ export class AuthController {
"Unfortunately, you didn't pass the captcha. Please, try again later.",
});


passport.authenticate(
'login',
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ describe('<AcknowledgmentsPage />', function () {
response: 'fixture:acknowledgment_data.json',
delay: 3000,
}).as('fetchSources');

cy.visit('/data-acknowledgments');
cy.contains(/Data Acknowledgments/i);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ describe('LandingPage', function () {
cy.get('#password').type('tT$5aaaaak');
cy.get('#passwordConfirmation').type('tT$5aaaaak');
cy.get('#isAgreementChecked').check();
for (let i = 0; i < 5; i++) {
for (let i = 0; i < 7; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why is the Sign-in button being clicked so many times?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is clicked so many times to trigger the login/register limiter that will be used after 4 unsuccessful attempts. I will change the number of clicks to the previous commit which is 5 times.

// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1500);
cy.get('button[data-testid="sign-up-button"]').click();
}
cy.contains(
Expand All @@ -228,7 +230,9 @@ describe('LandingPage', function () {
cy.contains('Sign in!').click();
cy.get('#email').type('test@example.com');
cy.get('#password').type('test');
for (let i = 0; i < 5; i++) {
for (let i = 0; i < 7; i++) {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1500);
cy.get('button[data-testid="sign-in-button"]').click();
}
cy.contains(/Too many failed login attempts, please try again later/i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('New case form', function () {
});
cy.addSource('Test source', 'www.example.com');

cy.visit('/')
cy.visit('/');
cy.visit('/cases/new');
cy.contains('Create new COVID-19 line list case');
cy.get('div[data-testid="caseReference"]').type('www.example.com');
Expand Down Expand Up @@ -51,7 +51,7 @@ describe('New case form', function () {
geoResolution: 'Country',
});

cy.visit('/')
cy.visit('/');
cy.visit('/cases/new');
cy.contains('Create new COVID-19 line list case');
cy.get('div[data-testid="caseReference"]').type('www.new-source.com');
Expand All @@ -74,7 +74,7 @@ describe('New case form', function () {
cy.contains('France');
cy.contains('2020-01-01');

cy.visit('/')
cy.visit('/');
cy.visit('/sources');
cy.contains('www.new-source.com');
cy.contains('New source');
Expand All @@ -90,7 +90,7 @@ describe('New case form', function () {
});
cy.addSource('Test source', 'www.example.com');

cy.visit('/')
cy.visit('/');
cy.visit('/cases/new');
cy.contains('Create new COVID-19 line list case');
cy.get('div[data-testid="caseReference"]').type('www.example.com');
Expand All @@ -111,7 +111,7 @@ describe('New case form', function () {
});

it('Can submit events without dates', function () {
cy.visit('/')
cy.visit('/');
cy.visit('/cases');
cy.contains('No records to display');
cy.seedLocation({
Expand All @@ -122,7 +122,7 @@ describe('New case form', function () {
});
cy.addSource('Test source', 'www.example.com');

cy.visit('/')
cy.visit('/');
cy.visit('/cases/new');
cy.get('div[data-testid="caseReference"]').type('www.example.com');
cy.contains('li', 'www.example.com').click();
Expand Down Expand Up @@ -164,7 +164,7 @@ describe('New case form', function () {
});
cy.addSource('Test source', 'www.example.com');

cy.visit('/')
cy.visit('/');
cy.visit('/cases/new');
cy.contains('Create new COVID-19 line list case');
cy.get('div[data-testid="caseReference"]').type('www.example.com');
Expand Down Expand Up @@ -246,7 +246,7 @@ describe('New case form', function () {
symptoms: ['fever', 'cough'],
});

cy.visit('/')
cy.visit('/');
cy.visit('/cases/new');
cy.contains('Create new COVID-19 line list case');
cy.get('div[data-testid="caseReference"]').type('www.example.com');
Expand Down Expand Up @@ -301,11 +301,11 @@ describe('New case form', function () {
geoResolution: 'Country',
});
cy.addSource('Test source', 'www.example.com');
cy.visit('/')
cy.visit('/');
cy.visit('/cases');
cy.contains('No records to display');

cy.visit('/')
cy.visit('/');
cy.visit('/cases/new');
cy.get('div[data-testid="caseReference"]').type('www.example.com');
cy.contains('li', 'www.example.com').click();
Expand All @@ -330,7 +330,7 @@ describe('New case form', function () {
});

it('Can change source URL without changing source name', function () {
cy.visit('/')
cy.visit('/');
cy.visit('/cases/new');

cy.get('div[data-testid="caseReference"]').type('www.example.com');
Expand All @@ -345,14 +345,14 @@ describe('New case form', function () {
});

it('Check for required fields', function () {
cy.visit('/')
cy.visit('/');
cy.visit('/cases/new');

cy.get('p:contains("Required")').should('have.length', 3);
});

it('Shows checkbox on field completion', function () {
cy.visit('/')
cy.visit('/');
cy.visit('/cases/new');
cy.get('svg[data-testid="check-icon"]').should('not.exist');
cy.get('div[data-testid="gender"]').click();
Expand All @@ -361,7 +361,7 @@ describe('New case form', function () {
});

it('Shows error icon on field submission error', function () {
cy.visit('/')
cy.visit('/');
cy.visit('/cases/new');
cy.get('svg[data-testid="error-icon"]').should('not.exist');
cy.get('svg[data-testid="check-icon"]').should('not.exist');
Expand Down
3 changes: 2 additions & 1 deletion verification/curator-service/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"cypress-open": "cypress open",
"cypress-run": "cypress run",
"cypress-run-ff": "cypress run --browser firefox",
"cypress-run-edge": "cypress run --browser edge"
"cypress-run-edge": "cypress run --browser edge",
"cypress-run-chrome": "cypress run --headless --browser chrome"
},
"eslintConfig": {
"extends": "react-app"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ const FeedbackEmailDialog = ({
},
});

// -------------------
// isOpen = true;
// -------------------
return (
<>
<Dialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ interface SignInFormProps {
setRegistrationScreenOn: (active: boolean) => void;
}

const RECAPTCHA_SITE_KEY = process.env.RECAPTCHA_SITE_KEY as string;
const RECAPTCHA_SITE_KEY = window.Cypress
? '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
Copy link
Contributor

Choose a reason for hiding this comment

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

is this supposed to be secret? not sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your feedback! That's a great question. It is a ReCaptchas site-key for testing purposes which is available for all developers: https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha.-what-should-i-do Since every developer have access to it and it is the same for everyone I didn't set it as a secret.

: (process.env.RECAPTCHA_SITE_KEY as string);

export default function SignInForm({
disabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { sendCustomGtmEvent } from '../util/helperFunctions';
import ReCAPTCHA from 'react-google-recaptcha';
import PasswordStrengthBar from 'react-password-strength-bar';


const useStyles = makeStyles((theme: Theme) => ({
checkboxRoot: {
display: 'block',
Expand Down Expand Up @@ -93,7 +92,9 @@ interface SignUpFormProps {
setRegistrationScreenOn: (active: boolean) => void;
}

const RECAPTCHA_SITE_KEY = process.env.RECAPTCHA_SITE_KEY as string;
const RECAPTCHA_SITE_KEY = window.Cypress
? '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

: (process.env.RECAPTCHA_SITE_KEY as string);

export default function SignUpForm({
disabled,
Expand Down Expand Up @@ -166,7 +167,6 @@ export default function SignUpForm({
const token =
(await recaptchaRef.current.executeAsync()) as string;
recaptchaRef.current.reset();

dispatch(
signUpWithEmailAndPassword({
email,
Expand Down