aboutsummaryrefslogtreecommitdiffstats
path: root/vid-automation/src/test
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2020-02-05 00:26:37 +0200
committerEylon Malin <eylon.malin@intl.att.com>2020-02-05 00:26:37 +0200
commit4fe55a9f53c156fd8f2103ea6ec81a4652d98d19 (patch)
treea2a63e8b9c40b388eef28091353d01e9bac81592 /vid-automation/src/test
parent9e73da42126982f247a0c64882ac8958e504ca24 (diff)
Respect permissions by owning-entity-id when searching instances by owning entity
Issue-ID: VID-758 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com> Change-Id: I98d3e551231bb5aca3150da99f3431268f3373d8
Diffstat (limited to 'vid-automation/src/test')
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java26
1 files changed, 20 insertions, 6 deletions
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 ca09d796b..54300c22a 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
@@ -47,6 +47,7 @@ import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetInstanceGroups
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetInstanceGroupsByCloudRegionRequiredMissing;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetL3NetworksByCloudRegion;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetL3NetworksByCloudRegionSpecificState;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetModelsByOwningEntity;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetNetworkCollectionDetails;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetNetworkCollectionDetailsInvalidRequest;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetNetworkCollectionDetailsRequiredMissing;
@@ -903,20 +904,34 @@ public class AaiApiTest extends BaseApiAaiTest {
}
@Test
- public void searchServiceInstances_serviceInstanceOfAnotherSubscriber_authIsFollowingFeatureToggle() {
+ public void searchServiceInstancesBySubscriber_serviceInstanceOfAnotherSubscriber_authIsFollowingFeatureToggle() {
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);
+
+ searchServicesAndAssertIsPermitted("subscriberId=" + craigRobertsSubscriberId, "4ea864f2-b946-473a-b51c-51a7c10b8391");
+ }
+
+ @Test
+ public void searchServiceInstancesByOwningEntity_serviceInstanceOfAnotherSubscriber_authIsFollowingFeatureToggle() {
+ String owningEntityName = "someOwning";
+ String owningEntityId = "SILVIA ROBBINS"; // this will need to change with translateOwningEntityNameToOwningEntityId
+
+ SimulatorApi.registerExpectationFromPreset(new PresetAAIGetModelsByOwningEntity(owningEntityName, owningEntityId, "fakeSubscriberId"), CLEAR_THEN_SET);
+
+ searchServicesAndAssertIsPermitted("owningEntity=" + owningEntityName, "af9d52f9-13b2-4657-a198-463677f82dc0");
+ }
+
+ private void searchServicesAndAssertIsPermitted(String queryParams, String aServiceInstanceId) {
+ boolean expectedPermission = Features.FLAG_2006_USER_PERMISSIONS_BY_OWNING_ENTITY.isActive();
+
SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), APPEND);
JsonNode serviceInstancesResult = restTemplate
- .getForObject(uri + "/search_service_instances?subscriberId=" + craigRobertsSubscriberId, JsonNode.class);
+ .getForObject(uri + "/search_service_instances?" + queryParams, JsonNode.class);
assertThat(serviceInstancesResult.path("service-instances").isArray(), is(true));
@@ -929,7 +944,6 @@ public class AaiApiTest extends BaseApiAaiTest {
assertThat(aServiceResult.toString(),
aServiceResult.path("isPermitted").booleanValue(), is(expectedPermission));
-
}
private void assertResponse(Object expected, String response) {