Skip to content

Commit

Permalink
Merge pull request #1899 from uktrade/dev
Browse files Browse the repository at this point in the history
UAT release
  • Loading branch information
kevincarrogan authored Apr 16, 2024
2 parents 8072d79 + a2cb90d commit a8972c5
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 15 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

- [Python 3.9](https://www.python.org/downloads/release/python-39/)
- [Pipenv](https://pipenv.pypa.io/en/latest/)
- [Homebrew](https://brew.sh/)

### Installing

Expand Down Expand Up @@ -62,15 +63,21 @@ make run_exporter
- Set up your local config file:
- `make secrets`
- populate the newly created `caseworker.env` and `exporter.env` with values from Vault.
- As it states in the env file add the following to your to your /etc/hosts file:
```
127.0.0.1 caseworker
127.0.0.1 exporter
```
- Further information at https://kinsta.com/knowledgebase/edit-mac-hosts-file/
* Ensure docker is running
* Build and start docker images:
- If you haven't already done this for lite-api, set up a shared docker network:
- `docker network create lite` - shared network to allow API and frontend to communicate
- `docker network create lite` - shared network to allow API and frontend to communicate
- `docker-compose build` - build the container image
* Installation requirements
- install libmagic
- install libmagic with the `brew install libmagic` command.
#### Starting the service
Expand Down
1 change: 0 additions & 1 deletion caseworker/core/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def get_permissible_statuses(request, case):
if status["key"]
not in [
CaseStatusEnum.APPLICANT_EDITING,
CaseStatusEnum.CLOSED,
CaseStatusEnum.FINALISED,
CaseStatusEnum.REGISTERED,
CaseStatusEnum.CLC,
Expand Down
4 changes: 3 additions & 1 deletion caseworker/external_data/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
app_name = "external_data"

urlpatterns = [
path("denials/upload/", views.DenialUploadView.as_view(), name="denials-upload"),
path(
"denials/add-by-csv/", views.DenialUploadView.as_view(), name="denials-add-by-csv"
), # TODO: rename back to "denials/upload/" and "denials-upload" when we are ready to release this to users
path("denials/<uuid:pk>/", views.DenialDetailView.as_view(), name="denial-detail"),
path("denials/<uuid:pk>/revoke/", views.DenialRevokeView.as_view(), name="denial-revoke"),
]
4 changes: 2 additions & 2 deletions example.caseworker.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ ALLOWED_HOSTS=*
ALLOWED_HOSTS=*
OAUTHLIB_INSECURE_TRANSPORT=True
GTM_ID=''
LITE_API_HAWK_KEY=

LITE_API_URL=http://host.docker.internal:8100
# comment above LITE_API_URL and uncomment below if running outside docker
Expand All @@ -27,12 +26,14 @@ TEST_TYPE_HEADLESS=False
TEST_SSO_EMAIL=<<FROM_VAULT>>
TEST_SSO_PASSWORD=<<FROM_VAULT>>
TEST_SSO_NAME=<<FROM_VAULT>>
TEST_EXPORTER_SSO_NAME=<<FROM_VAULT>>
EXPORTER_TEST_SSO_EMAIL=<<FROM_VAULT>>
EXPORTER_TEST_SSO_PASSWORD=<<FROM_VAULT>>

# AWS
AWS_S3_ENDPOINT_URL=http://s3:9000
AWS_ACCESS_KEY_ID=minio_username
AWS_REGION=eu-west-2
AWS_SECRET_ACCESS_KEY=minio_password
AWS_STORAGE_BUCKET_NAME=uploads

Expand All @@ -42,7 +43,6 @@ DJANGO_SECRET_KEY=DJANGO_SECRET_KEY

ENVIRONMENT=local

LITE_E2E_HAWK_KEY=LITE_E2E_HAWK_KEY
PERMISSIONS_FINDER_URL=

STATICFILES_STORAGE=django.contrib.staticfiles.storage.StaticFilesStorage
Expand Down
2 changes: 1 addition & 1 deletion exporter/applications/forms/export_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def route_of_goods_form():
"<br>"
+ "<details class='govuk-details' data-module='govuk-details'>"
+ "<summary class='govuk-details__summary'>"
+ "<span class='govuk-details__summary-text'>Help with airway bill and bill of landing</span>"
+ "<span class='govuk-details__summary-text'>Help with airway bill and bill of lading</span>"
+ "</summary>"
+ "<div class='govuk-details__text govuk'>"
+ "<p>"
Expand Down
2 changes: 1 addition & 1 deletion exporter/applications/forms/route_of_goods.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def route_of_goods_form(back_link):
"<br>"
+ "<details class='govuk-details' data-module='govuk-details'>"
+ "<summary class='govuk-details__summary'>"
+ "<span class='govuk-details__summary-text'>Help with airway bill and bill of landing</span>"
+ "<span class='govuk-details__summary-text'>Help with airway bill and bill of lading</span>"
+ "</summary>"
+ "<div class='govuk-details__text govuk'>"
+ "<p>"
Expand Down
2 changes: 1 addition & 1 deletion exporter/templates/applications/goods/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1 class="govuk-heading-l">
</div>

<p class="govuk-body">
Where possible, please add items in the same order as they are shown on the end user undertaking document. This will help case officers process applications quickly.
Where possible, please add items in the same order as they are shown on the end-user undertaking <a class="govuk-link" href="https://www.gov.uk/government/publications/end-user-undertaking-euu-form" target=”_blank”>form</a> (opens in new tab). This will help case officers process applications quickly.
</p>

{% if application.status.key in 'applicant_editing,draft' %}
Expand Down
5 changes: 5 additions & 0 deletions exporter/templates/core/hub.html
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,9 @@ <h2 class="govuk-!-margin-top-0">
</div>
</div>
{% endif %}
<div class="govuk-grid-row">
<div class="govuk-body govuk-grid-column-two-thirds govuk-!-margin-top-5">
{% comment %}/PS-IGNORE{% endcomment %}If you or any of your colleagues have accessibility needs, tell us how we can improve your user experience. Contact <a href="mailto:[email protected]">[email protected]</a>.
</div>
</div>
{% endblock %}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"private": true,
"scripts": {
"build_exporter": "parcel build ./exporter/assets/javascripts/main.js ./exporter/assets/javascripts/cookie-policy-form.js --dist-dir exporter/assets/built --public-url /assets/",
"build_caseworker": "parcel build ./caseworker/assets/javascripts/{main,head,bookmarks,cookie-policy-form,beis,tau,tau-edit,tau-multiple-assessment-edit,case-filters,refusal-review-consolidate,search-products}.js --dist-dir caseworker/assets/built --public-url /assets/",
"build_caseworker": "parcel build ./caseworker/assets/javascripts/{main,head,bookmarks,cookie-policy-form,desnz,tau,tau-edit,tau-multiple-assessment-edit,case-filters,refusal-review-consolidate,search-products}.js --dist-dir caseworker/assets/built --public-url /assets/",
"watch_exporter": "PARCEL_WORKERS=0 parcel watch --port 8400 ./exporter/assets/javascripts/{main,head}.js ./exporter/assets/javascripts/cookie-policy-form.js --dist-dir exporter/assets/built --public-url /assets/",
"watch_caseworker": "PARCEL_WORKERS=0 parcel watch --port 8401 ./caseworker/assets/javascripts/{main,head,bookmarks,cookie-policy-form,search-cases,beis,tau,tau-edit,tau-multiple-assessment-edit,case-filters,refusal-review-consolidate,search-products}.js --dist-dir caseworker/assets/built --public-url /assets/",
"watch_caseworker": "PARCEL_WORKERS=0 parcel watch --port 8401 ./caseworker/assets/javascripts/{main,head,bookmarks,cookie-policy-form,search-cases,desnz,tau,tau-edit,tau-multiple-assessment-edit,case-filters,refusal-review-consolidate,search-products}.js --dist-dir caseworker/assets/built --public-url /assets/",
"watch": "rm -rf .parcel-cache && npm run build_exporter && npm run build_caseworker && concurrently 'npm run watch_exporter' 'npm run watch_caseworker'",
"build": "npm install --no-save && npm run build_all",
"build_all": "export NODE_ENV=production && concurrently 'npm run build_exporter' 'npm run build_caseworker'",
Expand Down
36 changes: 36 additions & 0 deletions unit_tests/caseworker/cases/views/test_change_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,42 @@ def test_change_status_GET_provides_finalise_status(
assert (CaseStatusEnum.FINALISED in statuses) == expected


@pytest.mark.parametrize(
"gov_user_type,expected",
[
("mock_gov_tau_user", False),
("mock_gov_fcdo_user", False),
("mock_gov_desnz_nuclear_user", False),
("mock_gov_lu_user", False),
("mock_gov_lu_super_user", True),
],
)
def test_closed_status_visible_to_specific_roles(
authorized_client,
change_status_url,
case_id,
gov_user_type,
expected,
request,
):
_ = request.getfixturevalue(gov_user_type)

response = authorized_client.get(change_status_url)
assert response.status_code == 200

assertTemplateUsed(response, "layouts/case.html")
context = response.context
assert context["case"].id == case_id

html = BeautifulSoup(response.content, "html.parser")
all_h1s = [elem.get_text().strip() for elem in html.find_all("h1")]
assert "Change case status" in all_h1s

# Only LU users get an option set the status as 'Finalised'
statuses = [item["value"] for item in html.find_all("option")]
assert (CaseStatusEnum.CLOSED in statuses) == expected


def test_change_status_success(
authorized_client,
case_url,
Expand Down
17 changes: 16 additions & 1 deletion unit_tests/caseworker/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,22 @@ def mock_gov_lu_user(requests_mock, mock_notifications, mock_case_statuses, mock
requests_mock.get(url=re.compile(f"{url}{gov_uk_user_id}/"), json=mock_gov_user)


@pytest.fixture
def mock_gov_lu_super_user(requests_mock, mock_notifications, mock_case_statuses, mock_gov_user, gov_uk_user_id):
mock_gov_user["user"]["team"] = {
"id": "521154de-f39e-45bf-9922-baaaaaa",
"name": "Licencing Unit",
"alias": "LICENSING_UNIT",
}
mock_gov_user["user"]["role"]["statuses"].extend(
[{"id": "00000000-0000-0000-0000-000000000009", "key": "closed", "value": "Closed", "priority": 16}]
)

url = client._build_absolute_uri("/gov-users/")
requests_mock.get(url=f"{url}me/", json=mock_gov_user)
requests_mock.get(url=re.compile(f"{url}{gov_uk_user_id}/"), json=mock_gov_user)


@pytest.fixture
def mock_notifications(requests_mock):
url = client._build_absolute_uri("/gov-users/notifications/")
Expand Down Expand Up @@ -1605,7 +1621,6 @@ def mock_case_statuses(requests_mock):
"priority": 14,
},
{"id": "00000000-0000-0000-0000-000000000008", "key": "withdrawn", "value": "Withdrawn", "priority": 15},
{"id": "00000000-0000-0000-0000-000000000009", "key": "closed", "value": "Closed", "priority": 16},
{"id": "00000000-0000-0000-0000-000000000010", "key": "registered", "value": "Registered", "priority": 17},
{
"id": "00000000-0000-0000-0000-000000000011",
Expand Down
12 changes: 9 additions & 3 deletions unit_tests/caseworker/external_data/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def mock_denial_patch(requests_mock):

def test_upload_denial_404(authorized_client, mock_denial_upload, settings):
# given the case has activity from system user
url = reverse("external_data:denials-upload")
url = reverse(
"external_data:denials-add-by-csv"
) # TODO: rename back to ""denials-upload" when we are ready to release this to users

file_path = os.path.join(settings.BASE_DIR, "caseworker/external_data/example.csv")
data = {"csv_file": open(file_path, "rb")}
Expand All @@ -62,7 +64,9 @@ def test_upload_denial_404(authorized_client, mock_denial_upload, settings):
@pytest.mark.skip(reason="CSV denials upload has been disabled")
def test_upload_denial_valid_file(authorized_client, mock_denial_upload, settings):
# given the case has activity from system user
url = reverse("external_data:denials-upload")
url = reverse(
"external_data:denials-add-by-csv"
) # TODO: rename back to ""denials-upload" when we are ready to release this to users

file_path = os.path.join(settings.BASE_DIR, "caseworker/external_data/example.csv")
data = {"csv_file": open(file_path, "rb")}
Expand All @@ -80,7 +84,9 @@ def test_upload_denial_valid_file(authorized_client, mock_denial_upload, setting
@pytest.mark.skip(reason="CSV denials upload has been disabled")
def test_upload_denial_invalid_file(authorized_client, mock_denial_upload_validation_error, settings):
# given the case has activity from system user
url = reverse("external_data:denials-upload")
url = reverse(
"external_data:denials-add-by-csv"
) # TODO: rename back to ""denials-upload" when we are ready to release this to users

file_path = os.path.join(settings.BASE_DIR, "caseworker/external_data/example.csv")
data = {"csv_file": open(file_path, "rb")}
Expand Down

0 comments on commit a8972c5

Please sign in to comment.