diff options
author | MichaelMorris <michael.morris@est.tech> | 2023-05-15 11:26:46 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2023-05-16 11:23:46 +0000 |
commit | 79d071d42c2016c1bddd5a8a177fb2b462889134 (patch) | |
tree | 4a00e4a1c7f934c0c2599efd66971c8d54cdf3ce /catalog-be/src/test/java | |
parent | da9babe4b44715649abe58008f128967e76db358 (diff) |
Fix error in userId handling
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Issue-ID: SDC-4468
Change-Id: Iccc61e54876fea732d82334d0bf21bc485b9e1bb
(cherry picked from commit 5768f2e5a056df6b23f7f8a87529d5ca00063c68)
Diffstat (limited to 'catalog-be/src/test/java')
6 files changed, 25 insertions, 0 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java index 54ccf2bee9..36d22bc453 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java @@ -2139,6 +2139,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { when(userValidations.validateUserExists(Mockito.eq("userId"))) .thenReturn(user); + when(userValidations.isSameUser(Mockito.eq("userId"), Mockito.eq("userId"))) + .thenReturn(true); when(toscaOperationFacade.getToscaFullElement(any())) .thenReturn(Either.left(resource)); when(artifactToscaOperation.getArtifactById(any(), any(), any(), any())) @@ -2259,6 +2261,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { when(userValidations.validateUserExists(eq(user.getUserId()))) .thenReturn(user); + when(userValidations.isSameUser(Mockito.eq("userId"), Mockito.eq("userId"))) + .thenReturn(true); when(toscaOperationFacade.getToscaFullElement(eq(componentId))) .thenReturn(Either.left(resource)); when(artifactToscaOperation.getArtifactById(anyString(), anyString(), any(ComponentTypeEnum.class), anyString())) diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java index f6a86ac02f..e813924b4b 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java @@ -715,6 +715,7 @@ class ComponentInstanceBusinessLogicTest { private void stubMethods() { Mockito.lenient().when(userValidations.validateUserExists(eq(USER_ID))).thenReturn(user); + Mockito.lenient().when(userValidations.isSameUser(eq(USER_ID),eq(USER_ID))).thenReturn(true); Mockito.lenient().when(componentsUtils .convertFromStorageResponse(eq(StorageOperationStatus.GENERAL_ERROR), any(ComponentTypeEnum.class))) .thenReturn(ActionStatus.GENERAL_ERROR); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java index 953cc3b801..5ecc488570 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java @@ -179,6 +179,7 @@ public class InputsBusinessLogicTest { instanceInputMap.put("someInputId", Collections.singletonList(new ComponentInstanceInput())); service.setComponentInstancesInputs(instanceInputMap); when(userValidations.validateUserExists(eq(USER_ID))).thenReturn(new User()); + when(userValidations.isSameUser(eq(USER_ID),eq(USER_ID))).thenReturn(true); when(userAdminMock.getUser(USER_ID, false)).thenReturn(new User()); } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogicTest.java index cfdd774f67..ddef267c8d 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogicTest.java @@ -46,6 +46,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.openecomp.sdc.be.components.attribute.AttributeDeclarationOrchestrator; import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException; @@ -159,6 +160,7 @@ class OutputsBusinessLogicTest { instanceOutputMap.put("someOutputId", Collections.singletonList(new ComponentInstanceOutput())); service.setComponentInstancesOutputs(instanceOutputMap); when(userValidations.validateUserExists(USER_ID)).thenReturn(new User()); + when(userValidations.isSameUser(eq(USER_ID),eq(USER_ID))).thenReturn(true); when(userAdminMock.getUser(USER_ID, false)).thenReturn(new User()); } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java index d0a91e312a..83e52674d7 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java @@ -502,6 +502,7 @@ class PolicyBusinessLogicTest { @Test void testDeclarePropertiesAsPoliciesSuccess() { + when(userValidations.isSameUser(eq(USER_ID),eq(USER_ID))).thenReturn(true); when(toscaOperationFacade.getToscaElement(eq(COMPONENT_ID), Mockito.any(ComponentParametersView.class))).thenReturn(Either.left(resource)); when(graphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK); when(graphLockOperation.unlockComponent(any(), any())).thenReturn(StorageOperationStatus.OK); @@ -603,6 +604,7 @@ class PolicyBusinessLogicTest { private void stubValidationSuccess() { when(userValidations.validateUserExists(USER_ID)).thenReturn(user); + Mockito.lenient().when(userValidations.isSameUser(eq(USER_ID),eq(USER_ID))).thenReturn(true); when(toscaOperationFacade.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(componentSuccessEither); } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/UserValidationsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/UserValidationsTest.java index c19cf4679e..6a7bed9341 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/UserValidationsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/UserValidationsTest.java @@ -160,4 +160,19 @@ public class UserValidationsTest { }); Mockito.verify(userAdmin, Mockito.times(1)).getUser(Mockito.anyString()); } + + @Test + public void testValidateUserisSame() { + String userId = "cs0008"; + String encryptedSameUser = "eaGi1IQqP9kbgBHuG/pZm9frcXMQUvoQ59rKkiz6+ug="; + + User user = new User(); + user.setUserId(userId); + user.setStatus(UserStatusEnum.ACTIVE); + + Mockito.when(userAdmin.getUser(userId)).thenReturn(user); + Mockito.when(userAdmin.getUser(encryptedSameUser)).thenReturn(user); + + assertTrue(testSubject.isSameUser(userId, encryptedSameUser)); + } } |