Feature toggle for owning-entities filtering 99/101599/1
authorIttay Stern <ittay.stern@att.com>
Wed, 12 Feb 2020 06:40:26 +0000 (08:40 +0200)
committerIttay Stern <ittay.stern@att.com>
Wed, 12 Feb 2020 07:48:21 +0000 (09:48 +0200)
Add roles for all tests' users for all tests' owning-entities; namely
"aaa1", "WayneHolland" and "Melissa".

Issue-ID: VID-758

Change-Id: I54cac487325b6fd1fb9ef0f7a0d18c05c5e353c0
Signed-off-by: Ittay Stern <ittay.stern@att.com>
features.properties.md
vid-app-common/src/main/java/org/onap/vid/properties/Features.java
vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterServiceWithRoles.kt
vid-automation/conf/users
vid-automation/src/main/java/vid/automation/test/infra/Features.java

index a0f7e25..54be31b 100644 (file)
   When flag is true the user will be provided with edit permissions by owning entity id even the user have no permission by Subscriber,
   when the flag is false the user provided with edit permission by Subscriber.
   
+* FLAG_2006_LIMIT_OWNING_ENTITY_SELECTION_BY_ROLES
+  While service instantiation, when flag is enabled, a user will not be able to choose Owning Entity which she has no 
+  matching role for. Relevant roles can be provided by using FLAG_2006_USER_PERMISSIONS_BY_OWNING_ENTITY.
+  
 * FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF
   When flag is true new VF Modules on Alacarte service will inherit LCP-Region and Tenant from parent VNF.
   When off, user is requested to specify LCP-Region and Tenant for each VF Module.
\ No newline at end of file
index cc3fad6..219b65d 100644 (file)
@@ -86,6 +86,7 @@ public enum Features implements Feature {
     FLAG_2002_UNLIMITED_MAX,
     FLAG_MORE_AUDIT_INFO_LINK_ON_AUDIT_INFO,
     FLAG_2006_USER_PERMISSIONS_BY_OWNING_ENTITY,
+    FLAG_2006_LIMIT_OWNING_ENTITY_SELECTION_BY_ROLES,
     FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF,
 
     ;
index f059e59..c9b9d14 100644 (file)
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore
 import org.onap.vid.category.CategoryParameterOptionRep
 import org.onap.vid.category.CategoryParametersResponse
 import org.onap.vid.model.CategoryParameter
+import org.onap.vid.properties.Features
 import org.onap.vid.roles.RoleProvider
 import org.onap.vid.roles.WithPermissionPropertiesOwningEntity
 import org.springframework.beans.factory.annotation.Qualifier
@@ -22,7 +23,7 @@ class CategoryParameterServiceWithRoles(
 
     private val owningEntityKey = "owningEntity"
 
-    private fun shouldTreatPermissions() = false
+    private fun shouldTreatPermissions() = featureManager.isActive(Features.FLAG_2006_LIMIT_OWNING_ENTITY_SELECTION_BY_ROLES)
 
     override fun getCategoryParameters(familyName: CategoryParameter.Family?): CategoryParametersResponse {
         val categoryParameters =
@@ -50,10 +51,11 @@ class CategoryParameterServiceWithRoles(
                 ?.filter { userRolesValidator.isServicePermitted(it) }
     }
 
-
-    class OwningEntityOptionRep(categoryParameterOptionRep: CategoryParameterOptionRep) :
-            CategoryParameterOptionRep(categoryParameterOptionRep.id, categoryParameterOptionRep.name),
-            WithPermissionPropertiesOwningEntity {
+    /**
+     * Encapsulates a CategoryParameterOptionRep where id field  contains an owningEntityId
+     */
+    class OwningEntityOptionRep(option: CategoryParameterOptionRep) :
+            CategoryParameterOptionRep(option.id, option.name), WithPermissionPropertiesOwningEntity {
         override val owningEntityId: String?
             @JsonIgnore get() = id
     }
index de18c38..648b661 100644 (file)
             "userId": "1",
             "password": "1"
           },
-          "roles": ["SILVIA ROBBINS___TYLER SILVIA", "SILVIA ROBBINS___DARREN MCGEE", "CAR_2020_ER___DARREN MCGEE", "CAR_2020_ER___MSO-dev-service-type", "CAR_2020_ER___TYLER SILVIA","READ___LOGS___PERMITTED","Emanuel___mySubType", "global-customer-id___service-instance-type"],
+          "roles": [
+            "d61e6f2d-12fa-4cc2-91df-7c244011d6fc___LOB", "Melissa___LOB", "aaa1___LOB",
+            "SILVIA ROBBINS___TYLER SILVIA", "SILVIA ROBBINS___DARREN MCGEE", "CAR_2020_ER___DARREN MCGEE", "CAR_2020_ER___MSO-dev-service-type", "CAR_2020_ER___TYLER SILVIA","READ___LOGS___PERMITTED","Emanuel___mySubType", "global-customer-id___service-instance-type"
+          ],
           "subscriberNames": ["SILVIA ROBBINS", "CAR_2020_ER", "Emanuel", "global-customer-id"],
           "serviceTypes": ["TYLER SILVIA", "DARREN MCGEE", "MSO-dev-service-type"],
           "tenants": ["092eb9e8e4b7412e8787dd091bc58e86"]
             "userId": "3",
             "password": "3"
           },
-          "roles": ["Emanuel___Emanuel"],
+          "roles": [
+            "d61e6f2d-12fa-4cc2-91df-7c244011d6fc___LOB", "Melissa___LOB", "aaa1___LOB",
+            "Emanuel___Emanuel"
+          ],
           "subscriberNames": ["Emanuel"],
           "serviceTypes": ["Emanuel"],
           "tenants": ["c630e297a3ae486497d63eacec1d7c14", "d3b49834f7164cbe831bfbfa35ef649b"]
              "userId": "667",
              "password": "667"
            },
-           "roles": ["CRAIG/ROBERTS___AIM Transport"],
+           "roles": [
+             "d61e6f2d-12fa-4cc2-91df-7c244011d6fc___LOB", "Melissa___LOB", "aaa1___LOB",
+             "CRAIG/ROBERTS___AIM Transport"
+           ],
            "subscriberNames": ["CRAIG/ROBERTS"],
            "serviceTypes": ["AIM Transport"],
            "tenants": null
             "userId": "4",
             "password": "4"
           },
-          "roles": ["Emanuel___vWINIFRED", "Emanuel___vRichardson"],
+          "roles": [
+            "d61e6f2d-12fa-4cc2-91df-7c244011d6fc___LOB", "Melissa___LOB", "aaa1___LOB",
+            "Emanuel___vWINIFRED", "Emanuel___vRichardson"
+          ],
           "subscriberNames": ["Emanuel"],
           "serviceTypes": ["vWINIFRED", "vRichardson"],
           "tenants": ["092eb9e8e4b7412e8787dd091bc58e86"]
@@ -54,6 +66,7 @@
             "password": "822"
           },
           "roles": [
+            "d61e6f2d-12fa-4cc2-91df-7c244011d6fc___LOB", "Melissa___LOB", "aaa1___LOB",
             "JULIO ERICKSON___Emanuel",
             "JULIO ERICKSON___vRichardson"
 
@@ -68,6 +81,7 @@
             "password": "312"
           },
           "roles": [
+            "d61e6f2d-12fa-4cc2-91df-7c244011d6fc___LOB", "Melissa___LOB", "aaa1___LOB",
             "Emanuel___vRichardson"
           ],
           "subscriberNames": ["Emanuel"],
@@ -80,6 +94,7 @@
             "password": "312"
           },
           "roles": [
+            "d61e6f2d-12fa-4cc2-91df-7c244011d6fc___LOB", "Melissa___LOB", "aaa1___LOB",
             "Emanuel___vWINIFRED___test-hvf6-09"
           ],
           "subscriberNames": ["Emanuel"],
index ddf0bad..ff06bf9 100644 (file)
@@ -59,6 +59,7 @@ public enum Features implements Feature {
     FLAG_2004_INSTANTIATION_TEMPLATES_POPUP,
     FLAG_2006_VFM_SDNC_PRELOAD_FILES,
     FLAG_2006_USER_PERMISSIONS_BY_OWNING_ENTITY,
+    FLAG_2006_LIMIT_OWNING_ENTITY_SELECTION_BY_ROLES,
     FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF,
     ;