Commit 6df27e86 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'cablett-consistent-recaptcha' into 'master'

Make reCAPTCHA consistent

Closes #214740

See merge request gitlab-org/gitlab!29755
parents 334ad7b8 f5917674
......@@ -24,7 +24,7 @@ module Spam
def execute(api: false, recaptcha_verified:, spam_log_id:, user_id:)
if recaptcha_verified
# If it's a request which is already verified through recaptcha,
# If it's a request which is already verified through reCAPTCHA,
# update the spam log accordingly.
SpamLog.verify_recaptcha!(user_id: user_id, id: spam_log_id)
else
......
......@@ -30,7 +30,7 @@ describe RegistrationsController do
end
end
context 'when recaptcha experiment enabled' do
context 'when reCAPTCHA experiment enabled' do
it "logs a 'User Created' message including the experiment state" do
user_params = { user: attributes_for(:user) }
allow_any_instance_of(EE::RecaptchaExperimentHelper).to receive(:show_recaptcha_sign_up?).and_return(true)
......
......@@ -752,7 +752,7 @@ describe Projects::IssuesController do
expect { update_issue }.not_to change { issue.reload.title }
end
it 'rejects an issue recognized as a spam when recaptcha disabled' do
it 'rejects an issue recognized as a spam when reCAPTCHA disabled' do
stub_application_setting(recaptcha_enabled: false)
expect { update_issue }.not_to change { issue.reload.title }
......@@ -811,7 +811,7 @@ describe Projects::IssuesController do
expect(response).to have_gitlab_http_status(:ok)
end
it 'accepts an issue after recaptcha is verified' do
it 'accepts an issue after reCAPTCHA is verified' do
expect { update_verified_issue }.to change { issue.reload.title }.to(spammy_title)
end
......@@ -1017,7 +1017,7 @@ describe Projects::IssuesController do
expect { post_new_issue(title: '') }.not_to change(Issue, :count)
end
it 'does not create an issue when recaptcha is not enabled' do
it 'does not create an issue when reCAPTCHA is not enabled' do
stub_application_setting(recaptcha_enabled: false)
expect { post_spam_issue }.not_to change(Issue, :count)
......@@ -1052,7 +1052,7 @@ describe Projects::IssuesController do
expect(controller).to receive_messages(verify_recaptcha: true)
end
it 'accepts an issue after recaptcha is verified' do
it 'accepts an issue after reCAPTCHA is verified' do
expect { post_verified_issue }.to change(Issue, :count)
end
......
......@@ -127,7 +127,7 @@ describe Projects::SnippetsController do
.to log_spam(title: 'Title', user_id: user.id, noteable_type: 'ProjectSnippet')
end
it 'renders :new with recaptcha disabled' do
it 'renders :new with reCAPTCHA disabled' do
stub_application_setting(recaptcha_enabled: false)
create_snippet(project, visibility_level: Snippet::PUBLIC)
......@@ -135,18 +135,18 @@ describe Projects::SnippetsController do
expect(response).to render_template(:new)
end
context 'recaptcha enabled' do
context 'reCAPTCHA enabled' do
before do
stub_application_setting(recaptcha_enabled: true)
end
it 'renders :verify with recaptcha enabled' do
it 'renders :verify with reCAPTCHA enabled' do
create_snippet(project, visibility_level: Snippet::PUBLIC)
expect(response).to render_template(:verify)
end
it 'renders snippet page when recaptcha verified' do
it 'renders snippet page when reCAPTCHA verified' do
spammy_title = 'Whatever'
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
......@@ -223,7 +223,7 @@ describe Projects::SnippetsController do
.to log_spam(title: 'Foo', user_id: user.id, noteable_type: 'ProjectSnippet')
end
it 'renders :edit with recaptcha disabled' do
it 'renders :edit with reCAPTCHA disabled' do
stub_application_setting(recaptcha_enabled: false)
update_snippet(title: 'Foo')
......@@ -231,18 +231,18 @@ describe Projects::SnippetsController do
expect(response).to render_template(:edit)
end
context 'recaptcha enabled' do
context 'reCAPTCHA enabled' do
before do
stub_application_setting(recaptcha_enabled: true)
end
it 'renders :verify with recaptcha enabled' do
it 'renders :verify with reCAPTCHA enabled' do
update_snippet(title: 'Foo')
expect(response).to render_template(:verify)
end
it 'renders snippet page when recaptcha verified' do
it 'renders snippet page when reCAPTCHA verified' do
spammy_title = 'Whatever'
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
......@@ -268,7 +268,7 @@ describe Projects::SnippetsController do
.to log_spam(title: 'Foo', user_id: user.id, noteable_type: 'ProjectSnippet')
end
it 'renders :edit with recaptcha disabled' do
it 'renders :edit with reCAPTCHA disabled' do
stub_application_setting(recaptcha_enabled: false)
update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC)
......@@ -276,18 +276,18 @@ describe Projects::SnippetsController do
expect(response).to render_template(:edit)
end
context 'recaptcha enabled' do
context 'reCAPTCHA enabled' do
before do
stub_application_setting(recaptcha_enabled: true)
end
it 'renders :verify with recaptcha enabled' do
it 'renders :verify' do
update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC)
expect(response).to render_template(:verify)
end
it 'renders snippet page when recaptcha verified' do
it 'renders snippet page' do
spammy_title = 'Whatever'
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
......
......@@ -139,7 +139,7 @@ describe RegistrationsController do
expect(flash[:alert]).to eq(_('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'))
end
it 'redirects to the dashboard when the recaptcha is solved' do
it 'redirects to the dashboard when the reCAPTCHA is solved' do
post(:create, params: user_params)
expect(flash[:notice]).to eq(I18n.t('devise.registrations.signed_up'))
......
......@@ -318,7 +318,7 @@ describe SnippetsController do
.to log_spam(title: 'Title', user: user, noteable_type: 'PersonalSnippet')
end
it 'renders :new with recaptcha disabled' do
it 'renders :new with reCAPTCHA disabled' do
stub_application_setting(recaptcha_enabled: false)
create_snippet(visibility_level: Snippet::PUBLIC)
......@@ -326,18 +326,18 @@ describe SnippetsController do
expect(response).to render_template(:new)
end
context 'recaptcha enabled' do
context 'reCAPTCHA enabled' do
before do
stub_application_setting(recaptcha_enabled: true)
end
it 'renders :verify with recaptcha enabled' do
it 'renders :verify' do
create_snippet(visibility_level: Snippet::PUBLIC)
expect(response).to render_template(:verify)
end
it 'renders snippet page when recaptcha verified' do
it 'renders snippet page' do
spammy_title = 'Whatever'
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
......@@ -403,7 +403,7 @@ describe SnippetsController do
.to log_spam(title: 'Foo', user: user, noteable_type: 'PersonalSnippet')
end
it 'renders :edit with recaptcha disabled' do
it 'renders :edit with reCAPTCHA disabled' do
stub_application_setting(recaptcha_enabled: false)
update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC)
......@@ -411,18 +411,18 @@ describe SnippetsController do
expect(response).to render_template(:edit)
end
context 'recaptcha enabled' do
context 'reCAPTCHA enabled' do
before do
stub_application_setting(recaptcha_enabled: true)
end
it 'renders :verify with recaptcha enabled' do
it 'renders :verify' do
update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC)
expect(response).to render_template(:verify)
end
it 'renders snippet page when recaptcha verified' do
it 'renders snippet page when reCAPTCHA verified' do
spammy_title = 'Whatever'
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
......@@ -446,7 +446,7 @@ describe SnippetsController do
.to log_spam(title: 'Foo', user: user, noteable_type: 'PersonalSnippet')
end
it 'renders :edit with recaptcha disabled' do
it 'renders :edit with reCAPTCHA disabled' do
stub_application_setting(recaptcha_enabled: false)
update_snippet(title: 'Foo')
......@@ -459,13 +459,13 @@ describe SnippetsController do
stub_application_setting(recaptcha_enabled: true)
end
it 'renders :verify with recaptcha enabled' do
it 'renders :verify' do
update_snippet(title: 'Foo')
expect(response).to render_template(:verify)
end
it 'renders snippet page when recaptcha verified' do
it 'renders snippet page when reCAPTCHA verified' do
spammy_title = 'Whatever'
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
......
......@@ -103,8 +103,8 @@ describe 'New issue', :js do
click_button 'Submit issue'
# it is impossible to test recaptcha automatically and there is no possibility to fill in recaptcha
# recaptcha verification is skipped in test environment and it always returns true
# it is impossible to test reCAPTCHA automatically and there is no possibility to fill in recaptcha
# reCAPTCHA verification is skipped in test environment and it always returns true
expect(page).not_to have_content('issue title')
expect(page).to have_css('.recaptcha')
......
......@@ -40,13 +40,13 @@ shared_examples_for 'snippet editor' do
end
end
shared_examples 'solve recaptcha' do
it 'creates a snippet after solving reCaptcha' do
shared_examples 'solve reCAPTCHA' do
it 'creates a snippet after solving reCAPTCHA' do
click_button('Create snippet')
wait_for_requests
# it is impossible to test recaptcha automatically and there is no possibility to fill in recaptcha
# recaptcha verification is skipped in test environment and it always returns true
# it is impossible to test reCAPTCHA automatically and there is no possibility to fill in recaptcha
# reCAPTCHA verification is skipped in test environment and it always returns true
expect(page).not_to have_content('My Snippet Title')
expect(page).to have_css('.recaptcha')
click_button('Submit personal snippet')
......@@ -82,7 +82,7 @@ shared_examples_for 'snippet editor' do
end
context 'when allow_possible_spam feature flag is true' do
it_behaves_like 'solve recaptcha'
it_behaves_like 'solve reCAPTCHA'
end
end
......
......@@ -316,7 +316,7 @@ describe('Issuable output', () => {
});
});
it('opens recaptcha modal if update rejected as spam', done => {
it('opens reCAPTCHA modal if update rejected as spam', done => {
function mockScriptSrc() {
const recaptchaChild = vm.$children.find(
// eslint-disable-next-line no-underscore-dangle
......
......@@ -57,7 +57,7 @@ describe('Description component', () => {
});
});
it('opens recaptcha dialog if update rejected as spam', done => {
it('opens reCAPTCHA dialog if update rejected as spam', done => {
let modal;
const recaptchaChild = vm.$children.find(
// eslint-disable-next-line no-underscore-dangle
......
......@@ -386,7 +386,7 @@ describe Issues::CreateService do
stub_feature_flags(allow_possible_spam: false)
end
context 'when recaptcha was verified' do
context 'when reCAPTCHA was verified' do
let(:log_user) { user }
let(:spam_logs) { create_list(:spam_log, 2, user: log_user, title: title) }
let(:target_spam_log) { spam_logs.last }
......@@ -423,7 +423,7 @@ describe Issues::CreateService do
end
end
context 'when recaptcha was not verified' do
context 'when reCAPTCHA was not verified' do
before do
expect_next_instance_of(Spam::SpamActionService) do |spam_service|
expect(spam_service).to receive_messages(check_for_spam?: true)
......
......@@ -85,7 +85,7 @@ describe Spam::SpamActionService do
allow(Spam::SpamVerdictService).to receive(:new).and_return(fake_verdict_service)
end
context 'when recaptcha was already verified' do
context 'when reCAPTCHA was already verified' do
let(:recaptcha_verified) { true }
it "doesn't check with the SpamVerdictService" do
......@@ -102,7 +102,7 @@ describe Spam::SpamActionService do
end
end
context 'when recaptcha was not verified' do
context 'when reCAPTCHA was not verified' do
let(:recaptcha_verified) { false }
context 'when spammable attributes have not changed' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment