Skip to content
Draft
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
20 changes: 10 additions & 10 deletions app/celery/research_mode_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def ses_notification_callback(reference):
"processingTimeMillis": 2003,
"recipients": ["success@simulator.amazonses.com"],
"remoteMtaIp": "123.123.123.123",
"reportingMTA": "a7-32.smtp-out.eu-west-1.amazonses.com",
"reportingMTA": "a7-32.smtp-out.eu-west-2.amazonses.com",
"smtpResponse": "250 2.6.0 Message received",
"timestamp": uniform_timestamp,
},
Expand All @@ -256,7 +256,7 @@ def ses_notification_callback(reference):
"messageId": reference,
"sendingAccountId": "12341234",
"source": '"TEST" <TEST@notify.works>',
"sourceArn": "arn:aws:ses:eu-west-1:12341234:identity/notify.works",
"sourceArn": "arn:aws:ses:eu-west-2:12341234:identity/notify.works",
"sourceIp": "0.0.0.1",
"timestamp": uniform_timestamp,
},
Expand All @@ -266,14 +266,14 @@ def ses_notification_callback(reference):
return {
"Type": "Notification",
"MessageId": "8e83c020-1234-1234-1234-92a8ee9baa0a",
"TopicArn": "arn:aws:sns:eu-west-1:12341234:ses_notifications",
"TopicArn": "arn:aws:sns:eu-west-2:12341234:ses_notifications",
"Subject": None,
"Message": json.dumps(ses_message_body),
"Timestamp": uniform_timestamp,
"SignatureVersion": "1",
"Signature": "[REDACTED]",
"SigningCertUrl": "https://sns.eu-west-1.amazonaws.com/SimpleNotificationService-[REDACTED].pem",
"UnsubscribeUrl": "https://sns.eu-west-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=[REACTED]",
"SigningCertUrl": "https://sns.eu-west-2.amazonaws.com/SimpleNotificationService-[REDACTED].pem",
"UnsubscribeUrl": "https://sns.eu-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=[REACTED]",
"MessageAttributes": {},
}

Expand Down Expand Up @@ -302,7 +302,7 @@ def _ses_bounce_callback(reference, bounce_type):
],
"feedbackId": "0102015fc9e676fb-12341234-1234-1234-1234-9301e86a4fa8-000000",
"remoteMtaIp": "123.123.123.123",
"reportingMTA": "dsn; a7-31.smtp-out.eu-west-1.amazonses.com",
"reportingMTA": "dsn; a7-31.smtp-out.eu-west-2.amazonses.com",
"timestamp": uniform_timestamp,
},
"mail": {
Expand All @@ -326,7 +326,7 @@ def _ses_bounce_callback(reference, bounce_type):
"messageId": reference,
"sendingAccountId": "12341234",
"source": '"TEST" <TEST@notify.works>',
"sourceArn": "arn:aws:ses:eu-west-1:12341234:identity/notify.works",
"sourceArn": "arn:aws:ses:eu-west-2:12341234:identity/notify.works",
"sourceIp": "0.0.0.1",
"timestamp": uniform_timestamp,
},
Expand All @@ -335,13 +335,13 @@ def _ses_bounce_callback(reference, bounce_type):
return {
"Type": "Notification",
"MessageId": "36e67c28-1234-1234-1234-2ea0172aa4a7",
"TopicArn": "arn:aws:sns:eu-west-1:12341234:ses_notifications",
"TopicArn": "arn:aws:sns:eu-west-2:12341234:ses_notifications",
"Subject": None,
"Message": json.dumps(ses_message_body),
"Timestamp": uniform_timestamp,
"SignatureVersion": "1",
"Signature": "[REDACTED]",
"SigningCertUrl": "https://sns.eu-west-1.amazonaws.com/SimpleNotificationService-[REDACTED]].pem",
"UnsubscribeUrl": "https://sns.eu-west-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=[REDACTED]]",
"SigningCertUrl": "https://sns.eu-west-2.amazonaws.com/SimpleNotificationService-[REDACTED]].pem",
"UnsubscribeUrl": "https://sns.eu-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=[REDACTED]]",
"MessageAttributes": {},
}
4 changes: 2 additions & 2 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class Config:
###########################

NOTIFY_ENVIRONMENT = os.environ.get("NOTIFY_ENVIRONMENT", "development")
AWS_REGION = "eu-west-1"
AWS_REGION = "eu-west-2"
INVITATION_EXPIRATION_DAYS = 2
NOTIFY_APP_NAME = "api"

Expand Down Expand Up @@ -267,7 +267,7 @@ class Config:

AWS_ACCOUNT_ID = os.environ.get("AWS_ACCOUNT_ID", "123456789012")
CELERY = {
"broker_url": "https://sqs.eu-west-1.amazonaws.com",
"broker_url": "https://sqs.eu-west-2.amazonaws.com",
"broker_transport": "sqs",
"task_ignore_result": True,
"broker_transport_options": {
Expand Down
30 changes: 15 additions & 15 deletions tests/app/celery/test_letters_pdf_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,19 +591,19 @@ def test_process_sanitised_letter_with_valid_letter(
scan_bucket_name = current_app.config["S3_BUCKET_LETTERS_SCAN"]
template_preview_bucket_name = current_app.config["S3_BUCKET_LETTER_SANITISE"]
destination_bucket_name = current_app.config[destination_bucket]
conn = boto3.resource("s3", region_name="eu-west-1")
conn = boto3.resource("s3", region_name="eu-west-2")

scan_bucket = conn.create_bucket(
Bucket=scan_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"}
Bucket=scan_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"}
)
template_preview_bucket = conn.create_bucket(
Bucket=template_preview_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"}
Bucket=template_preview_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"}
)
destination_bucket = conn.create_bucket(
Bucket=destination_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"}
Bucket=destination_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"}
)

s3 = boto3.client("s3", region_name="eu-west-1")
s3 = boto3.client("s3", region_name="eu-west-2")
s3.put_object(Bucket=scan_bucket_name, Key=filename, Body=b"original_pdf_content")
s3.put_object(Bucket=template_preview_bucket_name, Key=filename, Body=b"sanitised_pdf_content")

Expand Down Expand Up @@ -656,14 +656,14 @@ def test_process_sanitised_letter_sets_postage_international(
scan_bucket_name = current_app.config["S3_BUCKET_LETTERS_SCAN"]
template_preview_bucket_name = current_app.config["S3_BUCKET_LETTER_SANITISE"]
destination_bucket_name = current_app.config["S3_BUCKET_LETTERS_PDF"]
conn = boto3.resource("s3", region_name="eu-west-1")
conn.create_bucket(Bucket=scan_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
conn = boto3.resource("s3", region_name="eu-west-2")
conn.create_bucket(Bucket=scan_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})
conn.create_bucket(
Bucket=template_preview_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"}
Bucket=template_preview_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"}
)
conn.create_bucket(Bucket=destination_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
conn.create_bucket(Bucket=destination_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})

s3 = boto3.client("s3", region_name="eu-west-1")
s3 = boto3.client("s3", region_name="eu-west-2")
s3.put_object(Bucket=scan_bucket_name, Key=filename, Body=b"original_pdf_content")
s3.put_object(Bucket=template_preview_bucket_name, Key=filename, Body=b"sanitised_pdf_content")

Expand Down Expand Up @@ -699,19 +699,19 @@ def test_process_sanitised_letter_with_invalid_letter(sample_letter_notification
scan_bucket_name = current_app.config["S3_BUCKET_LETTERS_SCAN"]
template_preview_bucket_name = current_app.config["S3_BUCKET_LETTER_SANITISE"]
invalid_letter_bucket_name = current_app.config["S3_BUCKET_INVALID_PDF"]
conn = boto3.resource("s3", region_name="eu-west-1")
conn = boto3.resource("s3", region_name="eu-west-2")

scan_bucket = conn.create_bucket(
Bucket=scan_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"}
Bucket=scan_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"}
)
template_preview_bucket = conn.create_bucket(
Bucket=template_preview_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"}
Bucket=template_preview_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"}
)
invalid_letter_bucket = conn.create_bucket(
Bucket=invalid_letter_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"}
Bucket=invalid_letter_bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"}
)

s3 = boto3.client("s3", region_name="eu-west-1")
s3 = boto3.client("s3", region_name="eu-west-2")
s3.put_object(Bucket=scan_bucket_name, Key=filename, Body=b"original_pdf_content")

sample_letter_notification.status = NOTIFICATION_PENDING_VIRUS_CHECK
Expand Down
4 changes: 2 additions & 2 deletions tests/app/celery/test_nightly_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ def test_deep_archive_notification_history_hour_starting_happy_path(
set_config(notify_api, "NOTIFICATION_DEEP_HISTORY_DELETE_ARCHIVED", delete_archived),
):
s3 = boto3.client("s3")
s3.create_bucket(Bucket="deep-bucket", CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
s3.create_bucket(Bucket="deep-bucket", CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})

_populate_notification_history(sample_template, sample_job)

Expand Down Expand Up @@ -1336,7 +1336,7 @@ def test_deep_archive_notification_history_hour_starting_delete_fails(
db.engine.connect() as alt_conn,
):
s3 = boto3.client("s3")
s3.create_bucket(Bucket="deep-bucket", CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
s3.create_bucket(Bucket="deep-bucket", CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})

_populate_notification_history(sample_template, sample_job)

Expand Down
24 changes: 12 additions & 12 deletions tests/app/celery/test_provider_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ def test_deliver_letter(
sample_letter_template.service.organisation = sample_organisation

pdf_bucket = current_app.config["S3_BUCKET_LETTERS_PDF"]
s3 = boto3.client("s3", region_name="eu-west-1")
s3.create_bucket(Bucket=pdf_bucket, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
s3 = boto3.client("s3", region_name="eu-west-2")
s3.create_bucket(Bucket=pdf_bucket, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})
s3.put_object(Bucket=pdf_bucket, Key="2020-02-17/NOTIFY.REF1.D.2.C.20200217150000.PDF", Body=b"file")

deliver_letter(letter.id)
Expand Down Expand Up @@ -297,8 +297,8 @@ def test_deliver_letter_when_file_is_not_in_S3_logs_an_error(mocker, sample_lett
sample_letter_template.service.organisation = sample_organisation

pdf_bucket = current_app.config["S3_BUCKET_LETTERS_PDF"]
s3 = boto3.client("s3", region_name="eu-west-1")
s3.create_bucket(Bucket=pdf_bucket, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
s3 = boto3.client("s3", region_name="eu-west-2")
s3.create_bucket(Bucket=pdf_bucket, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})

with pytest.raises(NotificationTechnicalFailureException) as e:
deliver_letter(letter.id)
Expand Down Expand Up @@ -343,8 +343,8 @@ def test_deliver_letter_retries_when_there_is_a_retryable_exception(
sample_letter_template.service.organisation = sample_organisation

pdf_bucket = current_app.config["S3_BUCKET_LETTERS_PDF"]
s3 = boto3.client("s3", region_name="eu-west-1")
s3.create_bucket(Bucket=pdf_bucket, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
s3 = boto3.client("s3", region_name="eu-west-2")
s3.create_bucket(Bucket=pdf_bucket, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})
s3.put_object(Bucket=pdf_bucket, Key="2020-02-17/NOTIFY.REF1.D.2.C.20200217150000.PDF", Body=b"file")

with caplog.at_level("WARNING"):
Expand Down Expand Up @@ -388,8 +388,8 @@ def test_deliver_letter_logs_a_warning_when_the_print_request_is_duplicate(
sample_letter_template.service.organisation = sample_organisation

pdf_bucket = current_app.config["S3_BUCKET_LETTERS_PDF"]
s3 = boto3.client("s3", region_name="eu-west-1")
s3.create_bucket(Bucket=pdf_bucket, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
s3 = boto3.client("s3", region_name="eu-west-2")
s3.create_bucket(Bucket=pdf_bucket, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})
s3.put_object(Bucket=pdf_bucket, Key="2020-02-17/NOTIFY.REF1.D.2.C.20200217150000.PDF", Body=b"file")

with caplog.at_level("WARNING"):
Expand Down Expand Up @@ -468,8 +468,8 @@ def test_deliver_letter_when_there_is_a_non_retryable_error(
sample_letter_template.service.organisation = sample_organisation

pdf_bucket = current_app.config["S3_BUCKET_LETTERS_PDF"]
s3 = boto3.client("s3", region_name="eu-west-1")
s3.create_bucket(Bucket=pdf_bucket, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
s3 = boto3.client("s3", region_name="eu-west-2")
s3.create_bucket(Bucket=pdf_bucket, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})
s3.put_object(Bucket=pdf_bucket, Key="2020-02-17/NOTIFY.REF1.D.2.C.20200217150000.PDF", Body=b"file")

with pytest.raises(NotificationTechnicalFailureException) as e:
Expand Down Expand Up @@ -505,8 +505,8 @@ def test_deliver_letter_when_max_retries_are_reached(mocker, sample_letter_templ
sample_letter_template.service.organisation = sample_organisation

pdf_bucket = current_app.config["S3_BUCKET_LETTERS_PDF"]
s3 = boto3.client("s3", region_name="eu-west-1")
s3.create_bucket(Bucket=pdf_bucket, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
s3 = boto3.client("s3", region_name="eu-west-2")
s3.create_bucket(Bucket=pdf_bucket, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})
s3.put_object(Bucket=pdf_bucket, Key="2020-02-17/NOTIFY.REF1.D.2.C.20200217150000.PDF", Body=b"file")

with pytest.raises(NotificationTechnicalFailureException) as e:
Expand Down
2 changes: 1 addition & 1 deletion tests/app/clients/test_dvla.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@pytest.fixture
def ssm():
with mock_aws():
ssm_client = boto3.client("ssm", "eu-west-1")
ssm_client = boto3.client("ssm", "eu-west-2")
ssm_client.put_parameter(
Name="/notify/api/dvla_username",
Value="some username",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def test_every_column_in_notification_history_is_filled_with_data_from_notificat
@mock_aws
@freeze_time("2019-09-01 04:30")
def test_move_notifications_deletes_letters_from_s3(sample_letter_template):
s3 = boto3.client("s3", region_name="eu-west-1")
s3 = boto3.client("s3", region_name="eu-west-2")
bucket_name = current_app.config["S3_BUCKET_LETTERS_PDF"]
s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})

eight_days_ago = datetime.utcnow() - timedelta(days=8)
create_notification(
Expand All @@ -59,9 +59,9 @@ def test_move_notifications_deletes_letters_from_s3(sample_letter_template):
@mock_aws
@freeze_time("2019-09-01 04:30")
def test_move_notifications_deletes_same_letter_from_s3_as_notifications(sample_letter_template):
s3 = boto3.client("s3", region_name="eu-west-1")
s3 = boto3.client("s3", region_name="eu-west-2")
bucket_name = current_app.config["S3_BUCKET_LETTERS_PDF"]
s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})

noti_a_timestamp = datetime.utcnow() - timedelta(days=8)
noti_b_timestamp = datetime.utcnow() - timedelta(days=8, seconds=1)
Expand Down Expand Up @@ -103,10 +103,10 @@ def test_move_notifications_deletes_same_letter_from_s3_as_notifications(sample_
@mock_aws
@freeze_time("2019-09-01 04:30")
def test_move_notifications_copes_if_letter_not_in_s3(sample_letter_template):
s3 = boto3.client("s3", region_name="eu-west-1")
s3 = boto3.client("s3", region_name="eu-west-2")
s3.create_bucket(
Bucket=current_app.config["S3_BUCKET_LETTERS_PDF"],
CreateBucketConfiguration={"LocationConstraint": "eu-west-1"},
CreateBucketConfiguration={"LocationConstraint": "eu-west-2"},
)

eight_days_ago = datetime.utcnow() - timedelta(days=8)
Expand Down Expand Up @@ -165,8 +165,8 @@ def test_move_notifications_deletes_letters_sent_and_in_final_state_from_table_a
sample_service, notification_status
):
bucket_name = current_app.config["S3_BUCKET_LETTERS_PDF"]
s3 = boto3.client("s3", region_name="eu-west-1")
s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
s3 = boto3.client("s3", region_name="eu-west-2")
s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})

letter_template = create_template(service=sample_service, template_type="letter")
eight_days_ago = datetime.utcnow() - timedelta(days=8)
Expand Down Expand Up @@ -198,8 +198,8 @@ def test_move_notifications_deletes_letters_sent_and_in_final_state_from_table_a
@freeze_time("2020-12-24 04:30")
def test_move_notifications_deletes_letters_that_failed_validation_from_table_and_s3_invalid_bucket(sample_service):
bucket_name = current_app.config["S3_BUCKET_INVALID_PDF"]
s3 = boto3.client("s3", region_name="eu-west-1")
s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
s3 = boto3.client("s3", region_name="eu-west-2")
s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})

letter_template = create_template(service=sample_service, template_type="letter")
eight_days_ago = datetime.utcnow() - timedelta(days=8)
Expand Down Expand Up @@ -350,9 +350,9 @@ def test_delete_test_notifications(sample_template, sample_email_template):
@mock_aws
@freeze_time("2024-09-01 04:30")
def test_delete_test_notifications_deletes_letters_from_s3(sample_letter_template):
s3 = boto3.client("s3", region_name="eu-west-1")
s3 = boto3.client("s3", region_name="eu-west-2")
bucket_name = current_app.config["S3_BUCKET_TEST_LETTERS"]
s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})

eight_days_ago = datetime.utcnow() - timedelta(days=8)
create_notification(
Expand All @@ -376,9 +376,9 @@ def test_delete_test_notifications_deletes_letters_from_s3(sample_letter_templat
@mock_aws
@freeze_time("2019-09-01 04:30")
def test_delete_test_notifications_deletes_same_letter_from_s3_as_notifications(sample_letter_template):
s3 = boto3.client("s3", region_name="eu-west-1")
s3 = boto3.client("s3", region_name="eu-west-2")
bucket_name = current_app.config["S3_BUCKET_TEST_LETTERS"]
s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-1"})
s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": "eu-west-2"})

noti_a_timestamp = datetime.utcnow() - timedelta(days=8)
noti_b_timestamp = datetime.utcnow() - timedelta(days=8, seconds=1)
Expand Down Expand Up @@ -422,10 +422,10 @@ def test_delete_test_notifications_deletes_same_letter_from_s3_as_notifications(
@mock_aws
@freeze_time("2019-09-01 04:30")
def test_delete_test_notifications_copes_if_letter_not_in_s3(sample_letter_template, caplog):
s3 = boto3.client("s3", region_name="eu-west-1")
s3 = boto3.client("s3", region_name="eu-west-2")
s3.create_bucket(
Bucket=current_app.config["S3_BUCKET_TEST_LETTERS"],
CreateBucketConfiguration={"LocationConstraint": "eu-west-1"},
CreateBucketConfiguration={"LocationConstraint": "eu-west-2"},
)

eight_days_ago = datetime.utcnow() - timedelta(days=8)
Expand Down
Loading
Loading