Commit de8a8ef3 authored by harshit aggarwal's avatar harshit aggarwal
Browse files

Merge branch 'users/nikhil/StorageNotifIntegrationTest' into 'master'

Implementation of Test Acknowledgement Subscription for Integration Tests

See merge request !89
parents c888455c 49cf8708
Pipeline #50295 failed with stages
in 42 minutes and 8 seconds
This diff is collapsed.
// Copyright © Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.opengroup.osdu.register.provider.azure.subscriber;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.register.provider.interfaces.subscriber.ISubscriptionRepository;
import org.opengroup.osdu.register.provider.interfaces.subscriber.ITestSubscription;
import org.opengroup.osdu.register.subscriber.model.HmacSecret;
import org.opengroup.osdu.register.subscriber.model.Subscription;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository
public class TestSubscriptionAzure implements ITestSubscription {
@Autowired
private ISubscriptionRepository subscriptionRepository;
@Autowired
private JaxRsDpsLog logger;
@Override
public void performTestAcknowledgement() throws Exception {
try {
/* Creation of Test Acknowledgement Subscription which ensures the successful delivery
of notification at the test end point */
Subscription subscription = new Subscription();
subscription.setName("AcknowledgementTestSubscription");
subscription.setDescription("Subscription for Ack of test-endpoint");
subscription.setTopic("recordstopic");
subscription.setPushEndpoint("http://TestAck/api/register/v1/test/challenge/1");
subscription.setNotificationId("testingAcknowledgement");
subscription.setId("AckSubscription");
HmacSecret secret = new HmacSecret();
secret.setValue("TestAcknowledgementSubscription");
subscription.setSecret(secret);
subscription = subscriptionRepository.create(subscription);
logger.info("Successfully created Acknowledgement Subscription");
}catch(Exception e)
{
logger.error("An exception occurred while creating Test Acknowledgment Subscription");
throw e;
}
}
}
......@@ -18,11 +18,11 @@ package org.opengroup.osdu.register.api.test;
import javax.validation.ValidationException;
import javax.validation.constraints.NotBlank;
import org.opengroup.osdu.core.common.cryptographic.ISignatureService;
import org.opengroup.osdu.core.common.cryptographic.SignatureServiceException;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.register.api.dto.ChallengeResponse;
import org.opengroup.osdu.register.provider.interfaces.subscriber.ITestSubscription;
import org.opengroup.osdu.register.utils.AppServiceConfig;
import org.opengroup.osdu.register.utils.HashingUtil;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -48,6 +48,8 @@ public class SubscriberListenerApi {
private AppServiceConfig serviceConfig;
@Autowired
private JaxRsDpsLog logger;
@Autowired
private ITestSubscription testSubscription;
@GetMapping("challenge/{count}")
public ChallengeResponse testCrc(@RequestParam("crc") @NotBlank String crc,
......@@ -67,6 +69,12 @@ public class SubscriberListenerApi {
try {
signatureService.verifyHmacSignature(hmac, this.serviceConfig.getSubscriberSecret());
logger.info("Sending acknowledgement from hmac endpoint");
// Performing End Point Notification Acknowledgement
try {
testSubscription.performTestAcknowledgement();
}catch(Exception e) {
logger.error("An error occurred in Test Acknowledgement");
}
} catch (SignatureServiceException e) {
throw new ValidationException("Authorization signature validation Failed");
}
......
package org.opengroup.osdu.register.provider.interfaces.subscriber;
public interface ITestSubscription {
void performTestAcknowledgement() throws Exception;
}
package org.opengroup.osdu.register.subscriber.test;
import org.opengroup.osdu.register.provider.interfaces.subscriber.ITestSubscription;
import org.springframework.stereotype.Repository;
@Repository
public class TestSubscription implements ITestSubscription {
@Override
public void performTestAcknowledgement() {
// Implementation for Test Acknowledgement
}
}
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