aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEinat Vinouze <einat.vinouze@intl.att.com>2020-01-26 14:56:22 +0200
committerEinat Vinouze <einat.vinouze@intl.att.com>2020-01-26 14:48:27 +0000
commit7239330fc0fc4a09a363e0ad765fcb1798292fe5 (patch)
treecb25b1e47959bc7f6049fd151ba86b96484c1560
parent0b738a0f36e4382dbfc237e3dee60fb50eac0b74 (diff)
Rename RoleValidatorByRoles to RoleValidatorBySubscriberAndServiceType
Issue-ID: VID-758 Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com> Change-Id: I61fbfc902afee62e1099e491494065abae523b2e
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorBySubscriberAndServiceType.java (renamed from vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorByRoles.java)4
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/roles/RoleValidatorBySubscriberAndServiceTypeTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/roles/RoleValidatorByRolesTest.java)29
4 files changed, 22 insertions, 19 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java
index 830c0f50c..f0ee26b0b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java
+++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java
@@ -35,7 +35,7 @@ public interface RoleValidator {
static RoleValidator by(List<Role> roles, boolean disableRoles) {
return disableRoles
? new AlwaysValidRoleValidator()
- : new RoleValidatorByRoles(roles);
+ : new RoleValidatorBySubscriberAndServiceType(roles);
}
boolean isSubscriberPermitted(String subscriberName);
diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorByRoles.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorBySubscriberAndServiceType.java
index ad5b519c4..244610c89 100644
--- a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorByRoles.java
+++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorBySubscriberAndServiceType.java
@@ -24,11 +24,11 @@ import java.util.List;
import java.util.Map;
import org.onap.vid.mso.rest.RequestDetails;
-public class RoleValidatorByRoles implements RoleValidator {
+public class RoleValidatorBySubscriberAndServiceType implements RoleValidator {
private final List<Role> userRoles;
- RoleValidatorByRoles(List<Role> roles) {
+ RoleValidatorBySubscriberAndServiceType(List<Role> roles) {
this.userRoles = roles;
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
index 521102383..400926fbd 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
@@ -69,7 +69,7 @@ import org.onap.vid.aai.util.AAIRestInterface;
import org.onap.vid.model.VersionByInvariantIdsRequest;
import org.onap.vid.properties.Features;
import org.onap.vid.roles.RoleProvider;
-import org.onap.vid.roles.RoleValidatorByRoles;
+import org.onap.vid.roles.RoleValidatorBySubscriberAndServiceType;
import org.onap.vid.services.AaiService;
import org.onap.vid.utils.SystemPropertiesWrapper;
import org.onap.vid.utils.Unchecked;
@@ -408,7 +408,7 @@ public class AaiControllerTest {
String okResponseBody = "OK_RESPONSE";
AaiResponse<String> aaiResponse = new AaiResponse<>(okResponseBody, "", HttpStatus.OK.value());
given(featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH)).willReturn(isFeatureActive);
- given(aaiService.getSubscriberData(eq(subscriberId), isA(RoleValidatorByRoles.class),
+ given(aaiService.getSubscriberData(eq(subscriberId), isA(RoleValidatorBySubscriberAndServiceType.class),
eq(isFeatureActive && omitServiceInstances)))
.willReturn(aaiResponse);
@@ -479,7 +479,7 @@ public class AaiControllerTest {
String okResponseBody = "OK_RESPONSE";
AaiResponse<String> aaiResponse = new AaiResponse<>(okResponseBody, "", HttpStatus.OK.value());
given(featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH)).willReturn(isFeatureActive);
- given(aaiService.getSubscriberData(eq(subscriberId), isA(RoleValidatorByRoles.class),
+ given(aaiService.getSubscriberData(eq(subscriberId), isA(RoleValidatorBySubscriberAndServiceType.class),
eq(isFeatureActive && omitServiceInstances)))
.willReturn(aaiResponse);
diff --git a/vid-app-common/src/test/java/org/onap/vid/roles/RoleValidatorByRolesTest.java b/vid-app-common/src/test/java/org/onap/vid/roles/RoleValidatorBySubscriberAndServiceTypeTest.java
index 9362ec9d7..77e5088e5 100644
--- a/vid-app-common/src/test/java/org/onap/vid/roles/RoleValidatorByRolesTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/roles/RoleValidatorBySubscriberAndServiceTypeTest.java
@@ -31,7 +31,7 @@ import org.onap.vid.mso.rest.RequestDetails;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-public class RoleValidatorByRolesTest {
+public class RoleValidatorBySubscriberAndServiceTypeTest {
private static final String SAMPLE_SUBSCRIBER = "sampleSubscriber";
private static final String NOT_MATCHING_SUBSCRIBER = "notMatchingSubscriber";
@@ -46,61 +46,64 @@ public class RoleValidatorByRolesTest {
private Map<String, Object> requestParameters = ImmutableMap.of("subscriptionServiceType", SAMPLE_SERVICE_TYPE);
private Map<String, Object> requestDetailsProperties = ImmutableMap.of("subscriberInfo", subscriberInfo, "requestParameters", requestParameters);
private RequestDetails requestDetails;
- private RoleValidatorByRoles roleValidator;
+ private RoleValidatorBySubscriberAndServiceType roleValidatorBySubscriberAndServiceType;
@BeforeMethod
public void setUp() {
- roleValidator = new RoleValidatorByRoles(roles);
+ roleValidatorBySubscriberAndServiceType = new RoleValidatorBySubscriberAndServiceType(roles);
requestDetails = new RequestDetails();
}
@Test
public void shouldPermitSubscriberWhenNameMatchesAndRolesAreEnabled() {
- assertThat(roleValidator.isSubscriberPermitted(SAMPLE_SUBSCRIBER)).isTrue();
+ assertThat(roleValidatorBySubscriberAndServiceType.isSubscriberPermitted(SAMPLE_SUBSCRIBER)).isTrue();
}
@Test
public void shouldNotPermitSubscriberWhenNameNotMatches() {
- assertThat(roleValidator.isSubscriberPermitted(NOT_MATCHING_SUBSCRIBER)).isFalse();
+ assertThat(roleValidatorBySubscriberAndServiceType.isSubscriberPermitted(NOT_MATCHING_SUBSCRIBER)).isFalse();
}
@Test
public void shouldPermitServiceWhenNamesMatches() {
- assertThat(roleValidator.isServicePermitted(SAMPLE_SUBSCRIBER, SAMPLE_SERVICE_TYPE)).isTrue();
+ assertThat(roleValidatorBySubscriberAndServiceType.isServicePermitted(SAMPLE_SUBSCRIBER, SAMPLE_SERVICE_TYPE)).isTrue();
}
@Test
public void shouldNotPermitServiceWhenSubscriberNameNotMatches() {
- assertThat(roleValidator.isServicePermitted(NOT_MATCHING_SUBSCRIBER, SAMPLE_SERVICE_TYPE)).isFalse();
+ assertThat(
+ roleValidatorBySubscriberAndServiceType.isServicePermitted(NOT_MATCHING_SUBSCRIBER, SAMPLE_SERVICE_TYPE)).isFalse();
}
@Test
public void shouldNotPermitServiceWhenServiceTypeNotMatches() {
- assertThat(roleValidator.isServicePermitted(SAMPLE_SUBSCRIBER, NOT_MATCHING_SUBSCRIBER)).isFalse();
+ assertThat(roleValidatorBySubscriberAndServiceType.isServicePermitted(SAMPLE_SUBSCRIBER, NOT_MATCHING_SUBSCRIBER)).isFalse();
}
@Test
public void shouldPermitTenantWhenNameMatches() {
- assertThat(roleValidator.isTenantPermitted(SAMPLE_SUBSCRIBER, SAMPLE_SERVICE_TYPE, SAMPLE_TENANT)).isTrue();
+ assertThat(roleValidatorBySubscriberAndServiceType
+ .isTenantPermitted(SAMPLE_SUBSCRIBER, SAMPLE_SERVICE_TYPE, SAMPLE_TENANT)).isTrue();
}
@Test
public void shouldNotPermitTenantWhenNameNotMatches() {
- assertThat(roleValidator.isTenantPermitted(SAMPLE_SUBSCRIBER, SAMPLE_SERVICE_TYPE, NOT_MATCHING_TENANT)).isFalse();
+ assertThat(roleValidatorBySubscriberAndServiceType
+ .isTenantPermitted(SAMPLE_SUBSCRIBER, SAMPLE_SERVICE_TYPE, NOT_MATCHING_TENANT)).isFalse();
}
@Test
public void shouldValidateProperlySORequest() {
requestDetails.setAdditionalProperty("requestDetails", requestDetailsProperties);
- assertThat(roleValidator.isMsoRequestValid(requestDetails)).isTrue();
+ assertThat(roleValidatorBySubscriberAndServiceType.isMsoRequestValid(requestDetails)).isTrue();
}
@Test
public void shouldValidateUnknownSORequest() {
- assertThat(roleValidator.isMsoRequestValid(new RequestDetails())).isTrue();
+ assertThat(roleValidatorBySubscriberAndServiceType.isMsoRequestValid(new RequestDetails())).isTrue();
}
@Test
@@ -109,6 +112,6 @@ public class RoleValidatorByRolesTest {
Map<String, Object> requestDetailsProperties = ImmutableMap.of("subscriberInfo", subscriberInfo, "requestParameters", requestParameters);
requestDetails.setAdditionalProperty("requestDetails", requestDetailsProperties);
- assertThat(roleValidator.isMsoRequestValid(requestDetails)).isFalse();
+ assertThat(roleValidatorBySubscriberAndServiceType.isMsoRequestValid(requestDetails)).isFalse();
}
}