Skip to content

Commit

Permalink
Feat : Code cleanup for deprecated APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
saimanaswini-k committed Sep 9, 2024
1 parent 0d513be commit 72694d0
Show file tree
Hide file tree
Showing 10 changed files with 408 additions and 408 deletions.
24 changes: 12 additions & 12 deletions controller/app/controllers/BaseController.java
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,12 @@ public static Response createResponseOnException(
private static void handleBackwardCompatibility(
Request request, ProjectCommonException exception, Response response) {
// This code is for backwards compatibility
if (request.path() != null && request.path().startsWith("/v1/otp/generate")) {
if ("errorRateLimitExceeded".equalsIgnoreCase(exception.getResponseCode().name())) {
response.getParams().setErr("ERROR_RATE_LIMIT_EXCEEDED");
response.getParams().setStatus("ERROR_RATE_LIMIT_EXCEEDED");
}
}
//if (request.path() != null && request.path().startsWith("/v1/otp/generate")) {
// if ("errorRateLimitExceeded".equalsIgnoreCase(exception.getResponseCode().name())) {
// response.getParams().setErr("ERROR_RATE_LIMIT_EXCEEDED");
// response.getParams().setStatus("ERROR_RATE_LIMIT_EXCEEDED");
// }
//}

if (request.path() != null
&& request.path().startsWith("/v1/otp/verify")
Expand All @@ -491,12 +491,12 @@ private static void handleBackwardCompatibility(
response.getParams().setStatus("MANAGED_USER_LIMIT_EXCEEDED");
}

if (request.path() != null
&& (request.path().startsWith("/v1/user/consent/read"))
&& ("resourceNotFound".equalsIgnoreCase(exception.getResponseCode().name()))) {
response.getParams().setErr("USER_CONSENT_NOT_FOUND");
response.getParams().setStatus("USER_CONSENT_NOT_FOUND");
}
//if (request.path() != null
// && (request.path().startsWith("/v1/user/consent/read"))
// && ("resourceNotFound".equalsIgnoreCase(exception.getResponseCode().name()))) {
// response.getParams().setErr("USER_CONSENT_NOT_FOUND");
// response.getParams().setStatus("USER_CONSENT_NOT_FOUND");
//}
if (request.path() != null
&& (request.path().startsWith("/v1/user/get/"))
&& ("resourceNotFound".equalsIgnoreCase(exception.getResponseCode().name()))) {
Expand Down
14 changes: 7 additions & 7 deletions controller/app/util/RequestInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private RequestInterceptor() {}

static {
restrictedUriList = new ArrayList<>();
restrictedUriList.add("/v1/user/update");
//restrictedUriList.add("/v1/user/update");
restrictedUriList.add("/v1/note/create");
restrictedUriList.add("/v1/note/update");
restrictedUriList.add("/v1/note/search");
Expand All @@ -43,12 +43,12 @@ private RequestInterceptor() {}

// ---------------------------
short var = 1;
apiHeaderIgnoreMap.put("/v1/user/create", var);
apiHeaderIgnoreMap.put("/v2/user/create", var);
//apiHeaderIgnoreMap.put("/v1/user/create", var);
//apiHeaderIgnoreMap.put("/v2/user/create", var);
apiHeaderIgnoreMap.put("/v2/org/search", var);
apiHeaderIgnoreMap.put("/v2/org/preferences/read", var);
apiHeaderIgnoreMap.put("/v3/user/create", var);
apiHeaderIgnoreMap.put("/v1/user/signup", var);
//apiHeaderIgnoreMap.put("/v3/user/create", var);
//apiHeaderIgnoreMap.put("/v1/user/signup", var);
apiHeaderIgnoreMap.put("/v1/org/create", var);
apiHeaderIgnoreMap.put("/v1/system/settings/set", var);
apiHeaderIgnoreMap.put("/v1/org/update/encryptionkey", var);
Expand All @@ -58,7 +58,7 @@ private RequestInterceptor() {}
apiHeaderIgnoreMap.put("/v1/org/assign/key", var);
apiHeaderIgnoreMap.put("/v2/user/signup", var);
apiHeaderIgnoreMap.put("/v1/ssouser/create", var);
apiHeaderIgnoreMap.put("/v1/org/search", var);
//apiHeaderIgnoreMap.put("/v1/org/search", var);
apiHeaderIgnoreMap.put("/service/health", var);
apiHeaderIgnoreMap.put("/health", var);
apiHeaderIgnoreMap.put("/v1/notification/email", var);
Expand All @@ -73,7 +73,7 @@ private RequestInterceptor() {}
apiHeaderIgnoreMap.put("/v1/location/update", var);
apiHeaderIgnoreMap.put("/v1/location/search", var);
apiHeaderIgnoreMap.put("/v1/location/delete", var);
apiHeaderIgnoreMap.put("/v1/otp/generate", var);
//apiHeaderIgnoreMap.put("/v1/otp/generate", var);
apiHeaderIgnoreMap.put("/v1/otp/verify", var);
apiHeaderIgnoreMap.put("/v2/otp/generate", var);
apiHeaderIgnoreMap.put("/v2/otp/verify", var);
Expand Down
26 changes: 13 additions & 13 deletions controller/test/controllers/feed/FeedControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
@Ignore
public class FeedControllerTest extends BaseApplicationTest {

String SAVE_FEED_URL = "/v1/user/feed/create";
//String SAVE_FEED_URL = "/v1/user/feed/create";
String UPDATE_FEED_URL = "/v1/user/feed/update";
String DELETE_FEED_URL = "/v1/user/feed/delete";
//String DELETE_FEED_URL = "/v1/user/feed/delete";

@Before
public void before() {
Expand Down Expand Up @@ -70,11 +70,11 @@ public void testUpdateUserFeed() {
assertTrue(getResponseStatus(result) == 200);
}

public void testCreateUserFeed() {
Result result = performTest(SAVE_FEED_URL, HttpMethods.POST.name(), createFeedRequest(true));
assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name());
assertTrue(getResponseStatus(result) == 200);
}
//public void testCreateUserFeed() {
// Result result = performTest(SAVE_FEED_URL, HttpMethods.POST.name(), createFeedRequest(true));
// assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name());
// assertTrue(getResponseStatus(result) == 200);
//}

@Test
public void testUpdateUserFeedFailureForUserID() {
Expand All @@ -85,12 +85,12 @@ public void testUpdateUserFeedFailureForUserID() {
assertTrue(getResponseStatus(result) == 400);
}

@Test
public void testDeleteUserFeed() {
Result result = performTest(DELETE_FEED_URL, HttpMethods.POST.name(), updateFeedRequest(true));
assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name());
assertTrue(getResponseStatus(result) == 200);
}
//@Test
//public void testDeleteUserFeed() {
// Result result = performTest(DELETE_FEED_URL, HttpMethods.POST.name(), updateFeedRequest(true));
// assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name());
// assertTrue(getResponseStatus(result) == 200);
//}

private Map updateFeedRequest(boolean setUserid) {
Map<String, Object> requestMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ public void testGetOrgDetailsFailureWithoutOrgId() {
assertEquals(400, getResponseStatus(result));
}

@Test
public void testSearchOrgSuccess() {
Result result =
performTest("/v1/org/search", "POST", searchOrganisationRequest(status, new HashMap<>()));
assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name());
assertEquals(200, getResponseStatus(result));
}
//@Test
//public void testSearchOrgSuccess() {
// Result result =
// performTest("/v1/org/search", "POST", searchOrganisationRequest(status, new HashMap<>()));
// assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name());
// assertEquals(200, getResponseStatus(result));
//}

@Test
public void testSearchOrgV2Success() {
Expand All @@ -187,12 +187,12 @@ public void testSearchOrgV2Success() {
assertEquals(200, getResponseStatus(result));
}

@Test
public void testSearchOrgFailureWithoutFilters() {
Result result = performTest("/v1/org/search", "POST", searchOrganisationRequest(status, null));
assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name());
assertEquals(400, getResponseStatus(result));
}
//@Test
//public void testSearchOrgFailureWithoutFilters() {
// Result result = performTest("/v1/org/search", "POST", searchOrganisationRequest(status, null));
// assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name());
// assertEquals(400, getResponseStatus(result));
//}

@Test
public void testAddEncyptionKeyPublicPem() throws IOException {
Expand Down
110 changes: 55 additions & 55 deletions controller/test/controllers/otp/OtpControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,68 +40,68 @@ public class OtpControllerTest extends BaseApplicationTest {
private static final String VALID_EMAIL_TYPE = "email";
private static final String INVALID_TYPE = "invalidType";
private static final String INVALID_OTP = "anyOtp";
private static final String GENERATE_OTP_URL = "/v1/otp/generate";
//private static final String GENERATE_OTP_URL = "/v1/otp/generate";
private static final String VERIFY_OTP_URL = "/v1/otp/verify";

@Before
public void before() {
setup(ACTORS.OTP_ACTOR, DummyActor.class);
}

@Test
public void testGenerateOtpFailureWithoutPhoneKey() {
Result result =
performTest(
GENERATE_OTP_URL,
HttpMethods.POST.name(),
createInvalidOtpRequest(false, null, true, VALID_PHONE_TYPE, false, null));
assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name());
assertTrue(getResponseStatus(result) == 400);
}

@Test
public void testGenerateOtpFailureWithInvalidPhone() {
Result result =
performTest(
GENERATE_OTP_URL,
HttpMethods.POST.name(),
createInvalidOtpRequest(true, INVALID_PHONE, true, VALID_PHONE_TYPE, false, null));
assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name());
assertTrue(getResponseStatus(result) == 400);
}

@Test
public void testGenerateOtpFailureWithoutEmailKey() {
Result result =
performTest(
GENERATE_OTP_URL,
HttpMethods.POST.name(),
createInvalidOtpRequest(false, null, true, VALID_EMAIL_TYPE, false, null));
assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name());
assertTrue(getResponseStatus(result) == 400);
}

@Test
public void testGenerateOtpFailureWithInvalidEmail() {
Result result =
performTest(
GENERATE_OTP_URL,
HttpMethods.POST.name(),
createInvalidOtpRequest(true, INVALID_EMAIL, true, VALID_EMAIL_TYPE, false, null));
assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name());
assertTrue(getResponseStatus(result) == 400);
}

@Test
public void testGenerateOtpFailureWithInvalidType() {
Result result =
performTest(
GENERATE_OTP_URL,
HttpMethods.POST.name(),
createInvalidOtpRequest(true, VALID_EMAIL, true, INVALID_TYPE, false, null));
assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name());
assertTrue(getResponseStatus(result) == 400);
}
//@Test
//public void testGenerateOtpFailureWithoutPhoneKey() {
// Result result =
// performTest(
// GENERATE_OTP_URL,
// HttpMethods.POST.name(),
// createInvalidOtpRequest(false, null, true, VALID_PHONE_TYPE, false, null));
// assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name());
// assertTrue(getResponseStatus(result) == 400);
//}

//@Test
//public void testGenerateOtpFailureWithInvalidPhone() {
// Result result =
// performTest(
// GENERATE_OTP_URL,
// HttpMethods.POST.name(),
// createInvalidOtpRequest(true, INVALID_PHONE, true, VALID_PHONE_TYPE, false, null));
// assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name());
// assertTrue(getResponseStatus(result) == 400);
//}

//@Test
//public void testGenerateOtpFailureWithoutEmailKey() {
// Result result =
// performTest(
// GENERATE_OTP_URL,
// HttpMethods.POST.name(),
// createInvalidOtpRequest(false, null, true, VALID_EMAIL_TYPE, false, null));
// assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name());
// assertTrue(getResponseStatus(result) == 400);
//}

//@Test
//public void testGenerateOtpFailureWithInvalidEmail() {
// Result result =
// performTest(
// GENERATE_OTP_URL,
// HttpMethods.POST.name(),
// createInvalidOtpRequest(true, INVALID_EMAIL, true, VALID_EMAIL_TYPE, false, null));
// assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name());
// assertTrue(getResponseStatus(result) == 400);
//}

//@Test
//public void testGenerateOtpFailureWithInvalidType() {
// Result result =
// performTest(
// GENERATE_OTP_URL,
// HttpMethods.POST.name(),
// createInvalidOtpRequest(true, VALID_EMAIL, true, INVALID_TYPE, false, null));
// assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name());
// assertTrue(getResponseStatus(result) == 400);
//}

@Test
public void testVerifyOtpFailureWithoutPhoneKey() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public void updateUserConsentSuccess() {
assertTrue(getResponseStatus(result) == Response.Status.OK.getStatusCode());
}

@Test
public void getUserConsentSuccess() {
Result result = performTest("/v1/user/consent/read", "POST", (Map) getUserConsentRequest());
assertTrue(getResponseStatus(result) == Response.Status.OK.getStatusCode());
}
//@Test
//public void getUserConsentSuccess() {
// Result result = performTest("/v1/user/consent/read", "POST", (Map) getUserConsentRequest());
// assertTrue(getResponseStatus(result) == Response.Status.OK.getStatusCode());
//}

public static Map<String, Object> getUserConsentRequest() {
Map<String, Object> filters = new HashMap<String, Object>();
Expand Down
Loading

0 comments on commit 72694d0

Please sign in to comment.