Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated integration test env variables to the new values #250

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM maven:3-jdk-8
COPY ./ /notifications-java-client

RUN \
echo "Install Debian packages" \
Expand Down
22 changes: 11 additions & 11 deletions scripts/run_with_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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} \
${@}
62 changes: 31 additions & 31 deletions src/test/java/uk/gov/service/notify/ClientIntegrationTestIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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"));
Expand All @@ -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);

Expand All @@ -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());
Expand All @@ -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
);
Expand All @@ -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"));
Expand All @@ -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<String, String> 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);

Expand All @@ -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());
Expand All @@ -224,7 +224,7 @@ public void testSendAndGetNotificationWithReference() throws NotificationClientE
HashMap<String, String> 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());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -270,8 +270,8 @@ public void testGenerateTemplatePreview() throws NotificationClientException {
HashMap<String, Object> 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());
Expand All @@ -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);
Expand Down Expand Up @@ -361,23 +361,23 @@ 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);
}

private SendEmailResponse sendEmailAndAssertResponse(final NotificationClient client) throws NotificationClientException {
HashMap<String, String> 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;
}
Expand All @@ -386,7 +386,7 @@ private SendSmsResponse sendSmsAndAssertResponse(final NotificationClient client
HashMap<String, Object> 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;
}
Expand All @@ -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;
}
Expand Down