mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-26 17:24:23 -04:00
update warning message, fix tests
This commit is contained in:
@@ -150,6 +150,7 @@ def _csp(config):
|
|||||||
"'unsafe-eval'",
|
"'unsafe-eval'",
|
||||||
"https://js-agent.newrelic.com",
|
"https://js-agent.newrelic.com",
|
||||||
"https://gov-bam.nr-data.net",
|
"https://gov-bam.nr-data.net",
|
||||||
|
"https://www.googletagmanager.com",
|
||||||
],
|
],
|
||||||
"connect-src": ["'self'", "https://gov-bam.nr-data.net"],
|
"connect-src": ["'self'", "https://gov-bam.nr-data.net"],
|
||||||
"style-src": ["'self'", asset_domain],
|
"style-src": ["'self'", asset_domain],
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
(function (window) {
|
(function (window) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Show the current year
|
// Show the current year
|
||||||
document.getElementById("current-year").innerHTML = new Date().getFullYear();
|
const currentYearElement = document.getElementById("current-year");
|
||||||
|
|
||||||
|
if (currentYearElement) {
|
||||||
})(window);
|
currentYearElement.textContent = new Date().getFullYear();
|
||||||
|
}
|
||||||
|
})(window);
|
||||||
@@ -503,8 +503,6 @@ def delete_template_folder(service_id, template_folder_id):
|
|||||||
)
|
)
|
||||||
@user_has_permissions("manage_templates")
|
@user_has_permissions("manage_templates")
|
||||||
def add_service_template(service_id, template_type, template_folder_id=None):
|
def add_service_template(service_id, template_type, template_folder_id=None):
|
||||||
|
|
||||||
print("ENTER ADD_SERVICE_TEMPLATE")
|
|
||||||
if template_type not in current_service.available_template_types:
|
if template_type not in current_service.available_template_types:
|
||||||
return redirect(
|
return redirect(
|
||||||
url_for(
|
url_for(
|
||||||
@@ -569,7 +567,6 @@ def abort_403_if_not_admin_user():
|
|||||||
)
|
)
|
||||||
@user_has_permissions("manage_templates")
|
@user_has_permissions("manage_templates")
|
||||||
def edit_service_template(service_id, template_id):
|
def edit_service_template(service_id, template_id):
|
||||||
print("ENTER EDIT_SERVICE_TEMPLATE")
|
|
||||||
template = current_service.get_template_with_user_permission_or_403(
|
template = current_service.get_template_with_user_permission_or_403(
|
||||||
template_id, current_user
|
template_id, current_user
|
||||||
)
|
)
|
||||||
@@ -670,7 +667,6 @@ def count_content_length(service_id, template_type):
|
|||||||
current_service,
|
current_service,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
print(f"ERROR AND MESSAGE {error} {message}")
|
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
{
|
{
|
||||||
@@ -683,17 +679,21 @@ def count_content_length(service_id, template_type):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _is_latin1(s):
|
||||||
|
return bool(s.encode(encoding="latin-1", errors="strict"))
|
||||||
|
|
||||||
|
|
||||||
def _get_content_count_error_and_message_for_template(template):
|
def _get_content_count_error_and_message_for_template(template):
|
||||||
if template.template_type == "sms":
|
if template.template_type == "sms":
|
||||||
|
s1 = " Use of characters outside the iso-latin-1 character set may increase "
|
||||||
|
s2 = "the message fragment count, resulting in additional charges, and these non iso-latin-1 "
|
||||||
|
s3 = "characters may not display properly on older phones."
|
||||||
|
|
||||||
islatin1 = lambda s: bool(s.encode(encoding="latin-1", errors="strict"))
|
|
||||||
warning = ""
|
warning = ""
|
||||||
try:
|
try:
|
||||||
islatin1(template.content)
|
_is_latin1(template.content)
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
warning = " Use of characters outside the iso-latin-1 character set will result in additional characters and may not display properly on older phones."
|
warning = f"{s1}{s2}{s3}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if template.is_message_too_long():
|
if template.is_message_too_long():
|
||||||
return True, (
|
return True, (
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-col-12">
|
<div class="grid-col-12">
|
||||||
<div class="template-content-count" bg="blue" spacing="1">
|
<div class="template-content-count" bg-color="red">
|
||||||
<div data-module="update-status" data-target="template_content"
|
<div data-module="update-status" data-target="template_content"
|
||||||
data-updates-url="{{ url_for('.count_content_length', service_id=current_service.id, template_type='sms') }}"
|
data-updates-url="{{ url_for('.count_content_length', service_id=current_service.id, template_type='sms') }}"
|
||||||
aria-live="polite">
|
aria-live="polite">
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ def test_owasp_useful_headers_set(
|
|||||||
assert search(r"form-action 'self';", csp)
|
assert search(r"form-action 'self';", csp)
|
||||||
assert search(
|
assert search(
|
||||||
r"script-src 'self' static\.example\.com 'unsafe-eval' https:\/\/js-agent\.new"
|
r"script-src 'self' static\.example\.com 'unsafe-eval' https:\/\/js-agent\.new"
|
||||||
r"relic\.com https:\/\/gov-bam\.nr-data\.net 'nonce-.*';",
|
r"relic\.com https:\/\/gov-bam\.nr-data\.net https:\/\/www\.googletagmanager\."
|
||||||
|
r"com 'nonce-.*';",
|
||||||
csp,
|
csp,
|
||||||
)
|
)
|
||||||
assert search(r"connect-src 'self' https:\/\/gov-bam.nr-data\.net;", csp)
|
assert search(r"connect-src 'self' https:\/\/gov-bam.nr-data\.net;", csp)
|
||||||
|
|||||||
@@ -2113,7 +2113,7 @@ def test_content_count_json_endpoint(
|
|||||||
html = json.loads(response.get_data(as_text=True))["html"]
|
html = json.loads(response.get_data(as_text=True))["html"]
|
||||||
snippet = BeautifulSoup(html, "html.parser").select_one("span")
|
snippet = BeautifulSoup(html, "html.parser").select_one("span")
|
||||||
|
|
||||||
assert normalize_spaces(snippet.text) == expected_message
|
assert expected_message in normalize_spaces(snippet.text)
|
||||||
|
|
||||||
if snippet.has_attr("class"):
|
if snippet.has_attr("class"):
|
||||||
assert snippet["class"] == [expected_class]
|
assert snippet["class"] == [expected_class]
|
||||||
|
|||||||
Reference in New Issue
Block a user