diff options
author | Einat Vinouze <einat.vinouze@intl.att.com> | 2020-01-28 17:29:10 +0200 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2020-01-29 21:31:17 +0200 |
commit | f4993218ce5204a3e8b4527e40f71d5fdc5d1de9 (patch) | |
tree | 89b81955e9349ec2bf51badc57049e59d2d979f3 /vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java | |
parent | c0cbcef18427ec1d0edfb872385f128352487464 (diff) |
RoleValidatorByOwningEntity permits by PermissionPropertiesOwningEntity
PermissionPropertiesOwningEntity is sharing a parent interface
with PermissionPropertiesServiceType: WithPermissionProperties.
Issue-ID: VID-758
Change-Id: I90c04cb8d4331d68329f3a12329244f09c6bc184
Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java')
-rw-r--r-- | vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java b/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java index 3935349c0..8d81c929c 100644 --- a/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java @@ -22,7 +22,6 @@ package org.onap.vid.roles; import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.CoreMatchers.is; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; @@ -32,7 +31,6 @@ import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.assertj.core.util.Lists; -import org.hamcrest.CoreMatchers; import org.mockito.Mock; import org.onap.vid.aai.AaiResponse; import org.onap.vid.aai.exceptions.RoleParsingException; @@ -117,7 +115,7 @@ public class RoleProviderTest { @Test public void shouldProperlyRetrieveUserRolesWhenPermissionIsDifferentThanRead() { - Role expectedRole = new Role(EcompRole.READ, SAMPLE_SUBSCRIBER_ID, SAMPLE_SERVICE, SAMPLE_TENANT); + Role expectedRole = new Role(EcompRole.READ, SAMPLE_SUBSCRIBER_ID, SAMPLE_SERVICE, SAMPLE_TENANT, owningEntityId()); setSubscribers(); List<Role> userRoles = roleProvider.getUserRoles(request); @@ -138,13 +136,14 @@ public class RoleProviderTest { @Test public void shouldReturnNotReadOnlyPermissionWhenRolesArePresent() { - assertThat(roleProvider.userPermissionIsReadOnly(Lists.list(new Role(EcompRole.READ, SAMPLE_SUBSCRIBER, SAMPLE_SERVICE, SAMPLE_TENANT)))).isFalse(); + assertThat(roleProvider.userPermissionIsReadOnly(Lists.list(new Role( + EcompRole.READ, SAMPLE_SUBSCRIBER, SAMPLE_SERVICE, SAMPLE_TENANT, owningEntityId())))).isFalse(); } @Test public void userShouldHavePermissionToReadLogsWhenServiceAndTenantAreCorrect() { - Role withoutPermission = new Role(EcompRole.READ, SAMPLE_SUBSCRIBER, SAMPLE_SERVICE, SAMPLE_TENANT); - Role withPermission = new Role(EcompRole.READ, SAMPLE_SUBSCRIBER, SERVICE_TYPE_LOGS, TENANT_PERMITTED); + Role withoutPermission = new Role(EcompRole.READ, SAMPLE_SUBSCRIBER, SAMPLE_SERVICE, SAMPLE_TENANT, owningEntityId()); + Role withPermission = new Role(EcompRole.READ, SAMPLE_SUBSCRIBER, SERVICE_TYPE_LOGS, TENANT_PERMITTED, owningEntityId()); assertThat(roleProvider.userPermissionIsReadLogs(Lists.list(withoutPermission, withPermission))).isTrue(); } @@ -159,6 +158,12 @@ public class RoleProviderTest { assertThat(result).isEqualTo(expectedRoleValidator); } + private String owningEntityId() { + // while translateOwningEntityNameToOwningEntityId does nothing, no translation happens. + // this will be changed later. + return SAMPLE_SUBSCRIBER; + } + private void setSubscribers() { Subscriber subscriber = new Subscriber(); subscriber.subscriberName = SAMPLE_SUBSCRIBER; |