Commit a12bca5d authored by Nikhil Singh[MicroSoft]'s avatar Nikhil Singh[MicroSoft]
Browse files

Clean up IT

parent a0eeb7ba
Pipeline #67096 passed with stages
in 12 minutes and 7 seconds
......@@ -38,7 +38,7 @@ import static org.junit.Assert.fail;
public class TestStorageIntegration extends BaseTestTemplate {
private String subscriptionId = null;
private String subscriptionId = "cmVjb3Jkc3RvcGljaHR0cHM6Ly9jb3N0b3Nvb2VwLm9lcC5wcGUuYXp1cmUtaW50Lm5ldC9hcGkvcmVnaXN0ZXIvdjEvdGVzdC9jaGFsbGVuZ2UvMQ==";
private String notificationId = null;
private final String ackSubscriptionId = "AckSubscription";
private final String ackNotificationId = "testingAcknowledgement";
......@@ -66,7 +66,21 @@ public class TestStorageIntegration extends BaseTestTemplate {
@Override
protected void deleteResource() throws Exception {
subscriptionService.delete(subscriptionId);
try {
Map<String, String> headers = new HashMap<>();
headers.put(DpsHeaders.DATA_PARTITION_ID, TestUtils.getOsduTenant());
headers.put(DpsHeaders.AUTHORIZATION, testUtils.getOpsToken());
DpsHeaders dpsHeaders = DpsHeaders.createFromMap(headers);
subscriptionService = factory.create(dpsHeaders);
subscriptionService.delete(subscriptionId);
} catch (SubscriptionException e) {
if (e.getHttpResponse().getResponseCode() == Response.SC_NOT_FOUND) {
System.out.println("Subscription Not Found for deletion.");
return;
}
Assert.fail("Unable to delete Subscription. Deletion Failed." + e);
throw e;
}
}
@After
......@@ -81,12 +95,6 @@ public class TestStorageIntegration extends BaseTestTemplate {
}
private void createResourceInPartition(String partitionId) throws Exception {
Map<String, String> headers = new HashMap<>();
headers.put(DpsHeaders.DATA_PARTITION_ID, partitionId);
headers.put(DpsHeaders.AUTHORIZATION, testUtils.getOpsToken());
DpsHeaders dpsHeaders = DpsHeaders.createFromMap(headers);
subscriptionService = factory.create(dpsHeaders);
// Create a new subscription
Subscription subscription = new Subscription();
subscription.setName("storage-integration-test-hmac");
......@@ -139,15 +147,18 @@ public class TestStorageIntegration extends BaseTestTemplate {
@Override
public void should_return20XResponseCode_when_makingValidHttpsRequest() throws Exception {
try {
// Creates an actual subscription with a test endpoint i.e REGISTER_CUSTOM_PUSH_URL_HMAC
this.createResource();
// Delay to get the above subscription registered by Notification Service
TimeUnit.SECONDS.sleep(60);
// Delete the pubsub subscription
this.deleteResource();
// Delete the Test Ack subscription if there exists any as a part of cleanup.
// The Test Ack Subscription gets created if the the test endpoint of actual subscription
// created above receives notification from Notification Service.
this.deleteAckSubscription();
// Delete legal tag
LegalTagUtils.delete(LEGAL_TAG, this.testUtils.getAdminToken());
// Creates an actual subscription with a test endpoint i.e REGISTER_CUSTOM_PUSH_URL_HMAC
this.createResource();
// Delay to get the above subscription registered by Notification Service
TimeUnit.SECONDS.sleep(60);
// Create legal tag used in storage record
LegalTagUtils.create(LEGAL_TAG, this.testUtils.getAdminToken());
......
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