Skip to content

Commit

Permalink
Merge pull request #3126 from /issues/3121/1
Browse files Browse the repository at this point in the history
Issue #3121 - Disable anonymous reporting
  • Loading branch information
Mike Taylor authored Jan 3, 2020
2 parents 40b83fa + 4981204 commit 1e096d1
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 47 deletions.
2 changes: 1 addition & 1 deletion tests/functional/reporting-non-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ registerSuite("Reporting (non-auth)", {
// wait a bit
.sleep(250)
// now make sure the buttons aren't disabled anymore
.findAllByCssSelector(".js-report-buttons button")
.findAllByCssSelector("#js-ReportForm .js-Button")
.getAttribute("disabled")
.then(function(values) {
values.forEach(function(value) {
Expand Down
13 changes: 7 additions & 6 deletions tests/unit/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_new_issue(self):

@patch('webcompat.views.report_issue')
def test_successful_post_new_issue(self, mock_proxy):
"""Test that post is working on /issues/new."""
"""Test that anonymous post is not working on /issues/new."""
mock_proxy.return_value = POST_RESPONSE
rv = self.app.post(
'/issues/new',
Expand All @@ -71,11 +71,12 @@ def test_successful_post_new_issue(self, mock_proxy):
submit_type='github-proxy-report',
url='http://testing.example.org',
username='yeeha'))
self.assertEqual(rv.status_code, 302)
self.assertEqual(
rv.headers['Location'], 'http://localhost/issues/1544')
self.assertTrue(
b'<a href="/issues/1544">/issues/1544</a>' in rv.data)
self.assertEqual(rv.status_code, 400)
# Commented out while anonymous reporting is disabled
# self.assertNotEqual(
# rv.headers['Location'], 'http://localhost/issues/1544')
# self.assertTrue(
# b'<a href="/issues/1544">/issues/1544</a>' in rv.data)

@patch('webcompat.issues.proxy_request')
def test_fail_post_new_issue(self, mock_proxy):
Expand Down
2 changes: 1 addition & 1 deletion webcompat/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def is_valid_issue_form(form):
'submit_type',
'url',
'username', ]
form_submit_values = ['github-auth-report', 'github-proxy-report']
form_submit_values = ['github-auth-report']
parameters_check = set(must_parameters).issubset(list(form.keys()))
if parameters_check:
values_check = form['submit_type'] in form_submit_values
Expand Down
10 changes: 6 additions & 4 deletions webcompat/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ def report_issue(form, proxy=False):
submit_type = form.get('submit_type')
if proxy and submit_type == 'github-proxy-report':
# Return a Response object.
response = proxy_request('post',
path,
data=json.dumps(build_formdata(form)))
json_response = response.json()
# response = proxy_request('post',
# path,
# data=json.dumps(build_formdata(form)))
# json_response = response.json()
# Anonymous reporting is currently disabled.
abort(400)
elif (not proxy) and submit_type == 'github-auth-report':
# Return JSON data as a dict
json_response = github.post(path, build_formdata(form))
Expand Down
9 changes: 4 additions & 5 deletions webcompat/templates/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,11 @@ <h1 class="headline-1">Report Site Issue</h1>
<div class="form-button form-button-multiple form-element js-Form-group js-report-buttons">
<div class="button-wrapper js-Button-wrapper">
<button
class="button button-secondary js-Button"
id="submitanon"
type="submit"
name="github-proxy-report"
class="button button-secondary"
type="button"
disabled="disabled"
>
Report Anonymously
Anonymous reports temporarily disabled
</button>
</div>
<div class="button-wrapper js-Button-wrapper">
Expand Down
41 changes: 11 additions & 30 deletions webcompat/templates/issue-wizard-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -324,45 +324,26 @@ <h3 class="page-heading">Filing a web compatibility issue</h3>
<div class="input-control">
<div class="col center">
<div class="final-text">
Good job! You can&nbsp;<strong>report via GitHub</strong>&nbsp;or&nbsp;<strong>report anonymously</strong>.
Good job! You can&nbsp;<strong>report via GitHub</strong>
<div><strong>Anonymous reporting is temporarily disabled</strong>.</div>
</div>
<div class="row mobile-col">
<button class="button button-secondary right js-Button" id="submitgithub" type="submit" name="github-auth-report">
<img class="" src="{{ url_for('static', filename='img/svg/icons/svg-github-white.svg') }}" title="Report via GitHub" alt="Report via GitHub" />
{% if session.username %}Report as {{ session.username }}{% else %}Report via GitHub{% endif %}
</button>
<button class="button button-primary" id="open-username" type="submit">
Report Anonymously
</button>
</div>
<div class="optional-username centered low">
You can optionally provide your GitHub username, allowing us to contact you during diagnosis.
<div class="column narrow js-Form-group">
<div class="label">
<label class="form-label" for="contact">Optional GitHub username</label>
<div class="right-label">public</div>
</div>
{{ form.contact(class_='form-field text-field',
placeholder='GitHub username',
pattern='^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$') }}

<div class="is-hidden" aria-hidden="true">
<div class="form-text form-element js-Form-group">
{{ form.username.label(class_='form-label') }}
{% if form.username.errors %}
{% for error in form.username.errors %}
<small class="form-message-error">{{ error }}</small>
{% endfor %}
{% endif %}
{{ form.username(class_='u-formInput') }}
</div>
<div class="is-hidden" aria-hidden="true">
<div class="form-text form-element js-Form-group">
{{ form.username.label(class_='form-label') }}
{% if form.username.errors %}
{% for error in form.username.errors %}
<small class="form-message-error">{{ error }}</small>
{% endfor %}
{% endif %}
{{ form.username(class_='u-formInput') }}
</div>
</div>
<div class="col center">
<button class="button button-primary js-Button" id="submitanon" type="submit" name="github-proxy-report">
Send report
</button>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 1e096d1

Please sign in to comment.