Commit abe275a6 authored by Spencer Sutton's avatar Spencer Sutton
Browse files

Merge

parents ec3e7026 32de9243
......@@ -81,6 +81,8 @@ spec:
value: "api://$(aad_client_id)"
- name: ENTITLEMENTS_API
value: http://entitlements/api/entitlements/v2
- name: ENTITLEMENTS_API_KEY
value: "OBSOLETE"
- name: RECORDS_CHANGE_PUBSUB_ENDPOINT
value: https://{{ .Values.global.dnsHost }}/api/notification/v1/push-handlers/records-changed
- name: partition_service_endpoint
......
......@@ -29,8 +29,7 @@
<packaging>jar</packaging>
<version>0.10.0-SNAPSHOT</version>
<properties>
<osdu.register-core.version>0.10.0-SNAPSHOT</osdu.register-core.version>
<osdu.corelibazure.version>0.6.1</osdu.corelibazure.version>
<osdu.corelibazure.version>0.10.0-rc8</osdu.corelibazure.version>
<junit-jupiter.version>5.6.0</junit-jupiter.version>
<mockito-junit-jupiter.version>2.23.0</mockito-junit-jupiter.version>
<oauth2-oidc-sdk.version>6.5</oauth2-oidc-sdk.version>
......
......@@ -51,7 +51,7 @@ public class PushSubscription {
.subscribe(
(Indexable indexable) -> {},
error::set,
() -> logger.info(String.format("Push Subscription with id %s created successfully", subscriptionId))
() -> logger.debug(String.format("Push Subscription with id %s created successfully", subscriptionId))
);
if(error.get() != null) {
......@@ -71,7 +71,7 @@ public class PushSubscription {
String scope = partitionHelper.retrieveScope(topicName);
AtomicReference<Throwable> error = new AtomicReference<>();
factory.getManager(headers.getPartitionId()).eventSubscriptions().deleteAsync(scope, subscriptionId)
.subscribe(() -> logger.info(String.format("Push Subscription with id %s deleted successfully", subscriptionId)), error::set);
.subscribe(() -> logger.debug(String.format("Push Subscription with id %s deleted successfully", subscriptionId)), error::set);
if(error.get() != null) {
if(error.get() instanceof CloudException) {
......@@ -93,7 +93,7 @@ public class PushSubscription {
.subscribe(
(Indexable indexable) -> {},
error::set,
() -> logger.info(String.format("Push Subscription with id %s fetched successfully", subscriptionId))
() -> logger.debug(String.format("Push Subscription with id %s fetched successfully", subscriptionId))
);
if(error.get() != null) {
......
......@@ -107,7 +107,7 @@ public class SubscriptionRepository implements ISubscriptionRepository {
try {
cosmosStore.createItem(dpsHeaders.getPartitionId(), azureBootstrapConfig.getCosmosDBName(), cosmosContainerConfig.getSubscriptionContainerName(), dpsHeaders.getPartitionId(), doc);
logger.info(String.format("Record successfully created for Subscription with id %s", input.getId()));
logger.debug(String.format("Record successfully created for Subscription with id %s", input.getId()));
}
catch (AppException e) {
if(e.getError().getCode() == 409) {
......@@ -128,16 +128,15 @@ public class SubscriptionRepository implements ISubscriptionRepository {
try {
pushSubscription.createPushSubscription(doc.getNotificationId(), doc.getTopic());
logger.info("Push Subscription created with Event Grid ID:" + doc.getNotificationId());
logger.debug("Push Subscription created with Event Grid ID:" + doc.getNotificationId());
return input;
}
catch(AppException e) {
} catch(AppException e) {
if(e.getError().getCode() == 409) {
throw new AppException(409, "Conflict", "Another request is trying to create the same subscription");
}
try {
cosmosStore.deleteItem(dpsHeaders.getPartitionId(), azureBootstrapConfig.getCosmosDBName(), cosmosContainerConfig.getSubscriptionContainerName(), input.getId(), dpsHeaders.getPartitionId());
logger.info("Record deleted for subscription with ID: " + input.getId());
logger.info("Record deleted for subscription with ID: " + input.getId() + ", because push subscription creation failed");
}
catch (AppException ignored) {}
......@@ -189,13 +188,13 @@ public class SubscriptionRepository implements ISubscriptionRepository {
logger.info("Record not found for subscription with ID: " + id);
return false;
}
logger.info("Record found for subscription with ID: " + id);
logger.debug("Record found for subscription with ID: " + id);
try {
pushSubscription.deletePushSubscription(subscription.get().getNotificationId(), subscription.get().getTopic());
logger.info("Push Subscription deleted with Event Grid ID:" + subscription.get().getNotificationId());
logger.debug("Push Subscription deleted with Event Grid ID:" + subscription.get().getNotificationId());
try {
cosmosStore.deleteItem(dpsHeaders.getPartitionId(), azureBootstrapConfig.getCosmosDBName(), cosmosContainerConfig.getSubscriptionContainerName(), id, dpsHeaders.getPartitionId());
logger.info("Record deleted for subscription with ID: " + id);
logger.debug("Record deleted for subscription with ID: " + id);
return true;
}
catch (AppException e) {
......@@ -247,7 +246,7 @@ public class SubscriptionRepository implements ISubscriptionRepository {
// notification-id to create the Push Subscription
Optional<SubscriptionDoc> originalDoc = cosmosStore.findItem(dpsHeaders.getPartitionId(), azureBootstrapConfig.getCosmosDBName(), cosmosContainerConfig.getSubscriptionContainerName(), input.getId(), dpsHeaders.getPartitionId(), SubscriptionDoc.class);
originalDoc.ifPresent(subscriptionDoc -> input.setNotificationId(subscriptionDoc.getNotificationId()));
logger.info(String.format("Creating Push Subscription with id %s if does not exists", input.getNotificationId()));
logger.debug(String.format("Creating Push Subscription with id %s if does not exists", input.getNotificationId()));
// We will check if Push Subscription does not exist then we should try creating it again since
// the corresponding record in the Cosmos Db is already present
......
......@@ -26,6 +26,10 @@ logging.slf4jlogger.enabled=true
logging.mdccontext.enabled=true
logging.ignore.servlet.paths=/actuator/health
# Need below two properties for Entitlements config bean initialization due to a primary bean added in core-lib-azure which takes precedence over EntitlementsClientFactory class in register service
AUTHORIZE_API=${ENTITLEMENTS_API}
AUTHORIZE_API_KEY=${ENTITLEMENTS_API_KEY}
ENTITLEMENTS_API=${ENTITLEMENTS_API}
PARTITION_API=${partition_service_endpoint}
RECORDS_CHANGE_PUBSUB_ENDPOINT=${RECORDS_CHANGE_PUBSUB_ENDPOINT}
......
......@@ -131,7 +131,7 @@ public class PushSubscriptionTest {
verify(eventGridManager, times(1)).eventSubscriptions();
verify(eventSubscriptions, times(1)).define(subscriptionId);
verify(eventSubscription, times(1)).withScope(scope);
verify(logger, times(1)).info(String.format("Push Subscription with id %s created successfully", subscriptionId));
verify(logger, times(1)).debug(String.format("Push Subscription with id %s created successfully", subscriptionId));
}
@Test
......@@ -159,7 +159,7 @@ public class PushSubscriptionTest {
pushSubscription.deletePushSubscription(subscriptionId, topicName);
verify(eventGridManager, times(1)).eventSubscriptions();
verify(logger, times(1)).info(String.format("Push Subscription with id %s deleted successfully", subscriptionId));
verify(logger, times(1)).debug(String.format("Push Subscription with id %s deleted successfully", subscriptionId));
}
@Test
......@@ -209,7 +209,7 @@ public class PushSubscriptionTest {
pushSubscription.checkIfPushSubscriptionExists(subscriptionId, topicName);
verify(eventGridManager, times(1)).eventSubscriptions();
verify(logger, times(1)).info(String.format("Push Subscription with id %s fetched successfully", subscriptionId));
verify(logger, times(1)).debug(String.format("Push Subscription with id %s fetched successfully", subscriptionId));
}
@Test
......
......@@ -43,7 +43,7 @@ public class GsaSubscriberListenerApi {
if (!gsaTokenVerifier.verify(headers.getAuthorization())) {
throw new ValidationException("Authorization signature validation Failed");
}
logger.info("Token verified and sending response");
logger.debug("Token verified and sending response");
return new ChallengeResponse(HashingUtil.hashString(crc, this.serviceConfig.getSubscriberPrivateKeyId()));
}
......@@ -53,7 +53,7 @@ public class GsaSubscriberListenerApi {
if (!gsaTokenVerifier.verify(headers.getAuthorization())) {
throw new ValidationException("Authorization signature validation Failed");
}
logger.info("Sending acknowledgement from gsa endpoint");
logger.debug("Sending acknowledgement from gsa endpoint");
}
}
......@@ -56,7 +56,7 @@ public class SubscriberListenerApi {
@RequestParam("hmac") @NotBlank String hmac) {
try {
signatureService.verifyHmacSignature(hmac, this.serviceConfig.getSubscriberSecret());
logger.info("Signature verified and sending response");
logger.debug("Signature verified and sending response");
// Use the secret you send to the subscriber registration create request
return new ChallengeResponse(HashingUtil.hashString(crc, this.serviceConfig.getSubscriberSecret()));
} catch (SignatureServiceException e) {
......@@ -68,7 +68,7 @@ public class SubscriberListenerApi {
public void testPushHmac(@RequestBody Object o, @RequestParam("hmac") String hmac) {
try {
signatureService.verifyHmacSignature(hmac, this.serviceConfig.getSubscriberSecret());
logger.info("Sending acknowledgement from hmac endpoint");
logger.debug("Sending acknowledgement from hmac endpoint");
// Performing End Point Notification Acknowledgement
try {
testSubscription.performTestAcknowledgement();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment