aboutsummaryrefslogtreecommitdiffstats
path: root/vid-automation/src
diff options
context:
space:
mode:
authorEinat Vinouze <einat.vinouze@intl.att.com>2020-01-30 16:11:29 +0200
committerIttay Stern <ittay.stern@att.com>2020-01-30 18:11:18 +0200
commit714c28d14b53b91eac1a5ffa3ebdf63650028918 (patch)
tree2e3599556dcf7630a5b2d56f9d2770d0943bba88 /vid-automation/src
parentf4993218ce5204a3e8b4527e40f71d5fdc5d1de9 (diff)
Test that a service instance of another subscriber has no edit permission
Issue-ID: VID-758 Change-Id: Ia394c7b04d78cf9fb5e187e8d2d9b7b3a62ef210 Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com> Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-automation/src')
-rw-r--r--vid-automation/src/main/java/vid/automation/test/infra/Features.java1
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java33
2 files changed, 34 insertions, 0 deletions
diff --git a/vid-automation/src/main/java/vid/automation/test/infra/Features.java b/vid-automation/src/main/java/vid/automation/test/infra/Features.java
index d98103402..55b7b3fd0 100644
--- a/vid-automation/src/main/java/vid/automation/test/infra/Features.java
+++ b/vid-automation/src/main/java/vid/automation/test/infra/Features.java
@@ -58,6 +58,7 @@ public enum Features implements Feature {
FLAG_2002_UNLIMITED_MAX,
FLAG_2004_INSTANTIATION_TEMPLATES_POPUP,
FLAG_2006_VFM_SDNC_PRELOAD_FILES,
+ FLAG_2006_USER_PERMISSIONS_BY_OWNING_ENTITY,
;
public boolean isActive() {
diff --git a/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java
index 555c2edcf..e170c450f 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java
@@ -2,6 +2,7 @@ package org.onap.vid.api;
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.defaultPlacement;
import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.ofL3Network;
@@ -13,12 +14,15 @@ import static org.onap.simulator.presetGenerator.presets.ecompportal_att.EcompPo
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.AssertJUnit.assertEquals;
+import static vid.automation.test.Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_CRAIG_ROBERTS;
import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND;
import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET;
import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets;
import static vid.automation.test.utils.TestHelper.GET_SERVICE_MODELS_BY_DISTRIBUTION_STATUS;
import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
@@ -898,6 +902,35 @@ public class AaiApiTest extends BaseApiAaiTest {
assertThat(response.getBody(), jsonEquals(getResourceAsString(AAI_VNFS_FOR_CHANGE_MANAGEMENT_JSON_BY_PARAMS)));
}
+ @Test
+ public void searchServiceInstances_serviceInstanceOfAnotherSubscriber_authIsFollwingFeatureToggle() {
+ String craigRobertsSubscriberId = "31739f3e-526b-11e6-beb8-9e71128cae77";
+ String aServiceInstanceId = "4ea864f2-b946-473a-b51c-51a7c10b8391";
+ String aServiceOwningEntityId = "f160c875-ddd1-4ef5-84d8-d098784daa3a";
+ String currentUserAuthorizedOwningEntityId = "SILVIA ROBBINS"; // this will need to change with translateOwningEntityNameToOwningEntityId
+
+ boolean expectedPermission = Features.FLAG_2006_USER_PERMISSIONS_BY_OWNING_ENTITY.isActive();
+
+ SimulatorApi.registerExpectation(GET_SUBSCRIBERS_FOR_CUSTOMER_CRAIG_ROBERTS,
+ ImmutableMap.of(aServiceOwningEntityId, currentUserAuthorizedOwningEntityId), CLEAR_THEN_SET);
+
+ JsonNode serviceInstancesResult = restTemplate
+ .getForObject(uri + "/search_service_instances?subscriberId=" + craigRobertsSubscriberId, JsonNode.class);
+
+ assertThat(serviceInstancesResult.path("service-instances").isArray(), is(true));
+
+ ArrayNode servicesArray = ((ArrayNode) serviceInstancesResult.path("service-instances"));
+
+ JsonNode aServiceResult = Streams.fromIterator(servicesArray.iterator())
+ .filter(it -> it.path("serviceInstanceId").asText().equals(aServiceInstanceId))
+ .findAny()
+ .orElseThrow(() -> new AssertionError("could not find serviceInstanceId=" + aServiceInstanceId));
+
+ assertThat(aServiceResult.toString(),
+ aServiceResult.path("isPermitted").booleanValue(), is(expectedPermission));
+
+ }
+
private void assertResponse(Object expected, String response) {
assertResponse(Configuration.empty(), expected, response);
}