Merge branch 'main' of https://github.com/GSA/notifications-admin into notify-786

This commit is contained in:
Andrew Shumway
2023-11-17 11:19:50 -07:00
7 changed files with 45 additions and 109 deletions
+2 -2
View File
@@ -6,7 +6,7 @@ from app import service_api_client
from app.formatters import email_safe
from app.main import main
from app.main.forms import CreateServiceForm
from app.utils.user import user_is_gov_user, user_is_platform_admin
from app.utils.user import user_is_gov_user, user_is_logged_in
def _create_service(service_name, organization_type, email_from, form):
@@ -42,7 +42,7 @@ def _create_example_template(service_id):
@main.route("/add-service", methods=["GET", "POST"])
@user_is_gov_user
@user_is_platform_admin
@user_is_logged_in
def add_service():
default_organization_type = current_user.default_organization_type
if default_organization_type is None:
-1
View File
@@ -689,7 +689,6 @@ def format_stats_by_service(services):
"name": service["name"],
"stats": service["statistics"],
"restricted": service["restricted"],
"research_mode": service["research_mode"],
"created_at": service["created_at"],
"active": service["active"],
}
+2 -7
View File
@@ -1,17 +1,12 @@
{% macro tick_cross(yes, label, truthy_hint='Can', falsey_hint='Cannot') %}
<li>
{% if yes %}
<li>
<span class="tick-cross-tick">
<span class="usa-sr-only">{{ truthy_hint }}</span>
{{ label}}
</span>
{% else %}
<span class="tick-cross-cross">
<span class="usa-sr-only">{{ falsey_hint }}</span>
{{ label}}
</span>
</li>
{% endif %}
</li>
{% endmacro %}
{% macro tick_cross_done_not_done(yes, label) %}
Generated
+32 -32
View File
@@ -1465,13 +1465,13 @@ files = [
[[package]]
name = "moto"
version = "4.2.7"
version = "4.2.8"
description = ""
optional = false
python-versions = ">=3.7"
files = [
{file = "moto-4.2.7-py2.py3-none-any.whl", hash = "sha256:3e0ef388900448485cd6eff18e9f7fcaa6cf4560b6fb536ba2e2e1278a5ecc59"},
{file = "moto-4.2.7.tar.gz", hash = "sha256:1298006aaa6996b886658eb194cac0e3a5679c9fcce6cb13e741ccc5a7247abb"},
{file = "moto-4.2.8-py2.py3-none-any.whl", hash = "sha256:e78b49ae8acee06a865e4963174bdf974dd66398fb3bb831a7428498506c0c56"},
{file = "moto-4.2.8.tar.gz", hash = "sha256:9b5a363f36f8c3fb36388764e7b8c01c615da2f2cba7da3e681680de14bfc769"},
]
[package.dependencies]
@@ -1486,29 +1486,29 @@ werkzeug = ">=0.5,<2.2.0 || >2.2.0,<2.2.1 || >2.2.1"
xmltodict = "*"
[package.extras]
all = ["PyYAML (>=5.1)", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "ecdsa (!=0.15)", "graphql-core", "jsondiff (>=1.1.2)", "multipart", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.4.1)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "setuptools", "sshpubkeys (>=3.1.0)"]
all = ["PyYAML (>=5.1)", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "ecdsa (!=0.15)", "graphql-core", "jsondiff (>=1.1.2)", "multipart", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.4.2)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "setuptools", "sshpubkeys (>=3.1.0)"]
apigateway = ["PyYAML (>=5.1)", "ecdsa (!=0.15)", "openapi-spec-validator (>=0.5.0)", "python-jose[cryptography] (>=3.1.0,<4.0.0)"]
apigatewayv2 = ["PyYAML (>=5.1)"]
appsync = ["graphql-core"]
awslambda = ["docker (>=3.0.0)"]
batch = ["docker (>=3.0.0)"]
cloudformation = ["PyYAML (>=5.1)", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "ecdsa (!=0.15)", "graphql-core", "jsondiff (>=1.1.2)", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.4.1)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "setuptools", "sshpubkeys (>=3.1.0)"]
cloudformation = ["PyYAML (>=5.1)", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "ecdsa (!=0.15)", "graphql-core", "jsondiff (>=1.1.2)", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.4.2)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "setuptools", "sshpubkeys (>=3.1.0)"]
cognitoidp = ["ecdsa (!=0.15)", "python-jose[cryptography] (>=3.1.0,<4.0.0)"]
ds = ["sshpubkeys (>=3.1.0)"]
dynamodb = ["docker (>=3.0.0)", "py-partiql-parser (==0.4.1)"]
dynamodbstreams = ["docker (>=3.0.0)", "py-partiql-parser (==0.4.1)"]
dynamodb = ["docker (>=3.0.0)", "py-partiql-parser (==0.4.2)"]
dynamodbstreams = ["docker (>=3.0.0)", "py-partiql-parser (==0.4.2)"]
ebs = ["sshpubkeys (>=3.1.0)"]
ec2 = ["sshpubkeys (>=3.1.0)"]
efs = ["sshpubkeys (>=3.1.0)"]
eks = ["sshpubkeys (>=3.1.0)"]
glue = ["pyparsing (>=3.0.7)"]
iotdata = ["jsondiff (>=1.1.2)"]
proxy = ["PyYAML (>=5.1)", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=2.5.1)", "ecdsa (!=0.15)", "graphql-core", "jsondiff (>=1.1.2)", "multipart", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.4.1)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "setuptools", "sshpubkeys (>=3.1.0)"]
resourcegroupstaggingapi = ["PyYAML (>=5.1)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "ecdsa (!=0.15)", "graphql-core", "jsondiff (>=1.1.2)", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.4.1)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "sshpubkeys (>=3.1.0)"]
proxy = ["PyYAML (>=5.1)", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=2.5.1)", "ecdsa (!=0.15)", "graphql-core", "jsondiff (>=1.1.2)", "multipart", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.4.2)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "setuptools", "sshpubkeys (>=3.1.0)"]
resourcegroupstaggingapi = ["PyYAML (>=5.1)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "ecdsa (!=0.15)", "graphql-core", "jsondiff (>=1.1.2)", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.4.2)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "sshpubkeys (>=3.1.0)"]
route53resolver = ["sshpubkeys (>=3.1.0)"]
s3 = ["PyYAML (>=5.1)", "py-partiql-parser (==0.4.1)"]
s3crc32c = ["PyYAML (>=5.1)", "crc32c", "py-partiql-parser (==0.4.1)"]
server = ["PyYAML (>=5.1)", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "ecdsa (!=0.15)", "flask (!=2.2.0,!=2.2.1)", "flask-cors", "graphql-core", "jsondiff (>=1.1.2)", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.4.1)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "setuptools", "sshpubkeys (>=3.1.0)"]
s3 = ["PyYAML (>=5.1)", "py-partiql-parser (==0.4.2)"]
s3crc32c = ["PyYAML (>=5.1)", "crc32c", "py-partiql-parser (==0.4.2)"]
server = ["PyYAML (>=5.1)", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "ecdsa (!=0.15)", "flask (!=2.2.0,!=2.2.1)", "flask-cors", "graphql-core", "jsondiff (>=1.1.2)", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.4.2)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "setuptools", "sshpubkeys (>=3.1.0)"]
ssm = ["PyYAML (>=5.1)"]
xray = ["aws-xray-sdk (>=0.93,!=0.96)", "setuptools"]
@@ -1590,26 +1590,26 @@ files = [
[[package]]
name = "newrelic"
version = "9.1.1"
version = "9.1.2"
description = "New Relic Python Agent"
optional = false
python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*"
files = [
{file = "newrelic-9.1.1-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:639abcaa1baee5a1a137036e328617e3a6bbb33a63814ef6227a8059d9062f0d"},
{file = "newrelic-9.1.1-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:1bd46363c71c3fc5dbcc0e96e1698757f4e7ff82c73a0ccb28f18c2b9f9c5de5"},
{file = "newrelic-9.1.1-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:fbebaf8d9801eef85827ca2906a7bdbc2a458a226455da49c71857e2ce2b264a"},
{file = "newrelic-9.1.1-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:c1a91322fdb301a7a17aab8df2e70925c1e2a01a61136d86a0e433f6ff167c5c"},
{file = "newrelic-9.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d677f8f11bd69d92a4b359c53a04e02094e5198ed1aa49c9b1ca235522d5efd5"},
{file = "newrelic-9.1.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:289cebbb86eb92b6c133e18cd5640115a918db41ae791d11c1ded5b592dd7c23"},
{file = "newrelic-9.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b1b93effe99be14a1747a70e9368274091abbed2ef3c593b08a29732d72d83e4"},
{file = "newrelic-9.1.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:45966c5f083d1f1abb76828c4864d20296f6929053fbe4d122e164d84c78e388"},
{file = "newrelic-9.1.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:18e8e6af37cc084007913b991bced2ea2b8b31ed5318a397f210a9625c214459"},
{file = "newrelic-9.1.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:437dfae553012dbe6e0f288b1f600ef27b0ebc2c367641723529b1a71fa541ae"},
{file = "newrelic-9.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5489becb7cff1ba992405c9d891fd1743e8042910c97f89ac072fd562501cdb1"},
{file = "newrelic-9.1.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8403b48807eae524ee1b2da254f4222834f3aef8326dd4475f0b22f924774bde"},
{file = "newrelic-9.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:603158cb23ed6604845e4fc8ee2a052e60003ccbb7da0f4b00667cd0c7c77c11"},
{file = "newrelic-9.1.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:96dedf6c1a385bf7b4b1336b3e4b5a0d6e983b5305022176c7c43d327e768bf3"},
{file = "newrelic-9.1.1.tar.gz", hash = "sha256:968a3662ccfb881498789105a52eec866b57c22b8cbdef43889ad76881c62a95"},
{file = "newrelic-9.1.2-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:9418171bed0662ab3660af6f20ee709e9f7fce8a55731878c35a89c90d885d3d"},
{file = "newrelic-9.1.2-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:3d13e9d52c35c7e22478f2c99490c35de6aa1c6b6015fb0c59fac0254c3cf74e"},
{file = "newrelic-9.1.2-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:283d05094eef7ff035d21a3dc50f4af99e3c105f84521aa776e567d86b043ea3"},
{file = "newrelic-9.1.2-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:88c60121523e71098b76f8c4e530b34be04ea4cead8350b9825467286dca8067"},
{file = "newrelic-9.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a8780510972301502642ed1af6f6832dab6aefa941aa4647554da053647d4449"},
{file = "newrelic-9.1.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:309c249e6bdd0258f54cd8102a37254653e1fa277cbe4d4a7cc2429a605a9d71"},
{file = "newrelic-9.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d146438edc59912b0af25756abaeee6a3b7c62cabd3d4dd27fceb65935ba2350"},
{file = "newrelic-9.1.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:287653c86a3b15b9f5b4e80626ae6cf58ca5a41df7f0ce1db806a8875fdcf233"},
{file = "newrelic-9.1.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8bcb72041bad15c11f2992bda53cb8e21412cc7ba7a218cc5af75c67d4ebc686"},
{file = "newrelic-9.1.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:314d26f475c2fcb1ee56a480dd94419a445cfcd35c9d436206bbf1e809dbfcec"},
{file = "newrelic-9.1.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:343836e35135b48e38173112e053511fe155ed0b585093ec9b262dabde5d12f0"},
{file = "newrelic-9.1.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:da6ffcca0f339c375e736d622f80ec0acf7c4be4525ab7ccff5f08e460d09c35"},
{file = "newrelic-9.1.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:02b564807d7e9f798b4455a82fce4b78d80735a506ff8bca703637b83d9f5a02"},
{file = "newrelic-9.1.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:28fd021dd7361317bfa518e906efd707c296cad2a5bb6ea41a804f582d55e624"},
{file = "newrelic-9.1.2.tar.gz", hash = "sha256:efa5430169828e36a459794ef46993db4b359ff0eab0af71aec16518d95274c9"},
]
[package.extras]
@@ -2265,13 +2265,13 @@ python-slugify = ">=6.0.0,<9.0.0"
[[package]]
name = "pytest-xdist"
version = "3.3.1"
version = "3.4.0"
description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs"
optional = false
python-versions = ">=3.7"
files = [
{file = "pytest-xdist-3.3.1.tar.gz", hash = "sha256:d5ee0520eb1b7bcca50a60a518ab7a7707992812c578198f8b44fdfac78e8c93"},
{file = "pytest_xdist-3.3.1-py3-none-any.whl", hash = "sha256:ff9daa7793569e6a68544850fd3927cd257cc03a7ef76c95e86915355e82b5f2"},
{file = "pytest-xdist-3.4.0.tar.gz", hash = "sha256:3a94a931dd9e268e0b871a877d09fe2efb6175c2c23d60d56a6001359002b832"},
{file = "pytest_xdist-3.4.0-py3-none-any.whl", hash = "sha256:e513118bf787677a427e025606f55e95937565e06dfaac8d87f55301e57ae607"},
]
[package.dependencies]
@@ -2970,4 +2970,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p
[metadata]
lock-version = "2.0"
python-versions = ">=3.9,<3.12"
content-hash = "45567b50df5ff3635275f69a93dddd5977af80fb2bdbe3484fe4dd643f41a8c2"
content-hash = "4a38fa6c01f64c2e813d2e65aa22334357fe8785fc76c2008668ed9eab7a27de"
+1 -1
View File
@@ -56,7 +56,7 @@ pytest = "^7.4.3"
pytest-env = "^1.1.1"
pytest-mock = "^3.12.0"
pytest-playwright = "^0.4.3"
pytest-xdist = "^3.3.1"
pytest-xdist = "^3.4.0"
radon = "^6.0.1"
requests-mock = "^1.11.0"
vulture = "^2.10"
+7 -52
View File
@@ -39,28 +39,12 @@ from tests.conftest import (
),
(
create_active_user_empty_permissions(),
(
"Test User With Empty Permissions (you) "
"Permissions "
"Cannot See dashboard "
"Cannot Send messages "
"Cannot Add and edit templates "
"Cannot Manage settings, team and usage "
"Cannot Manage API integration"
),
("Test User With Empty Permissions (you) " "Permissions"),
False,
),
(
create_active_user_view_permissions(),
(
"Test User With Permissions (you) "
"Permissions "
"Can See dashboard "
"Cannot Send messages "
"Cannot Add and edit templates "
"Cannot Manage settings, team and usage "
"Cannot Manage API integration"
),
("Test User With Permissions (you) " "Permissions " "Can See dashboard"),
False,
),
(
@@ -69,10 +53,7 @@ from tests.conftest import (
"Test User With Permissions (you) "
"Permissions "
"Can See dashboard "
"Cannot Send messages "
"Can Add and edit templates "
"Cannot Manage settings, team and usage "
"Cannot Manage API integration"
"Can Add and edit templates"
),
False,
),
@@ -112,15 +93,7 @@ def test_should_show_overview_page(
normalize_spaces(page.select(".user-list-item")[0].text) == expected_self_text
)
expected = (
"ZZZZZZZZ zzzzzzz@example.gsa.gov "
"Permissions "
"Can See dashboard "
"Cannot Send messages "
"Cannot Add and edit templates "
"Cannot Manage settings, team and usage "
"Cannot Manage API integration"
)
expected = "ZZZZZZZZ zzzzzzz@example.gsa.gov " "Permissions " "Can See dashboard"
if add_details is True:
expected = f"{expected} Change details for ZZZZZZZZ zzzzzzz@example.gsa.gov"
@@ -259,23 +232,11 @@ def test_should_show_caseworker_on_overview_page(
assert normalize_spaces(page.select_one("h1").text) == "Team members"
assert normalize_spaces(page.select(".user-list-item")[0].text) == (
"Test User With Permissions (you) "
"Permissions "
"Can See dashboard "
"Cannot Send messages "
"Cannot Add and edit templates "
"Cannot Manage settings, team and usage "
"Cannot Manage API integration"
"Test User With Permissions (you) " "Permissions " "Can See dashboard"
)
# [1:5] are invited users
assert normalize_spaces(page.select(".user-list-item")[6].text) == (
"Test User zzzzzzz@example.gsa.gov "
"Permissions "
"Cannot See dashboard "
"Can Send messages "
"Cannot Add and edit templates "
"Cannot Manage settings, team and usage "
"Cannot Manage API integration"
"Test User zzzzzzz@example.gsa.gov " "Permissions " "Can Send messages"
)
@@ -1240,7 +1201,6 @@ def test_cancel_invited_user_doesnt_work_if_user_not_invited_to_this_service(
"Permissions "
"Can See dashboard "
"Can Send messages "
"Cannot Add and edit templates "
"Can Manage settings, team and usage "
"Can Manage API integration "
"Cancel invitation for invited_user@test.gsa.gov"
@@ -1250,13 +1210,8 @@ def test_cancel_invited_user_doesnt_work_if_user_not_invited_to_this_service(
"cancelled",
(
"invited_user@test.gsa.gov (cancelled invite) "
"Permissions "
"Permissions"
# all permissions are greyed out
"Cannot See dashboard "
"Cannot Send messages "
"Cannot Add and edit templates "
"Cannot Manage settings, team and usage "
"Cannot Manage API integration"
),
),
],
+1 -14
View File
@@ -4,7 +4,7 @@ import pytest
from flask import url_for
from app.models.user import User
from tests.conftest import SERVICE_ONE_ID, create_platform_admin_user, normalize_spaces
from tests.conftest import SERVICE_ONE_ID, normalize_spaces
def test_render_sign_in_template_for_new_user(client_request):
@@ -72,19 +72,6 @@ def test_doesnt_redirect_to_sign_in_if_no_session_info(
with client_request.session_transaction() as session:
session["current_session_id"] = None
# This returns a 403 now
with pytest.raises(AssertionError):
client_request.get("main.add_service")
def test_doesnt_redirect_to_sign_in_if_no_session_info_platform_admin(
client_request,
mock_get_organization_by_domain,
):
platform_admin = create_platform_admin_user()
client_request.login(platform_admin)
platform_admin["current_session_id"] = str(uuid.UUID(int=1))
with client_request.session_transaction() as session:
session["current_session_id"] = None