From 2449cb17dc8ac71c06bf5cda1f43614557845c14 Mon Sep 17 00:00:00 2001 From: Emmet Cassidy Date: Wed, 23 Oct 2024 16:39:07 +0100 Subject: [PATCH 1/2] Amending env var names to match new rationalised names --- scripts/run_with_docker.sh | 22 +++---- .../notify/ClientIntegrationTestIT.java | 62 +++++++++---------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/scripts/run_with_docker.sh b/scripts/run_with_docker.sh index 0d7a4ea..6190846 100755 --- a/scripts/run_with_docker.sh +++ b/scripts/run_with_docker.sh @@ -7,17 +7,17 @@ docker run \ --rm \ -v "`pwd`:/var/project" \ -v `pwd`/.m2:/root/.m2 \ - -e NOTIFY_API_URL=${NOTIFY_API_URL} \ - -e API_KEY=${API_KEY} \ - -e FUNCTIONAL_TEST_NUMBER=${FUNCTIONAL_TEST_NUMBER} \ - -e FUNCTIONAL_TEST_EMAIL=${FUNCTIONAL_TEST_EMAIL} \ - -e EMAIL_TEMPLATE_ID=${EMAIL_TEMPLATE_ID} \ - -e SMS_TEMPLATE_ID=${SMS_TEMPLATE_ID} \ - -e LETTER_TEMPLATE_ID=${LETTER_TEMPLATE_ID} \ - -e EMAIL_REPLY_TO_ID=${EMAIL_REPLY_TO_ID} \ - -e SMS_SENDER_ID=${SMS_SENDER_ID} \ - -e API_SENDING_KEY=${API_SENDING_KEY} \ - -e INBOUND_SMS_QUERY_KEY=${INBOUND_SMS_QUERY_KEY} \ + -e API_CLIENT_INTEGRATION_TESTS_NOTIFY_API_URL=${API_CLIENT_INTEGRATION_TESTS_NOTIFY_API_URL} \ + -e API_CLIENT_INTEGRATION_TESTS_TEST_API_KEY=${API_CLIENT_INTEGRATION_TESTS_TEST_API_KEY} \ + -e API_CLIENT_INTEGRATION_TESTS_NUMBER=${API_CLIENT_INTEGRATION_TESTS_NUMBER} \ + -e API_CLIENT_INTEGRATION_TESTS_EMAIL=${API_CLIENT_INTEGRATION_TESTS_EMAIL} \ + -e API_CLIENT_INTEGRATION_TESTS_EMAIL_TEMPLATE_ID=${API_CLIENT_INTEGRATION_TESTS_EMAIL_TEMPLATE_ID} \ + -e API_CLIENT_INTEGRATION_TESTS_SMS_TEMPLATE_ID=${API_CLIENT_INTEGRATION_TESTS_SMS_TEMPLATE_ID} \ + -e API_CLIENT_INTEGRATION_TESTS_LETTER_TEMPLATE_ID=${API_CLIENT_INTEGRATION_TESTS_LETTER_TEMPLATE_ID} \ + -e API_CLIENT_INTEGRATION_TESTS_EMAIL_REPLY_TO_ID=${API_CLIENT_INTEGRATION_TESTS_EMAIL_REPLY_TO_ID} \ + -e API_CLIENT_INTEGRATION_TESTS_SMS_SENDER_ID=${API_CLIENT_INTEGRATION_TESTS_SMS_SENDER_ID} \ + -e API_CLIENT_INTEGRATION_TESTS_TEAM_API_KEY=${API_CLIENT_INTEGRATION_TESTS_TEAM_API_KEY} \ + -e API_CLIENT_INTEGRATION_TESTS_INBOUND_SMS_API_KEY=${API_CLIENT_INTEGRATION_TESTS_INBOUND_SMS_API_KEY} \ -it \ ${DOCKER_IMAGE_NAME} \ ${@} diff --git a/src/test/java/uk/gov/service/notify/ClientIntegrationTestIT.java b/src/test/java/uk/gov/service/notify/ClientIntegrationTestIT.java index ab2459e..e8b9f4d 100644 --- a/src/test/java/uk/gov/service/notify/ClientIntegrationTestIT.java +++ b/src/test/java/uk/gov/service/notify/ClientIntegrationTestIT.java @@ -58,7 +58,7 @@ public void testGetAllNotifications() throws NotificationClientException { assertFalse(notificationList.getNotifications().isEmpty()); // Just check the first notification in the list. assertNotification(notificationList.getNotifications().get(0)); - String baseUrl = System.getenv("NOTIFY_API_URL"); + String baseUrl = System.getenv("API_CLIENT_INTEGRATION_TESTS_NOTIFY_API_URL"); assertEquals(baseUrl + "/v2/notifications", notificationList.getCurrentPageLink()); if (notificationList.getNextPageLink().isPresent()){ String nextUri = notificationList.getNextPageLink().get(); @@ -74,7 +74,7 @@ public void testGetAllNotifications() throws NotificationClientException { public void testEmailNotificationWithoutPersonalisationReturnsErrorMessageIT() { NotificationClient client = getClient(); try { - client.sendEmail(System.getenv("EMAIL_TEMPLATE_ID"), System.getenv("FUNCTIONAL_TEST_EMAIL"), null, null); + client.sendEmail(System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL_TEMPLATE_ID"), System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL"), null, null); fail("Expected NotificationClientException: Template missing personalisation: name"); } catch (NotificationClientException e) { assert(e.getMessage().contains("Missing personalisation: name")); @@ -93,11 +93,11 @@ public void testEmailNotificationWithValidEmailReplyToIdIT() throws Notification personalisation.put("name", uniqueName); SendEmailResponse response = client.sendEmail( - System.getenv("EMAIL_TEMPLATE_ID"), - System.getenv("FUNCTIONAL_TEST_EMAIL"), + System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL_TEMPLATE_ID"), + System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL"), personalisation, uniqueName, - System.getenv("EMAIL_REPLY_TO_ID")); + System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL_REPLY_TO_ID")); assertNotificationEmailResponse(response, uniqueName); @@ -120,8 +120,8 @@ public void testEmailNotificationWithInValidEmailReplyToIdIT() throws Notificati try { client.sendEmail( - System.getenv("EMAIL_TEMPLATE_ID"), - System.getenv("FUNCTIONAL_TEST_EMAIL"), + System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL_TEMPLATE_ID"), + System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL"), personalisation, uniqueName, fake_uuid.toString()); @@ -147,8 +147,8 @@ public void testEmailNotificationWithUploadedDocumentInPersonalisation() throws personalisation.put("name", documentFileObject); String reference = UUID.randomUUID().toString(); - SendEmailResponse emailResponse = client.sendEmail(System.getenv("EMAIL_TEMPLATE_ID"), - System.getenv("FUNCTIONAL_TEST_EMAIL"), + SendEmailResponse emailResponse = client.sendEmail(System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL_TEMPLATE_ID"), + System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL"), personalisation, reference ); @@ -161,7 +161,7 @@ public void testEmailNotificationWithUploadedDocumentInPersonalisation() throws public void testSmsNotificationWithoutPersonalisationReturnsErrorMessageIT() { NotificationClient client = getClient(); try { - client.sendSms(System.getenv("SMS_TEMPLATE_ID"), System.getenv("FUNCTIONAL_TEST_NUMBER"), null, null); + client.sendSms(System.getenv("API_CLIENT_INTEGRATION_TESTS_SMS_TEMPLATE_ID"), System.getenv("API_CLIENT_INTEGRATION_TESTS_NUMBER"), null, null); fail("Expected NotificationClientException: Template missing personalisation: name"); } catch (NotificationClientException e) { assert(e.getMessage().contains("Missing personalisation: name")); @@ -171,18 +171,18 @@ public void testSmsNotificationWithoutPersonalisationReturnsErrorMessageIT() { @Test public void testSmsNotificationWithValidSmsSenderIdIT() throws NotificationClientException { - NotificationClient client = getClient("API_SENDING_KEY"); + NotificationClient client = getClient("API_CLIENT_INTEGRATION_TESTS_TEAM_API_KEY"); HashMap personalisation = new HashMap<>(); String uniqueName = UUID.randomUUID().toString(); personalisation.put("name", uniqueName); SendSmsResponse response = client.sendSms( - System.getenv("SMS_TEMPLATE_ID"), - System.getenv("FUNCTIONAL_TEST_NUMBER"), + System.getenv("API_CLIENT_INTEGRATION_TESTS_SMS_TEMPLATE_ID"), + System.getenv("API_CLIENT_INTEGRATION_TESTS_NUMBER"), personalisation, uniqueName, - System.getenv("SMS_SENDER_ID")); + System.getenv("API_CLIENT_INTEGRATION_TESTS_SMS_SENDER_ID")); assertNotificationSmsResponse(response, uniqueName); @@ -204,8 +204,8 @@ public void testSmsNotificationWithInValidSmsSenderIdIT() { try { client.sendSms( - System.getenv("SMS_TEMPLATE_ID"), - System.getenv("FUNCTIONAL_TEST_NUMBER"), + System.getenv("API_CLIENT_INTEGRATION_TESTS_SMS_TEMPLATE_ID"), + System.getenv("API_CLIENT_INTEGRATION_TESTS_NUMBER"), personalisation, uniqueName, fake_uuid.toString()); @@ -224,7 +224,7 @@ public void testSendAndGetNotificationWithReference() throws NotificationClientE HashMap personalisation = new HashMap<>(); String uniqueString = UUID.randomUUID().toString(); personalisation.put("name", uniqueString); - SendEmailResponse response = client.sendEmail(System.getenv("EMAIL_TEMPLATE_ID"), System.getenv("FUNCTIONAL_TEST_EMAIL"), personalisation, uniqueString); + SendEmailResponse response = client.sendEmail(System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL_TEMPLATE_ID"), System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL"), personalisation, uniqueString); assertNotificationEmailResponse(response, uniqueString); NotificationList notifications = client.getNotifications(null, null, uniqueString, null); assertEquals(1, notifications.getNotifications().size()); @@ -234,8 +234,8 @@ public void testSendAndGetNotificationWithReference() throws NotificationClientE @Test public void testGetTemplateById() throws NotificationClientException { NotificationClient client = getClient(); - Template template = client.getTemplateById(System.getenv("LETTER_TEMPLATE_ID")); - assertEquals(System.getenv("LETTER_TEMPLATE_ID"), template.getId().toString()); + Template template = client.getTemplateById(System.getenv("API_CLIENT_INTEGRATION_TESTS_LETTER_TEMPLATE_ID")); + assertEquals(System.getenv("API_CLIENT_INTEGRATION_TESTS_LETTER_TEMPLATE_ID"), template.getId().toString()); assertNotNull(template.getCreatedAt()); assertNotNull(template.getTemplateType()); assertNotNull(template.getBody()); @@ -248,8 +248,8 @@ public void testGetTemplateById() throws NotificationClientException { @Test public void testGetTemplateVersion() throws NotificationClientException { NotificationClient client = getClient(); - Template template = client.getTemplateVersion(System.getenv("SMS_TEMPLATE_ID"), 1); - assertEquals(System.getenv("SMS_TEMPLATE_ID"), template.getId().toString()); + Template template = client.getTemplateVersion(System.getenv("API_CLIENT_INTEGRATION_TESTS_SMS_TEMPLATE_ID"), 1); + assertEquals(System.getenv("API_CLIENT_INTEGRATION_TESTS_SMS_TEMPLATE_ID"), template.getId().toString()); assertNotNull(template.getCreatedAt()); assertNotNull(template.getTemplateType()); assertNotNull(template.getBody()); @@ -270,8 +270,8 @@ public void testGenerateTemplatePreview() throws NotificationClientException { HashMap personalisation = new HashMap<>(); String uniqueName = UUID.randomUUID().toString(); personalisation.put("name", uniqueName); - TemplatePreview template = client.generateTemplatePreview(System.getenv("EMAIL_TEMPLATE_ID"), personalisation); - assertEquals(System.getenv("EMAIL_TEMPLATE_ID"), template.getId().toString()); + TemplatePreview template = client.generateTemplatePreview(System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL_TEMPLATE_ID"), personalisation); + assertEquals(System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL_TEMPLATE_ID"), template.getId().toString()); assertNotNull(template.getTemplateType()); assertNotNull(template.getBody()); assertNotNull(template.getSubject()); @@ -280,7 +280,7 @@ public void testGenerateTemplatePreview() throws NotificationClientException { @Test public void testGetReceivedTextMessages() throws NotificationClientException { - NotificationClient client = getClient("INBOUND_SMS_QUERY_KEY"); + NotificationClient client = getClient("API_CLIENT_INTEGRATION_TESTS_INBOUND_SMS_API_KEY"); ReceivedTextMessageList response = client.getReceivedTextMessages(null); ReceivedTextMessage receivedTextMessage = assertReceivedTextMessageList(response); @@ -361,14 +361,14 @@ private void testGetReceivedTextMessagesWithOlderThanId(UUID id, NotificationCli } private NotificationClient getClient(){ - String apiKey = System.getenv("API_KEY"); - String baseUrl = System.getenv("NOTIFY_API_URL"); + String apiKey = System.getenv("API_CLIENT_INTEGRATION_TESTS_TEST_API_KEY"); + String baseUrl = System.getenv("API_CLIENT_INTEGRATION_TESTS_NOTIFY_API_URL"); return new NotificationClient(apiKey, baseUrl); } private NotificationClient getClient(String api_key){ String apiKey = System.getenv(api_key); - String baseUrl = System.getenv("NOTIFY_API_URL"); + String baseUrl = System.getenv("API_CLIENT_INTEGRATION_TESTS_NOTIFY_API_URL"); return new NotificationClient(apiKey, baseUrl); } @@ -376,8 +376,8 @@ private SendEmailResponse sendEmailAndAssertResponse(final NotificationClient cl HashMap personalisation = new HashMap<>(); String uniqueName = UUID.randomUUID().toString(); personalisation.put("name", uniqueName); - SendEmailResponse response = client.sendEmail(System.getenv("EMAIL_TEMPLATE_ID"), - System.getenv("FUNCTIONAL_TEST_EMAIL"), personalisation, uniqueName); + SendEmailResponse response = client.sendEmail(System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL_TEMPLATE_ID"), + System.getenv("API_CLIENT_INTEGRATION_TESTS_EMAIL"), personalisation, uniqueName); assertNotificationEmailResponse(response, uniqueName); return response; } @@ -386,7 +386,7 @@ private SendSmsResponse sendSmsAndAssertResponse(final NotificationClient client HashMap personalisation = new HashMap<>(); String uniqueName = UUID.randomUUID().toString(); personalisation.put("name", uniqueName); - SendSmsResponse response = client.sendSms(System.getenv("SMS_TEMPLATE_ID"), System.getenv("FUNCTIONAL_TEST_NUMBER"), personalisation, uniqueName); + SendSmsResponse response = client.sendSms(System.getenv("API_CLIENT_INTEGRATION_TESTS_SMS_TEMPLATE_ID"), System.getenv("API_CLIENT_INTEGRATION_TESTS_NUMBER"), personalisation, uniqueName); assertNotificationSmsResponse(response, uniqueName); return response; } @@ -399,7 +399,7 @@ private SendLetterResponse sendLetterAndAssertResponse(final NotificationClient personalisation.put("address_line_1", addressLine1); personalisation.put("address_line_2", addressLine2); personalisation.put("postcode", postcode); - SendLetterResponse response = client.sendLetter(System.getenv("LETTER_TEMPLATE_ID"), personalisation, addressLine1); + SendLetterResponse response = client.sendLetter(System.getenv("API_CLIENT_INTEGRATION_TESTS_LETTER_TEMPLATE_ID"), personalisation, addressLine1); assertNotificationLetterResponse(response, addressLine1); return response; } From ff02dd65c7061a70c9d102d29a3f595d2493bcfb Mon Sep 17 00:00:00 2001 From: Emmet Cassidy Date: Wed, 16 Oct 2024 15:32:47 +0100 Subject: [PATCH 2/2] copying in repo to dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 8a3da5f..178ed3e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM maven:3-jdk-8 +COPY ./ /notifications-java-client RUN \ echo "Install Debian packages" \