import org.onap.portalapp.portal.domain.CentralV2RoleFunction;
import org.onap.portalapp.portal.domain.EPApp;
import org.onap.portalapp.portal.domain.EPUser;
+import org.onap.portalapp.portal.domain.EpAppType;
import org.onap.portalapp.portal.ecomp.model.PortalRestResponse;
import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum;
import org.onap.portalapp.portal.framework.MockitoTestSuite;
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.setUebKey("test");
app.setUebSecret("test");
app.setUebTopicName("test");
- app.setAppType(1);
+ app.setAppType(EpAppType.GUI);
return app;
}
PrintWriter writer = new PrintWriter(sw);
Mockito.when(mockedResponse.getWriter()).thenReturn(writer);
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
List<EPApp> appList = new ArrayList<>();
appList.add(app);
Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey);
String expectedCentralUser = "test";
String loginId = "test";
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
List<EPApp> appList = new ArrayList<>();
appList.add(app);
Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey);
String expectedCentralUser = null;
String loginId = "test";
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
List<EPApp> appList = new ArrayList<>();
appList.add(app);
Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey);
List<CentralV2Role> centralV2RoleList = new ArrayList<>();
List<CentralRole> centralRoleList = new ArrayList<>();
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.FOUND);
Mockito.when(externalAccessRolesService.getNameSpaceIfExists(applicationList.get(0))).thenReturn(response);
List<CentralV2Role> centralV2RoleList = new ArrayList<>();
List<CentralRole> centralRoleList = new ArrayList<>();
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
ResponseEntity<String> response = null;
Mockito.when(externalAccessRolesService.getNameSpaceIfExists(applicationList.get(0))).thenReturn(response);
List<EPApp> applicationList = new ArrayList<>();
List<CentralV2Role> centralV2Role = new ArrayList<>();
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.FOUND);
Mockito.when(externalAccessRolesService.getNameSpaceIfExists(applicationList.get(0))).thenReturn(response);
List<EPApp> applicationList = new ArrayList<>();
List<CentralV2Role> centralV2Role = new ArrayList<>();
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
ResponseEntity<String> response = null;
Mockito.when(externalAccessRolesService.getNameSpaceIfExists(applicationList.get(0))).thenReturn(response);
List<EPApp> applicationList = new ArrayList<>();
List<CentralV2RoleFunction> centralV2RoleFunction = new ArrayList<>();
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.FOUND);
Mockito.when(externalAccessRolesService.getNameSpaceIfExists(applicationList.get(0))).thenReturn(response);
List<EPApp> applicationList = new ArrayList<>();
List<CentralV2RoleFunction> centralV2RoleFunction = new ArrayList<>();
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.FOUND);
Mockito.when(externalAccessRolesService.getNameSpaceIfExists(applicationList.get(0))).thenReturn(response);
CentralRole expectedCentralRole = null;
List<EPApp> applicationList = new ArrayList<>();
long roleId = 1;
- CentralV2Role centralV2Role = new CentralV2Role();
+ CentralV2Role centralV2Role = new CentralV2Role.CentralV2RoleBuilder().createCentralV2Role();
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey);
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.FOUND);
StringWriter sw = new StringWriter();
PrintWriter writer = new PrintWriter(sw);
Mockito.when(mockedResponse.getWriter()).thenReturn(writer);
- CentralV2Role answer = new CentralV2Role();
+ CentralV2Role answer = new CentralV2Role.CentralV2RoleBuilder().createCentralV2Role();
long roleId = 1;
Mockito.when(externalAccessRolesService.getRoleInfo(roleId, mockedRequest.getHeader(uebKey)))
.thenReturn(answer);
@Test
public void getV2RoleInfoValidationTest() throws Exception {
- CentralV2Role expectedCentralRole = new CentralV2Role();
+ CentralV2Role expectedCentralRole = new CentralV2Role.CentralV2RoleBuilder().createCentralV2Role();
expectedCentralRole.setActive(false);
List<EPApp> applicationList = new ArrayList<>();
long roleId = 1;
- CentralV2Role centralV2Role = new CentralV2Role();
+ CentralV2Role centralV2Role = new CentralV2Role.CentralV2RoleBuilder().createCentralV2Role();
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey);
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.FOUND);
StringWriter sw = new StringWriter();
PrintWriter writer = new PrintWriter(sw);
Mockito.when(mockedResponse.getWriter()).thenReturn(writer);
- CentralV2Role answer = new CentralV2Role();
+ CentralV2Role answer = new CentralV2Role.CentralV2RoleBuilder().createCentralV2Role();
long roleId = 1;
Mockito.when(externalAccessRolesService.getRoleInfo(roleId, mockedRequest.getHeader(uebKey)))
.thenReturn(answer);
CentralV2RoleFunction centralV2RoleFunction = new CentralV2RoleFunction();
centralV2RoleFunction.setCode("test");
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey);
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.FOUND);
String code = "test";
CentralV2RoleFunction centralV2RoleFunction = null;
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey);
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.FOUND);
@Test
public void getRoleFunctionTest() throws Exception {
EPApp mockApp = mockApp();
- mockApp.setCentralAuth(true);
+ mockApp.setRolesInAAF(true);
List<EPApp> mockAppList = new ArrayList<>();
mockAppList.add(mockApp);
StringWriter sw = new StringWriter();
public void getRoleFunctionXSSTest() throws Exception {
String expected = getXSSKeyJson();
EPApp mockApp = mockApp();
- mockApp.setCentralAuth(true);
+ mockApp.setRolesInAAF(true);
List<EPApp> mockAppList = new ArrayList<>();
mockAppList.add(mockApp);
StringWriter sw = new StringWriter();
public void saveRoleFunctionExceptionTest() throws Exception {
List<EPApp> applicationList = new ArrayList<>();
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList);
PortalRestResponse<String> portalRestResponse = null;
List<EPUser> userList = new ArrayList<>();
userList.add(user);
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
JSONObject roleFunc = new JSONObject();
roleFunc.put("type", "test_type");
List<EPUser> userList = new ArrayList<>();
userList.add(user);
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
JSONObject roleFunc = new JSONObject();
roleFunc.put("type", "<script>alert(“XSS”)</script> ");
List<EPUser> userList = new ArrayList<>();
userList.add(user);
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
List<EPApp> appList = new ArrayList<>();
appList.add(app);
expectedportalRestResponse.setStatus(PortalRestStatusEnum.OK);
List<EPUser> userList = new ArrayList<>();
userList.add(user);
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
List<EPApp> appList = new ArrayList<>();
appList.add(app);
String code = "<script>alert(‘XSS’)</script>";
public void getActiveRolesValidationTest() throws Exception {
List<CentralRole> expectedRolesList = null;
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
List<EPApp> appList = new ArrayList<>();
appList.add(app);
List<CentralV2Role> cenRoles = new ArrayList<>();
Mockito.when(mockedResponse.getWriter()).thenReturn(writer);
List<EPApp> applicationList = new ArrayList<>();
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList);
Mockito.when(externalAccessRolesService.getAllAppUsers(mockedRequest.getHeader(uebKey))).thenReturn(users);
List<EPApp> applicationList = new ArrayList<>();
EPApp app = mockApp();
app.setUebKey("uebKey");
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList);
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.OK);
List<EPApp> applicationList = new ArrayList<>();
EPApp app = mockApp();
app.setUebKey("uebKey");
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList);
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.OK);
public void getEpUserExceptionTest() throws Exception {
List<EPApp> applicationList = new ArrayList<>();
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList);
StringWriter sw = new StringWriter();
PrintWriter writer = new PrintWriter(sw);
List<EPApp> applicationList = new ArrayList<>();
EPApp app = mockApp();
app.setUebKey("uebKey");
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList);
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.OK);
List<EPApp> applicationList = new ArrayList<>();
EPApp app = mockApp();
app.setUebKey("uebKey");
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
applicationList.add(app);
Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList);
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.OK);
Mockito.when(externalAccessRolesService.getNameSpaceIfExists(app)).thenReturn(response);
Mockito.doNothing().when(externalAccessRolesService).syncApplicationRolesWithEcompDB(app);
List<CentralV2Role> cenRoleList = new ArrayList<>();
- CentralV2Role role = new CentralV2Role();
+ CentralV2Role role = new CentralV2Role.CentralV2RoleBuilder().createCentralV2Role();
role.setName("test");
cenRoleList.add(role);
Mockito.when(externalAccessRolesService.getActiveRoles(mockedRequest.getHeader(uebKey))).thenReturn(null);
public void getEPRolesOfApplicationExceptionTest() throws Exception {
List<EPApp> applicationList = new ArrayList<>();
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList);
StringWriter sw = new StringWriter();
PrintWriter writer = new PrintWriter(sw);
List<EPUser> userList = new ArrayList<>();
userList.add(user);
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
List<EPApp> appList = new ArrayList<>();
appList.add(app);
expectedportalRestResponse.setStatus(PortalRestStatusEnum.OK);
List<EPUser> userList = new ArrayList<>();
userList.add(user);
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
List<EPApp> appList = new ArrayList<>();
appList.add(app);
expectedportalRestResponse.setStatus(PortalRestStatusEnum.ERROR);
List<EPUser> userList = new ArrayList<>();
userList.add(user);
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
List<EPApp> appList = new ArrayList<>();
appList.add(app);
expectedportalRestResponse.setStatus(PortalRestStatusEnum.ERROR);
List<EPUser> userList = new ArrayList<>();
userList.add(user);
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
List<EPApp> appList = new ArrayList<>();
appList.add(app);
expectedportalRestResponse.setStatus(PortalRestStatusEnum.OK);
List<EPUser> userList = new ArrayList<>();
userList.add(user);
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
List<EPApp> appList = new ArrayList<>();
appList.add(app);
String code = "<img src=xss onerror=alert(1)>";
List<EPUser> userList = new ArrayList<>();
userList.add(user);
EPApp app = mockApp();
- app.setCentralAuth(true);
+ app.setRolesInAAF(true);
List<EPApp> appList = new ArrayList<>();
appList.add(app);
expectedportalRestResponse.setStatus(PortalRestStatusEnum.ERROR);