Rename Role's subscriberId field 46/100846/1
authorIttay Stern <ittay.stern@att.com>
Tue, 28 Jan 2020 10:36:50 +0000 (12:36 +0200)
committerIttay Stern <ittay.stern@att.com>
Tue, 28 Jan 2020 10:42:49 +0000 (12:42 +0200)
It was named subscriberName, although containing the id.

Issue-ID: VID-758

Change-Id: I28fd174a6eab642d34aef207e9d3ca69e8091884
Signed-off-by: Ittay Stern <ittay.stern@att.com>
vid-app-common/src/main/java/org/onap/vid/roles/AlwaysValidRoleValidator.java
vid-app-common/src/main/java/org/onap/vid/roles/Role.java
vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java
vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorByOwningEntity.java
vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorBySubscriberAndServiceType.java
vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorsComposer.kt
vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java

index e12f540..66eab18 100644 (file)
@@ -27,7 +27,7 @@ public class AlwaysValidRoleValidator implements RoleValidator {
     }
 
     @Override
-    public boolean isSubscriberPermitted(String subscriberName) {
+    public boolean isSubscriberPermitted(String subscriberId) {
         return true;
     }
 
@@ -37,7 +37,7 @@ public class AlwaysValidRoleValidator implements RoleValidator {
     }
 
     @Override
-    public boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName) {
+    public boolean isTenantPermitted(String subscriberId, String serviceType, String tenantName) {
         return true;
     }
 }
index 4544830..3d94dc0 100644 (file)
@@ -28,15 +28,15 @@ public class Role {
 
     private EcompRole ecompRole;
 
-    private String subscribeName;
+    private String subscriberId;
 
     private String serviceType;
 
     private String tenant;
 
-    public Role(EcompRole ecompRole, String subscribeName, String serviceType, String tenant) {
+    public Role(EcompRole ecompRole, String subscriberId, String serviceType, String tenant) {
         this.ecompRole = ecompRole;
-        this.subscribeName = subscribeName;
+        this.subscriberId = subscriberId;
         this.serviceType = serviceType;
         this.tenant = tenant;
     }
@@ -46,12 +46,12 @@ public class Role {
     }
 
 
-    public String getSubscribeName() {
-        return subscribeName;
+    public String getSubscriberId() {
+        return subscriberId;
     }
 
-    public void setSubscribeName(String subscribeName) {
-        this.subscribeName = subscribeName;
+    public void setSubscriberId(String subscriberId) {
+        this.subscriberId = subscriberId;
     }
 
     public String getServiceType() {
index 4ad168c..ed280c8 100644 (file)
@@ -38,9 +38,9 @@ public interface RoleValidator {
             : new RoleValidatorBySubscriberAndServiceType(roles);
     }
 
-    boolean isSubscriberPermitted(String subscriberName);
+    boolean isSubscriberPermitted(String subscriberId);
 
     boolean isServicePermitted(WithPermissionProperties serviceInstanceSearchResult);
 
-    boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName);
+    boolean isTenantPermitted(String subscriberId, String serviceType, String tenantName);
 }
index 726567c..50fc109 100644 (file)
@@ -28,7 +28,7 @@ public class RoleValidatorByOwningEntity implements RoleValidator{
     }
 
     @Override
-    public boolean isSubscriberPermitted(String subscriberName) {
+    public boolean isSubscriberPermitted(String subscriberId) {
         return false;
     }
 
@@ -38,7 +38,7 @@ public class RoleValidatorByOwningEntity implements RoleValidator{
     }
 
     @Override
-    public boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName) {
+    public boolean isTenantPermitted(String subscriberId, String serviceType, String tenantName) {
         return false;
     }
 }
index 95d8a16..1e0f9f4 100644 (file)
@@ -31,9 +31,9 @@ public class RoleValidatorBySubscriberAndServiceType implements RoleValidator {
     }
 
     @Override
-    public boolean isSubscriberPermitted(String subscriberName) {
+    public boolean isSubscriberPermitted(String subscriberId) {
         for (Role role : userRoles) {
-            if (role.getSubscribeName().equals(subscriberName)) {
+            if (role.getSubscriberId().equals(subscriberId)) {
                 return true;
             }
         }
@@ -43,7 +43,7 @@ public class RoleValidatorBySubscriberAndServiceType implements RoleValidator {
     @Override
     public boolean isServicePermitted(WithPermissionProperties permissionProperties) {
         for (Role role : userRoles) {
-            if (role.getSubscribeName().equals(permissionProperties.getSubscriberId()) && role.getServiceType().equals(permissionProperties.getServiceType())) {
+            if (role.getSubscriberId().equals(permissionProperties.getSubscriberId()) && role.getServiceType().equals(permissionProperties.getServiceType())) {
                 return true;
             }
         }
@@ -51,9 +51,9 @@ public class RoleValidatorBySubscriberAndServiceType implements RoleValidator {
     }
 
     @Override
-    public boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName) {
+    public boolean isTenantPermitted(String subscriberId, String serviceType, String tenantName) {
         for (Role role : userRoles) {
-            if (role.getSubscribeName().equals(globalCustomerId)
+            if (role.getSubscriberId().equals(subscriberId)
                 && role.getServiceType().equals(serviceType)
                 && (role.getTenant() == null || role.getTenant().equalsIgnoreCase(tenantName))) {
                 return true;
index 8736223..d012cb3 100644 (file)
@@ -7,10 +7,10 @@ class RoleValidatorsComposer(private vararg val roleValidators: RoleValidator) :
     override fun isServicePermitted(p: WithPermissionProperties): Boolean =
             roleValidators.any { it.isServicePermitted(p) }
 
-    override fun isSubscriberPermitted(subscriberName: String?): Boolean =
-            roleValidators.any { it.isSubscriberPermitted(subscriberName) }
+    override fun isSubscriberPermitted(subscriberId: String?): Boolean =
+            roleValidators.any { it.isSubscriberPermitted(subscriberId) }
 
-    override fun isTenantPermitted(globalCustomerId: String?, serviceType: String?, tenantName: String?): Boolean =
-            roleValidators.any { it.isTenantPermitted(globalCustomerId, serviceType, tenantName) }
+    override fun isTenantPermitted(subscriberId: String?, serviceType: String?, tenantName: String?): Boolean =
+            roleValidators.any { it.isTenantPermitted(subscriberId, serviceType, tenantName) }
 
 }
index c1033d2..452ae52 100644 (file)
@@ -42,7 +42,7 @@ import org.testng.annotations.Test;
 public class RoleProviderTest {
 
     private static final String SAMPLE_SUBSCRIBER = "sampleSubscriber";
-    private static final String SAMPLE_CUSTOMER_ID = "sampleCustomerId";
+    private static final String SAMPLE_SUBSCRIBER_ID = "subscriberId";
     private static final String SERVICE_TYPE_LOGS = "LOGS";
     private static final String TENANT_PERMITTED = "PERMITTED";
     private static final String SAMPLE_SERVICE = "sampleService";
@@ -83,7 +83,7 @@ public class RoleProviderTest {
         Role role = roleProvider.createRoleFromStringArr(roleParts, SAMPLE_ROLE_PREFIX);
 
         assertThat(role.getEcompRole()).isEqualTo(EcompRole.READ);
-        assertThat(role.getSubscribeName()).isEqualTo(SAMPLE_CUSTOMER_ID);
+        assertThat(role.getSubscriberId()).isEqualTo(SAMPLE_SUBSCRIBER_ID);
         assertThat(role.getTenant()).isEqualTo(SAMPLE_TENANT);
         assertThat(role.getServiceType()).isEqualTo(SAMPLE_SERVICE);
     }
@@ -97,7 +97,7 @@ public class RoleProviderTest {
         Role role = roleProvider.createRoleFromStringArr(roleParts, SAMPLE_ROLE_PREFIX);
 
         assertThat(role.getEcompRole()).isEqualTo(EcompRole.READ);
-        assertThat(role.getSubscribeName()).isEqualTo(SAMPLE_CUSTOMER_ID);
+        assertThat(role.getSubscriberId()).isEqualTo(SAMPLE_SUBSCRIBER_ID);
         assertThat(role.getServiceType()).isEqualTo(SAMPLE_SERVICE);
         assertThat(role.getTenant()).isNullOrEmpty();
     }
@@ -111,7 +111,7 @@ public class RoleProviderTest {
 
     @Test
     public void shouldProperlyRetrieveUserRolesWhenPermissionIsDifferentThanRead() {
-        Role expectedRole = new Role(EcompRole.READ, SAMPLE_CUSTOMER_ID, SAMPLE_SERVICE, SAMPLE_TENANT);
+        Role expectedRole = new Role(EcompRole.READ, SAMPLE_SUBSCRIBER_ID, SAMPLE_SERVICE, SAMPLE_TENANT);
         setSubscribers();
 
         List<Role> userRoles = roleProvider.getUserRoles(request);
@@ -121,7 +121,7 @@ public class RoleProviderTest {
         Role actualRole = userRoles.get(0);
 
         assertThat(actualRole.getTenant()).isEqualTo(expectedRole.getTenant());
-        assertThat(actualRole.getSubscribeName()).isEqualTo(expectedRole.getSubscribeName());
+        assertThat(actualRole.getSubscriberId()).isEqualTo(expectedRole.getSubscriberId());
         assertThat(actualRole.getServiceType()).isEqualTo(expectedRole.getServiceType());
     }
 
@@ -146,7 +146,7 @@ public class RoleProviderTest {
     private void setSubscribers() {
         Subscriber subscriber = new Subscriber();
         subscriber.subscriberName = SAMPLE_SUBSCRIBER;
-        subscriber.globalCustomerId = SAMPLE_CUSTOMER_ID;
+        subscriber.globalCustomerId = SAMPLE_SUBSCRIBER_ID;
         SubscriberList subscriberList = new SubscriberList(Lists.list(subscriber));
         when(aaiService.getFullSubscriberList()).thenReturn(subscriberListResponse);
         when(subscriberListResponse.getT()).thenReturn(subscriberList);