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

drop all references to CODE_MANAGER_URL #22872

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ def insert_debug_toolbar_middleware(middlewares):
STATIC_URL = '%s/static/' % EXTERNAL_SITE_URL
MEDIA_URL = '%s/user-media/' % EXTERNAL_SITE_URL

CODE_MANAGER_URL = os.environ.get('CODE_MANAGER_URL') or 'http://olympia.test:5000'

ALLOWED_HOSTS = ALLOWED_HOSTS + [SERVICES_DOMAIN, 'nginx', '127.0.0.1']

# Default AMO user id to use for tasks (from users.json fixture in zadmin).
Expand Down
39 changes: 0 additions & 39 deletions src/olympia/accounts/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,6 @@ def test_to_is_excluded_when_unsafe(self):
query = parse_qs(url.query)
assert ':' not in query['state'][0]

def test_allows_code_manager_url(self):
self.initialize_session({})
code_manager_url = 'https://code.example.org'
to = f'{code_manager_url}/foobar'
with override_settings(CODE_MANAGER_URL=code_manager_url):
response = self.client.get(f'{self.url}?to={to}')
url = urlparse(response['location'])
query = parse_qs(url.query)
state_parts = query['state'][0].split(':')
assert base64.urlsafe_b64decode(state_parts[1] + '====') == to.encode()

def test_allows_absolute_urls(self):
self.initialize_session({})
domain = 'example.org'
Expand Down Expand Up @@ -1162,34 +1151,6 @@ def test_log_in_redirects_to_absolute_url(self):
)
self.assertRedirects(response, next_path, fetch_redirect_response=False)

def test_log_in_redirects_to_code_manager(self):
email = '[email protected]'
UserProfile.objects.create(email=email)
self.fxa_identify.return_value = (
{'email': email, 'uid': '9001'},
self.token_data,
)
code_manager_url = 'https://example.org'
next_path = f'{code_manager_url}/path'
with override_settings(CODE_MANAGER_URL=code_manager_url):
response = self.client.get(
self.url,
{
'code': 'code',
'state': ':'.join(
[
self.fxa_state,
force_str(base64.urlsafe_b64encode(next_path.encode())),
]
),
},
)
self.assertRedirects(response, next_path, fetch_redirect_response=False)
assert (
response['Cache-Control']
== 'max-age=0, no-cache, no-store, must-revalidate, private'
)

def test_log_in_requires_https_when_request_is_secure(self):
email = '[email protected]'
UserProfile.objects.create(email=email)
Expand Down
6 changes: 0 additions & 6 deletions src/olympia/amo/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import os.path
import tempfile
from unittest import mock
from urllib.parse import urlparse

from django.conf import settings
from django.test import RequestFactory
Expand Down Expand Up @@ -367,11 +366,6 @@ def test_allows_domain(self):
assert is_safe_url(f'https://{settings.DOMAIN}/foo', request)
assert not is_safe_url('https://not-olympia.dev', request)

def test_allows_code_manager_site_url(self):
request = RequestFactory().get('/', secure=True)
external_domain = urlparse(settings.CODE_MANAGER_URL).netloc
assert is_safe_url(f'https://{external_domain}/foo', request)

def test_allows_with_allowed_hosts(self):
request = RequestFactory().get('/', secure=True)
foobaa_domain = 'foobaa.com'
Expand Down
6 changes: 1 addition & 5 deletions src/olympia/amo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
parse_qsl,
unquote_to_bytes,
urlencode as urllib_urlencode,
urlparse,
)

import django.core.mail
Expand Down Expand Up @@ -1204,10 +1203,7 @@ def is_safe_url(url, request, allowed_hosts=None):
"""Use Django's `url_has_allowed_host_and_scheme()` and pass a configured
list of allowed hosts and enforce HTTPS. `allowed_hosts` can be specified."""
if not allowed_hosts:
allowed_hosts = (
settings.DOMAIN,
urlparse(settings.CODE_MANAGER_URL).netloc,
)
allowed_hosts = (settings.DOMAIN,)
if settings.ADDONS_FRONTEND_PROXY_PORT:
allowed_hosts = allowed_hosts + (
f'{settings.DOMAIN}:{settings.ADDONS_FRONTEND_PROXY_PORT}',
Expand Down
3 changes: 0 additions & 3 deletions src/olympia/conf/dev/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
INTERNAL_SITE_URL = env('INTERNAL_SITE_URL', default='https://addons-dev.allizom.org')
EXTERNAL_SITE_URL = env('EXTERNAL_SITE_URL', default='https://addons-dev.allizom.org')
SERVICES_URL = 'https://' + SERVICES_DOMAIN
CODE_MANAGER_URL = env(
'CODE_MANAGER_URL', default='https://code.addons-dev.allizom.org'
)
STATIC_URL = '%s/static-server/' % EXTERNAL_SITE_URL
MEDIA_URL = '%s/user-media/' % EXTERNAL_SITE_URL

Expand Down
1 change: 0 additions & 1 deletion src/olympia/conf/prod/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
INTERNAL_SITE_URL = env('INTERNAL_SITE_URL', default='https://addons.mozilla.org')
EXTERNAL_SITE_URL = env('EXTERNAL_SITE_URL', default='https://addons.mozilla.org')
SERVICES_URL = 'https://' + SERVICES_DOMAIN
CODE_MANAGER_URL = env('CODE_MANAGER_URL', default='https://code.addons.mozilla.org')
STATIC_URL = PROD_STATIC_URL
MEDIA_URL = PROD_MEDIA_URL

Expand Down
1 change: 0 additions & 1 deletion src/olympia/conf/stage/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
INTERNAL_SITE_URL = env('INTERNAL_SITE_URL', default='https://addons.allizom.org')
EXTERNAL_SITE_URL = env('EXTERNAL_SITE_URL', default='https://addons.allizom.org')
SERVICES_URL = 'https://' + SERVICES_DOMAIN
CODE_MANAGER_URL = env('CODE_MANAGER_URL', default='https://code.addons.allizom.org')
STATIC_URL = '%s/static-server/' % EXTERNAL_SITE_URL
MEDIA_URL = '%s/user-media/' % EXTERNAL_SITE_URL

Expand Down
3 changes: 0 additions & 3 deletions src/olympia/devhub/templates/devhub/validation.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ <h2>{{ title }}</h2>

<div class="addon-validator-suite"
id="addon-validator-suite"
{% if file_url %}
data-file-url="{{ file_url }}"
{% endif %}
{% if file %}
data-file-id="{{ file.id }}"
{% endif %}
Expand Down
16 changes: 0 additions & 16 deletions src/olympia/devhub/tests/test_views_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from olympia.files.models import File, FileUpload, FileValidation
from olympia.files.tests.test_models import UploadMixin
from olympia.files.utils import check_xpi_info, parse_addon
from olympia.reviewers.templatetags.code_manager import code_manager_url
from olympia.users.models import UserProfile


Expand Down Expand Up @@ -351,21 +350,6 @@ def test_linkify_validation_messages(self):
assert link.text == 'https://bugzilla.mozilla.org/'
assert link.attrib['href'] == 'https://bugzilla.mozilla.org/'

def test_file_url(self):
response = self.client.get(self.url, follow=False)
doc = pq(response.content)
assert doc('#addon-validator-suite').attr['data-file-url'] is None

def test_file_url_reviewer(self):
self.client.logout()
self.client.force_login(UserProfile.objects.get(email='[email protected]'))
file_url = code_manager_url(
'browse', addon_id=self.addon.pk, version_id=self.file.version.pk
)
response = self.client.get(self.url, follow=False)
doc = pq(response.content)
assert doc('#addon-validator-suite').attr['data-file-url'] == file_url

def test_reviewers_can_see_json_results_for_deleted_addon(self):
self.client.logout()
self.client.force_login(UserProfile.objects.get(email='[email protected]'))
Expand Down
7 changes: 0 additions & 7 deletions src/olympia/devhub/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
from olympia.files.utils import parse_addon
from olympia.reviewers.forms import PublicWhiteboardForm
from olympia.reviewers.models import Whiteboard
from olympia.reviewers.templatetags.code_manager import code_manager_url
from olympia.reviewers.utils import ReviewHelper
from olympia.users.models import (
DeveloperAgreementRestriction,
Expand Down Expand Up @@ -704,15 +703,9 @@ def file_validation(request, addon_id, addon, file_id):
file_ = get_object_or_404(File, version__addon=addon, id=file_id)

validate_url = reverse('devhub.json_file_validation', args=[addon.slug, file_.id])
file_url = (
code_manager_url('browse', addon_id=addon.pk, version_id=file_.version.pk)
if acl.is_user_any_kind_of_reviewer(request.user)
else None
)

context = {
'validate_url': validate_url,
'file_url': file_url,
'file': file_,
'filename': file_.pretty_filename,
'timestamp': file_.created,
Expand Down
4 changes: 0 additions & 4 deletions src/olympia/lib/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,6 @@ def get_db_config(environ_var, atomic_requests=True):
# Example: https://services.addons.mozilla.org
SERVICES_URL = 'http://%s' % SERVICES_DOMAIN

# URL of the code-manager site, see:
# https://github.com/mozilla/addons-code-manager
CODE_MANAGER_URL = f'https://code.{DOMAIN}'

# Static and media URL for prod are hardcoded here to allow them to be set in
# the base CSP shared by all envs.
PROD_STATIC_URL = 'https://addons.mozilla.org/static-server/'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,13 @@
&middot;
<a href="{{ url('devhub.file_validation', addon.slug, file.id) }}">Validation results</a>
&middot;
<a
<a
class="assay"
href="{{ assay_url(addon.guid, version) }}"
title="Open this version in Visual Studio Code"
>
Open in VSC
</a>
&middot;
<a
href="{{ code_manager_url('browse', addon.pk, version.pk) }}"
title="Browse all files in this version"
>
Browse contents
</a>
{% if base_version_pk and version == latest_not_disabled_version %}
&middot;
<a
class="compare"
href="{{ code_manager_url('compare', addon.pk, version.pk, base_version_pk) }}"
title="Compare this version to the last reviewed version"
>
Compare with last reviewed
</a>
{% endif %}
</div>
<div>
{% if file.permissions %}
Expand Down
20 changes: 0 additions & 20 deletions src/olympia/reviewers/templatetags/code_manager.py

This file was deleted.

7 changes: 1 addition & 6 deletions src/olympia/reviewers/templatetags/jinja_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from olympia.access import acl
from olympia.amo.templatetags.jinja_helpers import new_context
from olympia.ratings.permissions import user_can_delete_rating
from olympia.reviewers.templatetags import assay, code_manager
from olympia.reviewers.templatetags import assay


@library.global_function
Expand Down Expand Up @@ -72,11 +72,6 @@ def assay_url(addon_guid, version_string, filepath=None):
return assay.assay_url(addon_guid, version_string, filepath)


@library.global_function
def code_manager_url(page, addon_id, version_id, base_version_id=None):
return code_manager.code_manager_url(page, addon_id, version_id, base_version_id)


@library.global_function
@jinja2.pass_context
def check_review_delete(context, rating):
Expand Down
62 changes: 0 additions & 62 deletions src/olympia/reviewers/tests/test_code_manager_tags.py

This file was deleted.

10 changes: 1 addition & 9 deletions src/olympia/reviewers/tests/test_jinja_helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from olympia.reviewers.templatetags import assay, code_manager, jinja_helpers
from olympia.reviewers.templatetags import assay, jinja_helpers


pytestmark = pytest.mark.django_db
Expand All @@ -14,14 +14,6 @@ def test_create_an_assay_url():
)


def test_create_a_code_manager_url():
assert jinja_helpers.code_manager_url(
'browse', addon_id=1, base_version_id=2, version_id=3
) == code_manager.code_manager_url(
'browse', addon_id=1, base_version_id=2, version_id=3
)


def test_format_score():
assert jinja_helpers.format_score(15.1) == '15%'
assert jinja_helpers.format_score(0) == 'n/a'
Expand Down
Loading
Loading