From: m.dalakov Date: Wed, 8 Nov 2017 17:22:32 +0000 (+0200) Subject: [SECIOTSRK-686] Fix REST Api for DSM & MQ X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3905d53b05bfbfd25e57759eac6b008af847e811;p=platform%2Fcore%2Fsecurity%2Fsuspicious-activity-monitor.git [SECIOTSRK-686] Fix REST Api for DSM & MQ --- diff --git a/servers/api-integration-tests/src/test/java/com/samsung/ci/test/mq/PolicyWitoutCloudTest.java b/servers/api-integration-tests/src/test/java/com/samsung/ci/test/mq/PolicyWitoutCloudTest.java index c7e093d..1225fef 100644 --- a/servers/api-integration-tests/src/test/java/com/samsung/ci/test/mq/PolicyWitoutCloudTest.java +++ b/servers/api-integration-tests/src/test/java/com/samsung/ci/test/mq/PolicyWitoutCloudTest.java @@ -38,8 +38,6 @@ import com.samsung.ci.test.useractions.BasicUserAction; * @par LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea) * @par Copyright : (c) Samsung Electronics Co, Ltd 2017. All rights reserved. */ -@Disabled -@Ignore public class PolicyWitoutCloudTest extends BasicUserAction { private static final String DEVICE_DUID = "00000000-1111-2222-3333-4444444444444"; @@ -118,7 +116,7 @@ public class PolicyWitoutCloudTest extends BasicUserAction { //CHECKSTYLE_OFF:Magic Number private void checkPolicy(KafkaConsumer consumer, String policy) { List policyList = new ArrayList<>(); - int attemptCounts = 10; + int attemptCounts = 0; while (policyList.isEmpty() && attemptCounts >= 0) { policyList = MQListenerAPI.getMessages(consumer); attemptCounts--; diff --git a/servers/api-integration-tests/src/test/java/com/samsung/ci/test/mq/ReportsWithOutCloudTest.java b/servers/api-integration-tests/src/test/java/com/samsung/ci/test/mq/ReportsWithOutCloudTest.java index 5a0a565..3df07bf 100644 --- a/servers/api-integration-tests/src/test/java/com/samsung/ci/test/mq/ReportsWithOutCloudTest.java +++ b/servers/api-integration-tests/src/test/java/com/samsung/ci/test/mq/ReportsWithOutCloudTest.java @@ -40,8 +40,7 @@ import static org.junit.Assert.assertEquals; * @par LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea) * @par Copyright : (c) Samsung Electronics Co, Ltd 2017. All rights reserved. */ -@Disabled -@Ignore + public class ReportsWithOutCloudTest extends BasicUserAction { private static final String SMACK = "smack"; @@ -129,7 +128,7 @@ public class ReportsWithOutCloudTest extends BasicUserAction { //CHECKSTYLE_OFF:Magic Number private void checkNotification(KafkaConsumer consumer) { List notificationList = new ArrayList<>(); - int attemptCounts = 10; + int attemptCounts = 0; while (notificationList.isEmpty() && attemptCounts >= 0) { notificationList = MQListenerAPI.getMessages(consumer); attemptCounts--; diff --git a/servers/api-integration-tests/src/test/java/com/samsung/ci/test/reports/RestRuleReportsTest.java b/servers/api-integration-tests/src/test/java/com/samsung/ci/test/reports/RestRuleReportsTest.java index b9141d2..76e6ed8 100644 --- a/servers/api-integration-tests/src/test/java/com/samsung/ci/test/reports/RestRuleReportsTest.java +++ b/servers/api-integration-tests/src/test/java/com/samsung/ci/test/reports/RestRuleReportsTest.java @@ -38,8 +38,7 @@ import io.restassured.response.Response; * @par LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea) * @par Copyright : (c) Samsung Electronics Co, Ltd 2017. All rights reserved. */ -@Disabled -@Ignore + public class RestRuleReportsTest extends BasicUserAction { private static final String SYSCALL = "syscall"; @@ -117,7 +116,7 @@ public class RestRuleReportsTest extends BasicUserAction { //CHECKSTYLE_OFF:Magic Number private void checkNotification(KafkaConsumer consumer) { List notificationList = new ArrayList<>(); - int attemptCounts = 10; + int attemptCounts = 0; while (notificationList.isEmpty() && attemptCounts >= 0) { notificationList = MQListenerAPI.getMessages(consumer); attemptCounts--; diff --git a/servers/dsm/src/main/java/com/samsung/dsm/rest/policy/PolicyApi.java b/servers/dsm/src/main/java/com/samsung/dsm/rest/policy/PolicyApi.java index 4d492c4..3ab5cda 100644 --- a/servers/dsm/src/main/java/com/samsung/dsm/rest/policy/PolicyApi.java +++ b/servers/dsm/src/main/java/com/samsung/dsm/rest/policy/PolicyApi.java @@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import com.samsung.commons.domain.Agent; @@ -76,7 +77,7 @@ public class PolicyApi { * @param deviceId the device id * @return the response entity */ - @RequestMapping(value = "/request/{policyId}/device/{deviceId}") + @RequestMapping(value = "/request/{policyId}/device/{deviceId}", method = RequestMethod.POST) public ResponseEntity requestPolicy(@PathVariable Long policyId, @PathVariable String deviceId) { LOG.info("Request policy - " + policyId); // TODO add check for policy diff --git a/servers/dsm/src/main/java/com/samsung/dsm/rest/report/ReportApi.java b/servers/dsm/src/main/java/com/samsung/dsm/rest/report/ReportApi.java index 5c9e64a..213a1e7 100644 --- a/servers/dsm/src/main/java/com/samsung/dsm/rest/report/ReportApi.java +++ b/servers/dsm/src/main/java/com/samsung/dsm/rest/report/ReportApi.java @@ -126,7 +126,7 @@ public class ReportApi { * @param reportId report ID * @return the response entity */ - @RequestMapping(value = "/newreport/{reportId}") + @RequestMapping(value = "/newreport/{reportId}", method = RequestMethod.POST) public ResponseEntity newReportNotification(@PathVariable Long reportId) { LOG.info("Get new report " + reportId); diff --git a/servers/mq/src/main/java/com/samsung/servermq/utils/rest/DsmApiImpl.java b/servers/mq/src/main/java/com/samsung/servermq/utils/rest/DsmApiImpl.java index 1f63c7c..aee03f2 100644 --- a/servers/mq/src/main/java/com/samsung/servermq/utils/rest/DsmApiImpl.java +++ b/servers/mq/src/main/java/com/samsung/servermq/utils/rest/DsmApiImpl.java @@ -29,9 +29,9 @@ public class DsmApiImpl implements DsmApi { private static final Logger LOG = Logger.getLogger(DsmApiImpl.class); - private static final String REST_FOR_NOTIFICATION = "restapi/report/newreport/"; + private static final String REST_FOR_NOTIFICATION = "dsm/restapi/report/newreport/"; - private static final String REST_FOR_REQUEST_POLICY = "restapi/policy/request/"; + private static final String REST_FOR_REQUEST_POLICY = "dsm/restapi/policy/request/"; /** * Http Sender