Skip to content
Snippets Groups Projects
Commit b7818266 authored by Abhay Joshi's avatar Abhay Joshi
Browse files

making sure test for special character always run in aws

parent 39c2aa6b
No related branches found
No related tags found
4 merge requests!760Vulnerability fixes,!745Draft: M18 Upgraded packages to mitigate vulns in netty, guava, snakeyaml,!744Upgraded packages to mitigated vulns in netty, guava, snakeyaml,!692M18 service and CICD updates
......@@ -15,12 +15,16 @@
package org.opengroup.osdu.storage.records;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.opengroup.osdu.storage.util.AWSTestUtils;
import org.opengroup.osdu.storage.util.ConfigUtils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import org.junit.*;
import org.opengroup.osdu.storage.util.*;
import com.sun.jersey.api.client.ClientResponse;
import com.google.gson.Gson;
public class TestRecordsApiAcceptance extends RecordsApiAcceptanceTests {
......@@ -49,4 +53,39 @@ public class TestRecordsApiAcceptance extends RecordsApiAcceptanceTests {
this.testUtils = null;
}
}
\ No newline at end of file
@Override
@Test
public void should_createNewRecord_withSpecialCharacter_ifEnabled() throws Exception {
final long currentTimeMillis = System.currentTimeMillis();
final String RECORD_ID = TenantUtils.getTenantName() + ":inttest:testSpecialChars%abc%2Ffoobar-" + currentTimeMillis;
final String ENCODED_RECORD_ID = TenantUtils.getTenantName() + ":inttest:testSpecialChars%25abc%252Ffoobar-" + currentTimeMillis;
String jsonInput = createJsonBody(RECORD_ID, "TestSpecialCharacters");
ClientResponse response = TestUtils.send("records", "PUT", HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()), jsonInput, "");
String json = response.getEntity(String.class);
assertEquals(201, response.getStatus());
assertTrue(response.getType().toString().contains("application/json"));
Gson gson = new Gson();
DummyRecordsHelper.CreateRecordResponse result = gson.fromJson(json,
DummyRecordsHelper.CreateRecordResponse.class);
assertEquals(1, result.recordCount);
assertEquals(1, result.recordIds.length);
assertEquals(1, result.recordIdVersions.length);
assertEquals(RECORD_ID, result.recordIds[0]);
response = TestUtils.send("records/" + ENCODED_RECORD_ID, "GET", HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()), "", "");
// Service does not allow URLs with suspicious characters, Which is the default setting.
// Different CSPs are responding with different status code for this error when a special character like %25 is present in the URL.
// Hence the Assert Statement is marked not to be 200.
// More details - https://community.opengroup.org/osdu/platform/system/storage/-/issues/61
assertNotEquals(200, response.getStatus());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment