-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into dependabot/pip/cryptography-44.0.1
- Loading branch information
Showing
12 changed files
with
204 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,23 +3,20 @@ | |
# Exit early if something goes wrong | ||
set -e | ||
|
||
git_clone_base_url="https://codestar-connections.eu-west-2.amazonaws.com/git-http/$AWS_ACCOUNT_ID/eu-west-2/$CODESTAR_CONNECTION_ID/uktrade" | ||
if [ -f "./.gitmodules" ]; then | ||
echo ".gitmodules file exists. Modifying URLs..." | ||
account_id=$(echo $CODESTAR_CONNECTION_ARN | cut -d':' -f5) | ||
connection_id=$(echo $CODESTAR_CONNECTION_ARN | cut -d'/' -f2) | ||
git_clone_base_url="https://codestar-connections.eu-west-2.amazonaws.com/git-http/$account_id/eu-west-2/$connection_id/uktrade" | ||
|
||
git config --global credential.helper '!aws codecommit credential-helper $@' | ||
git config --global credential.UseHttpPath true | ||
git config --global credential.helper '!aws codecommit credential-helper $@' | ||
git config --global credential.UseHttpPath true | ||
|
||
cat <<EOF > ./.gitmodules | ||
[submodule "lite-content"] | ||
path = lite_content | ||
url = $git_clone_base_url/lite-content.git | ||
branch = master | ||
[submodule "lite_routing"] | ||
path = lite_routing | ||
url = $git_clone_base_url/lite-routing.git | ||
branch = main | ||
[submodule "django_db_anonymiser"] | ||
path = django_db_anonymiser | ||
url = $git_clone_base_url/django-db-anonymiser.git | ||
EOF | ||
sed -i "s|url = [email protected]:uktrade/\(.*\).git|url = $git_clone_base_url/\1.git|g" ./.gitmodules | ||
|
||
git submodule update --init --recursive | ||
|
||
git submodule update --init --recursive | ||
|
||
else | ||
echo ".gitmodules file does not exist. No URLs to update." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
from django.urls import reverse | ||
from rest_framework import status | ||
from random import randint | ||
from unittest import mock | ||
from api.core.authentication import EXPORTER_USER_TOKEN_HEADER | ||
from api.users.libraries.user_to_token import user_to_token | ||
from test_helpers.clients import DataTestClient | ||
from api.organisations.enums import OrganisationType | ||
from lite_content.lite_api.strings import Addresses | ||
|
||
|
||
class AddressSerializerPostcodeValidationTest(DataTestClient): | ||
url = reverse("organisations:organisations") | ||
|
||
@mock.patch("api.core.celery_tasks.NotificationsAPIClient.send_email_notification") | ||
def test_required_address_fields(self, mock_gov_notification): | ||
data = { | ||
"name": "Lemonworld Co", | ||
"type": OrganisationType.COMMERCIAL, | ||
"eori_number": "GB123456789000", | ||
"sic_number": "01110", | ||
"vat_number": "GB123456789", | ||
"registration_number": "98765432", | ||
"site": { | ||
"name": "Headquarters", | ||
"address": { | ||
"address_line_1": "42 Industrial Estate", | ||
"address_line_2": "w3r", | ||
"region": "", | ||
"city": "St Albans", | ||
"postcode": "BT32 4PX", | ||
}, | ||
}, | ||
"user": {"email": "[email protected]"}, | ||
"phone_number": "+441234567895", | ||
"website": "", | ||
} | ||
|
||
data["registration_number"] = "".join([str(randint(0, 9)) for _ in range(8)]) | ||
response = self.client.post( | ||
self.url, data, **{EXPORTER_USER_TOKEN_HEADER: user_to_token(self.exporter_user.baseuser_ptr)} | ||
) | ||
self.assertEqual(response.status_code, status.HTTP_201_CREATED) | ||
|
||
@mock.patch("api.core.celery_tasks.NotificationsAPIClient.send_email_notification") | ||
def test_valid(self, mock_gov_notification): | ||
data = { | ||
"name": "Lemonworld Co", | ||
"type": OrganisationType.COMMERCIAL, | ||
"eori_number": "GB123456789000", | ||
"sic_number": "01110", | ||
"vat_number": "GB123456789", | ||
"registration_number": "98765432", | ||
"site": { | ||
"name": "Headquarters", | ||
"address": { | ||
"address_line_1": "42 Industrial Estate", | ||
"address_line_2": "Queens Road", | ||
"region": "Hertfordshire", | ||
"city": "St Albans", | ||
"postcode": "BT32 4PX", | ||
}, | ||
}, | ||
"user": {"email": "[email protected]"}, | ||
"phone_number": "+441234567895", | ||
"website": "", | ||
} | ||
|
||
data["registration_number"] = "".join([str(randint(0, 9)) for _ in range(8)]) | ||
response = self.client.post( | ||
self.url, data, **{EXPORTER_USER_TOKEN_HEADER: user_to_token(self.exporter_user.baseuser_ptr)} | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_201_CREATED) | ||
|
||
@mock.patch("api.core.celery_tasks.NotificationsAPIClient.send_email_notification") | ||
def test_empty_address_fields(self, mock_gov_notification): | ||
data = { | ||
"name": "Lemonworld Co", | ||
"type": OrganisationType.COMMERCIAL, | ||
"eori_number": "GB123456789000", | ||
"sic_number": "01110", | ||
"vat_number": "GB123456789", | ||
"registration_number": "98765432", | ||
"site": { | ||
"name": "Headquarters", | ||
"address": { | ||
"address_line_1": "", | ||
"address_line_2": "", | ||
"region": "", | ||
"city": "", | ||
"postcode": "", | ||
}, | ||
}, | ||
"user": {"email": "[email protected]"}, | ||
"phone_number": "+441234567895", | ||
"website": "", | ||
} | ||
|
||
data["registration_number"] = "".join([str(randint(0, 9)) for _ in range(8)]) | ||
response = self.client.post( | ||
self.url, data, **{EXPORTER_USER_TOKEN_HEADER: user_to_token(self.exporter_user.baseuser_ptr)} | ||
) | ||
address = response.json()["errors"]["site"]["address"] | ||
|
||
self.assertEqual(address["postcode"][0], Addresses.POSTCODE) | ||
self.assertEqual(address["address_line_1"][0], Addresses.ADDRESS_LINE_1) | ||
self.assertEqual(address["city"][0], Addresses.CITY) | ||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ | |
licence_views.LicencesListDW, | ||
basename="dw-licences-only", | ||
) | ||
|
||
urlpatterns = router_v0.urls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters