Skip to content

Commit

Permalink
Merge pull request #1755 from akto-api-security/hotfix/fix_demerge_un…
Browse files Browse the repository at this point in the history
…it_test

fix: fixed testDemergeAfterReuploadingApis
  • Loading branch information
avneesh-akto authored Nov 22, 2024
2 parents 5f63268 + 1d947f7 commit 39008f8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions apps/dashboard/src/test/java/com/akto/action/TestHarAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,21 @@ public void testDemergeAfterReuploadingApis() throws Exception {
httpCallParser.syncFunction(Collections.singletonList(httpResponseParams),true, true, null);

List<ApiInfo> apiInfoList = ApiInfoDao.instance.findAll(Filters.empty());

assertEquals(1, apiInfoList.size());

int apiCollectionId = apiInfoList.get(0).getId().getApiCollectionId();

assertEquals("https://juice-shop.herokuapp.com/api/Deliverys/STRING", apiInfoList.get(0).getId().getUrl());

InventoryAction action = new InventoryAction();
action.setUrl("https://juice-shop.herokuapp.com/api/Deliverys/STRING");
action.setMethod("GET");
action.setApiCollectionId(335433302);
action.setApiCollectionId(apiCollectionId);
action.deMergeApi();

Map<URLStatic, RequestTemplate> strictURLToMethods = httpCallParser.apiCatalogSync.dbState.get(335433302).getStrictURLToMethods();
Map<URLTemplate, RequestTemplate> templateURLToMethods = httpCallParser.apiCatalogSync.dbState.get(335433302).getTemplateURLToMethods();
Map<URLStatic, RequestTemplate> strictURLToMethods = httpCallParser.apiCatalogSync.dbState.get(apiCollectionId).getStrictURLToMethods();
Map<URLTemplate, RequestTemplate> templateURLToMethods = httpCallParser.apiCatalogSync.dbState.get(apiCollectionId).getTemplateURLToMethods();

assertEquals(0, strictURLToMethods.size());
assertEquals(1, templateURLToMethods.size());
Expand All @@ -54,8 +59,8 @@ public void testDemergeAfterReuploadingApis() throws Exception {

httpCallParser.syncFunction(Collections.singletonList(httpResponseParams),true, true, null);

Map<URLStatic, RequestTemplate> strictURLToMethods1 = httpCallParser.apiCatalogSync.dbState.get(335433302).getStrictURLToMethods();
Map<URLTemplate, RequestTemplate> templateURLToMethods1 = httpCallParser.apiCatalogSync.dbState.get(335433302).getTemplateURLToMethods();
Map<URLStatic, RequestTemplate> strictURLToMethods1 = httpCallParser.apiCatalogSync.dbState.get(apiCollectionId).getStrictURLToMethods();
Map<URLTemplate, RequestTemplate> templateURLToMethods1 = httpCallParser.apiCatalogSync.dbState.get(apiCollectionId).getTemplateURLToMethods();

assertEquals(1, strictURLToMethods1.size());
assertEquals(0, templateURLToMethods1.size());
Expand Down

0 comments on commit 39008f8

Please sign in to comment.