import org.onap.portalapp.portal.domain.EPUserAppRoles;
import org.onap.portalapp.portal.domain.EPUserAppRolesRequest;
import org.onap.portalapp.portal.domain.EPUserAppRolesRequestDetail;
+import org.onap.portalapp.portal.domain.EpAppType;
import org.onap.portalapp.portal.domain.ExternalSystemAccess;
-import org.onap.portalapp.portal.transport.AppWithRolesForUser;
-import org.onap.portalapp.portal.transport.CentralV2Role;
-import org.onap.portalapp.portal.transport.EPUserAppCurrentRoles;
-import org.onap.portalapp.portal.transport.EcompUserAppRoles;
-import org.onap.portalapp.portal.transport.ExternalRequestFieldsValidator;
-import org.onap.portalapp.portal.transport.FieldsValidator;
-import org.onap.portalapp.portal.transport.FunctionalMenuItem;
-import org.onap.portalapp.portal.transport.FunctionalMenuRole;
-import org.onap.portalapp.portal.transport.RemoteRole;
-import org.onap.portalapp.portal.transport.RemoteUserWithRoles;
-import org.onap.portalapp.portal.transport.RoleInAppForUser;
-import org.onap.portalapp.portal.transport.UserApplicationRoles;
+import org.onap.portalapp.portal.transport.*;
import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
import org.onap.portalapp.portal.utils.EcompPortalUtils;
import org.onap.portalapp.portal.utils.PortalConstants;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@Mock
Transaction transaction;
+
+ @Mock
+ AdminRolesService adminRolesService;
@InjectMocks
UserRolesCommonServiceImpl userRolesCommonServiceImpl = new UserRolesCommonServiceImpl();
EPApp app = new EPApp();
app.setName("Test");
app.setImageUrl("test");
- app.setDescription("test");
- app.setNotes("test");
- app.setUrl("test");
+ app.setAppDescription("test");
+ app.setAppNotes("test");
+ app.setLandingPage("test");
app.setId((long) 1);
app.setAppRestEndpoint("test");
- app.setAlternateUrl("test");
+ app.setAlternateLandingPage("test");
app.setName("test");
app.setMlAppName("test");
app.setMlAppAdminId("test");
- app.setUsername("test");
- app.setAppPassword("test");
+ app.setAppBasicAuthUsername("test");
+ app.setAppBasicAuthPassword("test");
app.setOpen(false);
app.setEnabled(false);
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
app.setUebKey("test");
app.setUebSecret("test");
app.setUebTopicName("test");
- app.setAppType(1);
+ app.setAppType(EpAppType.GUI);
return app;
}
Mockito.when(epAppCommonServiceImpl.getApp(mockApp.getId())).thenReturn(mockApp);
List<RoleInAppForUser> mockRoleInAppForUserList = getMockedRoleInAppUserList();
List<CentralV2Role> mockCenV2Role = new ArrayList<>();
- CentralV2Role cenV2Role = new CentralV2Role(1l, null, null, null, null, null, "test1", true, null,
- new TreeSet<>(), new TreeSet<>(), new TreeSet<>());
- CentralV2Role cenV2Role2 = new CentralV2Role(16l, null, null, null, null, null, "test2", true, null,
- new TreeSet<>(), new TreeSet<>(), new TreeSet<>());
+ CentralV2Role cenV2Role = new CentralV2Role.CentralV2RoleBuilder().setId(1l).setCreated(null).setModified(null)
+ .setCreatedId(null).setModifiedId(null).setRowNum(null).setName("test1").setActive(true)
+ .setPriority(null).setRoleFunctions(new TreeSet<>()).setChildRoles(new TreeSet<>())
+ .setParentRoles(new TreeSet<>()).createCentralV2Role();
+ CentralV2Role cenV2Role2 = new CentralV2Role.CentralV2RoleBuilder().setId(16l).setCreated(null)
+ .setModified(null).setCreatedId(null).setModifiedId(null).setRowNum(null).setName("test2")
+ .setActive(true).setPriority(null).setRoleFunctions(new TreeSet<>()).setChildRoles(new TreeSet<>())
+ .setParentRoles(new TreeSet<>()).createCentralV2Role();
mockCenV2Role.add(cenV2Role);
mockCenV2Role.add(cenV2Role2);
Mockito.when(externalAccessRolesServiceImpl.getRolesForApp(mockApp.getUebKey())).thenReturn(mockCenV2Role);
EPUser user = mockUser.mockEPUser();
user.setId(1l);
EPApp mockApp = mockApp();
- mockApp.setCentralAuth(false);
+ mockApp.setRolesInAAF(false);
EPRole mockEPRole = new EPRole();
mockEPRole.setId(1l);
mockEPRole.setName("test1");
mockEpUserList.add(user);
EPApp mockApp = mockApp();
mockApp.setId(2l);
- mockApp.setCentralAuth(false);
+ mockApp.setRolesInAAF(false);
Mockito.when(epAppCommonServiceImpl.getApp(mockApp.getId())).thenReturn(mockApp);
List<RoleInAppForUser> mockRoleInAppForUserList = new ArrayList<>();
RoleInAppForUser mockRoleInAppForUser = new RoleInAppForUser();
- mockRoleInAppForUser.setIsApplied(false);
+ mockRoleInAppForUser.setIsApplied(true);
mockRoleInAppForUser.setRoleId(333l);
mockRoleInAppForUser.setRoleName("test1");
RoleInAppForUser mockRoleInAppForUser2 = new RoleInAppForUser();
- mockRoleInAppForUser2.setIsApplied(false);
+ mockRoleInAppForUser2.setIsApplied(true);
mockRoleInAppForUser2.setRoleId(777l);
mockRoleInAppForUser2.setRoleName("test2");
RoleInAppForUser mockRoleInAppForUser3 = new RoleInAppForUser();
EPApp mockApp = mockApp();
mockApp.setNameSpace("com.test.com");
mockApp.setId(1l);
- mockApp.setCentralAuth(true);
+ mockApp.setRolesInAAF(true);
Mockito.when(epAppCommonServiceImpl.getApp(mockApp.getId())).thenReturn(mockApp);
Mockito.when(EcompPortalUtils.checkIfRemoteCentralAccessAllowed()).thenReturn(true);
AppWithRolesForUser mockWithRolesForUser = new AppWithRolesForUser();
Mockito.when(session.createSQLQuery("update fn_role set app_id = null where app_id = 1 "))
.thenReturn(epsetAppWithUserRoleUpdateEPRoleQuery);
ExternalRequestFieldsValidator actual = userRolesCommonServiceImpl.setAppWithUserRoleStateForUser(user, mockWithRolesForUser);
- assertFalse(actual.isResult());
+ assertTrue(actual.isResult());
}
private List<EcompUserAppRoles> getCurrentUserRoles(EPUser user, EPApp mockApp) {
EPApp mockApp = mockApp();
mockApp.setNameSpace("com.test.com");
mockApp.setId(2l);
- mockApp.setCentralAuth(false);
+ mockApp.setRolesInAAF(false);
Mockito.when(epAppCommonServiceImpl.getApp(mockApp.getId())).thenReturn(mockApp);
Mockito.when(EcompPortalUtils.checkIfRemoteCentralAccessAllowed()).thenReturn(true);
AppWithRolesForUser mockWithRolesForUser = new AppWithRolesForUser();
EPApp mockApp = mockApp();
mockApp.setNameSpace("com.test.com");
mockApp.setId(1l);
- mockApp.setCentralAuth(true);
+ mockApp.setRolesInAAF(true);
Mockito.when(EcompPortalUtils.checkIfRemoteCentralAccessAllowed()).thenReturn(true);
ExternalSystemUser externalSystemUser = new ExternalSystemUser();
List<ExternalSystemRoleApproval> mockExternalSystemRoleApprovalList = new ArrayList<>();
EPApp mockApp = mockApp();
mockApp.setId(2l);
mockApp.setEnabled(true);
- mockApp.setCentralAuth(false);
+ mockApp.setRolesInAAF(false);
ExternalSystemUser externalSystemUser = new ExternalSystemUser();
List<ExternalSystemRoleApproval> mockExternalSystemRoleApprovalList = new ArrayList<>();
ExternalSystemRoleApproval mockExternalSystemRoleApproval = new ExternalSystemRoleApproval();
EPApp mockApp = mockApp();
mockApp.setId(1l);
mockApp.setEnabled(true);
- mockApp.setCentralAuth(true);
+ mockApp.setRolesInAAF(true);
EPUser user = mockUser.mockEPUser();
EPUser user2 = mockUser.mockEPUser();
user2.setActive(true);
mockUserApplicationRoles2.setRoles(mockRemoteRoleList2);
mockUserApplicationRolesList.add(mockUserApplicationRoles);
mockUserApplicationRolesList.add(mockUserApplicationRoles2);
- Mockito.when((List<EPUser>) dataAccessService.executeNamedQuery("getActiveUsers", null, null))
+ Map<String, Object> params = new HashMap<>();
+ params.put("id", 1l);
+ params.put("active", true);
+ Mockito.when((List<EPUser>) dataAccessService.executeNamedQuery("getActiveUsersForApp", params, null))
.thenReturn(mockEpUserList);
assertEquals(userRolesCommonServiceImpl.getUsersFromAppEndpoint(1l).size(),
mockUserApplicationRolesList.size());
EPApp mockApp = mockApp();
mockApp.setId(2l);
mockApp.setEnabled(true);
- mockApp.setCentralAuth(false);
+ mockApp.setRolesInAAF(false);
Mockito.when(epAppCommonServiceImpl.getApp(mockApp.getId())).thenReturn(mockApp);
List<UserApplicationRoles> mockUserApplicationRolesNonCentralizedList = new ArrayList<>();
UserApplicationRoles mockUserApplicationRoles = new UserApplicationRoles();
EPApp mockApp = mockApp();
mockApp.setId(2l);
mockApp.setEnabled(true);
- mockApp.setCentralAuth(false);
+ mockApp.setRolesInAAF(false);
EPUser user = mockUser.mockEPUser();
AppWithRolesForUser appWithRolesForUser = new AppWithRolesForUser();
List<RoleInAppForUser> mockRoleInAppForUserList = new ArrayList<>();
EPApp mockApp = mockApp();
mockApp.setId(2l);
mockApp.setEnabled(true);
- mockApp.setCentralAuth(false);
+ mockApp.setRolesInAAF(false);
List<EPRole> expected = new ArrayList<>();
EPRole epRole = new EPRole();
epRole.setAppId(mockApp.getId());
EPApp mockApp = mockApp();
mockApp.setId(2l);
mockApp.setEnabled(true);
- mockApp.setCentralAuth(false);
+ mockApp.setRolesInAAF(false);
EPUser user = mockUser.mockEPUser();
List<EPUserApp> expected = new ArrayList<>();
EPUserApp epUserApp = new EPUserApp();
EPApp mockApp = mockApp();
mockApp.setId(2l);
mockApp.setEnabled(true);
- mockApp.setCentralAuth(false);
+ mockApp.setRolesInAAF(false);
EPUser user = mockUser.mockEPUser();
List<EPUserAppCatalogRoles> expected = new ArrayList<>();
EPUserAppCatalogRoles epUserAppCatalogRoles = new EPUserAppCatalogRoles();
EPApp mockApp = mockApp();
mockApp.setId(2l);
mockApp.setEnabled(true);
- mockApp.setCentralAuth(false);
+ mockApp.setRolesInAAF(false);
EPUser user = mockUser.mockEPUser();
List<EPUserApp> expected = new ArrayList<>();
EPUserApp epUserApp = new EPUserApp();
EPApp mockApp2 = mockApp();
mockApp.setId(2l);
mockApp.setEnabled(true);
- mockApp.setCentralAuth(false);
+ mockApp.setRolesInAAF(false);
EPUser user = mockUser.mockEPUser();
List<EPApp> mockEpAppList = new ArrayList<>();
mockEpAppList.add(mockApp);