Merge "test equality in EPUserAppRolesRequestTest.java"
authorManoop Talasila <talasila@research.att.com>
Tue, 9 Oct 2018 19:39:15 +0000 (19:39 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 9 Oct 2018 19:39:15 +0000 (19:39 +0000)
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java
ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/BEPropertyTest.java
ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPRoleTest.java
ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserTest.java
ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/utils/MusicCookieCsrfTokenRepositoryTest.java [new file with mode: 0644]
ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java
ecomp-portal-FE-os/client/src/directives/search-users/search-users.controller.js
ecomp-portal-FE-os/client/src/directives/search-users/search-users.tpl.html

index 809e42f..f8d1116 100644 (file)
@@ -86,7 +86,7 @@ public class EcompPortalUtils {
         *         otherwise
         */
        public static boolean legitimateUserId(String orgUserId) {
-               return orgUserId.matches("^[a-zA-Z0-9]+$");
+               return orgUserId.matches("^[a-zA-Z0-9/_/-/@]+$");
        }
 
        /**
index 102e6ae..516393a 100644 (file)
@@ -4,6 +4,8 @@
  * ===================================================================
  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
  * ===================================================================
+ *  Modifications Copyright © 2018 IBM.
+ * ================================================================================
  *
  * Unless otherwise specified, all software contained herein is licensed
  * under the Apache License, Version 2.0 (the "License");
@@ -45,25 +47,41 @@ import org.junit.Test;
 
 public class BEPropertyTest {
 
-       
-       private static final String TEST="test";
-       
-       @Test
-       public  void test() {
-               BEProperty property=new BEProperty(TEST, TEST);
-               BEProperty beProperty=new BEProperty(TEST, TEST);
-               BEProperty be=property;
-               
-               beProperty.setKey(property.getKey());
-               beProperty.setValue(property.getValue());
-               
-               assertEquals(property.hashCode(), beProperty.hashCode());
-               assertTrue(beProperty.equals(property));
-               assertTrue(be.equals(property));
-               assertFalse(be.equals(null));
-               be.setValue(null);
-               assertTrue(be.equals(property));
-               be.setKey(null);
-               assertTrue(be.equals(property));
-       }
+    
+    private static final String TEST="test";
+    
+    @Test
+    public  void test() {
+        BEProperty property=new BEProperty(TEST, TEST);
+        BEProperty beProperty=new BEProperty(TEST, TEST);
+        BEProperty be=property;
+        
+        beProperty.setKey(property.getKey());
+        beProperty.setValue(property.getValue());
+        
+        assertEquals(property.hashCode(), beProperty.hashCode());
+        assertTrue(beProperty.equals(property));
+        assertTrue(be.equals(property));
+        assertFalse(be.equals(null));
+        be.setValue(null);
+        assertTrue(be.equals(property));
+        be.setKey(null);
+        assertTrue(be.equals(property));
+        
+        assertFalse(property.equals(this));
+        
+        property.setKey(null);
+        beProperty.setKey("notnull");
+        assertFalse(property.equals(beProperty));
+        assertFalse(beProperty.equals(property));
+        
+        property.setKey("notnull");
+        beProperty.setKey("notnull");
+        property.setValue(null);
+        beProperty.setValue("notnull");
+        assertFalse(property.equals(beProperty));
+        assertFalse(beProperty.equals(property));
+        
+        
+    }
 }
index d081b80..f99c80b 100644 (file)
@@ -4,6 +4,8 @@
  * ===================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ===================================================================
+ *  Modifications Copyright © 2018 IBM.
+ * ================================================================================
  *
  * Unless otherwise specified, all software contained herein is licensed
  * under the Apache License, Version 2.0 (the "License");
@@ -51,58 +53,68 @@ import org.onap.portalsdk.core.restful.domain.EcompRoleFunction;
 
 public class EPRoleTest {
 
-       
-       @Test
-       public void testEpRole() {
-               EPRole role=new EPRole();
-               role.setActive(true);
-               role.setAppId(1l);
-               role.setAppRoleId(2l);
-               role.setId(3l);
-               role.setName("TEST_ADMIN");
-               SortedSet<EPRole> childRoles = new TreeSet<EPRole>();
-               EPRole child=new EPRole();
-               child.setActive(true);
-               child.setAppId(1l);
-               child.setAppRoleId(3l);
-               child.setId(6l);
-               child.setName("TEST_USER");
-               childRoles.add(child);
-               role.setChildRoles(childRoles);
-               SortedSet<EPRole> parentRoles = new TreeSet<EPRole>();
-               EPRole parent=new EPRole();
-               parent.setActive(true);
-               parent.setAppId(1l);
-               parent.setAppRoleId(3l);
-               parent.setId(6l);
-               parent.setName("TEST_USER");
-               parentRoles.add(parent);
-               role.setParentRoles(parentRoles);
-               
-               SortedSet<RoleFunction> rolefunction = new TreeSet<RoleFunction>();
-               RoleFunction function=new RoleFunction();
-               function.setAction("Test");;
-               function.setCode("code");
-               rolefunction.add(function);
-               role.setRoleFunctions(rolefunction);
-               role.setPriority(5);
-               role.setAppRoleId(3l);
-               assertEquals(3l, role.getAppRoleId().longValue());
-               assertNotNull(role.getChildRoles());
-               assertNotNull(role.getParentRoles());
-               assertNotNull(role.getRoleFunctions());
-               role.compareTo(role);
-               assertEquals(1l, role.getAppId().longValue());
-               assertEquals("TEST_ADMIN",role.getName());
-               role.removeChildRole(6l);
-               role.removeParentRole(6l);
-               assertEquals(role.toString(), "[Id = 3, name = TEST_ADMIN]");
-               role.removeRoleFunction("code");
-               role.addChildRole(child);
-               role.addParentRole(parent);
-               role.addRoleFunction(function);
-               
-       }
-       
+    
+    @Test
+    public void testEpRole() {
+        EPRole role=new EPRole();
+        role.setActive(true);
+        role.setAppId(1l);
+        role.setAppRoleId(2l);
+        role.setId(3l);
+        role.setName("TEST_ADMIN");
+        SortedSet<EPRole> childRoles = new TreeSet<EPRole>();
+        EPRole child=new EPRole();
+        child.setActive(true);
+        child.setAppId(1l);
+        child.setAppRoleId(3l);
+        child.setId(6l);
+        child.setName("TEST_USER");
+        childRoles.add(child);
+        role.setChildRoles(childRoles);
+        SortedSet<EPRole> parentRoles = new TreeSet<EPRole>();
+        EPRole parent=new EPRole();
+        parent.setActive(true);
+        parent.setAppId(1l);
+        parent.setAppRoleId(3l);
+        parent.setId(6l);
+        parent.setName("TEST_USER");
+        parentRoles.add(parent);
+        role.setParentRoles(parentRoles);
+        
+        SortedSet<RoleFunction> rolefunction = new TreeSet<RoleFunction>();
+        RoleFunction function=new RoleFunction();
+        function.setAction("Test");;
+        function.setCode("code");
+        rolefunction.add(function);
+        role.setRoleFunctions(rolefunction);
+        role.setPriority(5);
+        role.setAppRoleId(3l);
+        assertEquals(3l, role.getAppRoleId().longValue());
+        assertNotNull(role.getChildRoles());
+        assertNotNull(role.getParentRoles());
+        assertNotNull(role.getRoleFunctions());
+        role.compareTo(role);
+        assertEquals(1l, role.getAppId().longValue());
+        assertEquals("TEST_ADMIN",role.getName());
+        role.removeChildRole(6l);
+        role.removeParentRole(6l);
+        assertEquals(role.toString(), "[Id = 3, name = TEST_ADMIN]");
+        role.removeRoleFunction("code");
+        role.addChildRole(child);
+        role.addParentRole(parent);
+        role.addRoleFunction(function);
+        
+        parent.setAppId(null);
+        child.setAppId((long) 1234);
+        assertEquals(parent.compareTo(child), -1);
+        
+        child.setAppId(null);
+        parent.setAppId((long) 1234);
+        assertEquals(parent.compareTo(child), 1);
+        
+        
+        
+    }
+    
 }
 
index bc4c6f3..c856b5a 100644 (file)
@@ -4,6 +4,8 @@
  * ===================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ===================================================================
+ * Modifications Copyright © 2018 IBM.
+ * ================================================================================
  *
  * Unless otherwise specified, all software contained herein is licensed
  * under the Apache License, Version 2.0 (the "License");
@@ -37,7 +39,7 @@
  */
 package org.onap.portalapp.portal.domain;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 import java.util.Date;
 
@@ -46,106 +48,111 @@ import org.onap.portalapp.portal.domain.EPUser;
 
 public class EPUserTest {
 
-       public EPUser mockEPUser(){
-               
-               EPUser epUser = new EPUser();
-               
-               epUser.setId((long)1);
-               epUser.setManagerId((long) 1234);
-               epUser.setFirstName("test");
-               epUser.setLastName("test");
-               epUser.setMiddleInitial("test");
-               epUser.setPhone("test");
-               epUser.setFax("test");
-               epUser.setCellular("test");
-               epUser.setEmail("test");
-               epUser.setAddressId((long) 123); 
-               epUser.setAlertMethodCd("test");
-               epUser.setHrid("test");
-               epUser.setOrgUserId("test");
-               epUser.setOrgCode("test");
-               epUser.setAddress1("test");
-               epUser.setAddress2("test");
-               epUser.setCity("test");
-               epUser.setState("test");
-               epUser.setZipCode("test");
-               epUser.setCountry("test");
-               epUser.setOrgManagerUserId("test");
-               epUser.setLocationClli("test");
-               epUser.setBusinessCountryCode("test");
-               epUser.setBusinessCountryName("test");
-               epUser.setBusinessUnit("test");
-               epUser.setBusinessUnitName("test");
-               epUser.setDepartment("test");
-               epUser.setDepartmentName("test");
-               epUser.setCompanyCode("test");
-               epUser.setCompany("test");
-               epUser.setZipCodeSuffix("test");
-               epUser.setJobTitle("test");
-               epUser.setCommandChain("test");
-               epUser.setSiloStatus("test");
-               epUser.setCostCenter("test");
-               epUser.setFinancialLocCode("test");
-               epUser.setLoginId("test");
-               epUser.setLoginPwd("test");
-               epUser.setLastLoginDate(new Date());
-               epUser.setActive(false);
-               epUser.setInternal(false);
-               epUser.setSelectedProfileId((long) 12345);
-               epUser.setTimeZoneId((long) 12345);
-               epUser.setOnline(false);
-               epUser.setChatId("test");
-               return epUser;
-                                   
-       }
-       
-       @Test
-       public void userTest(){
-               EPUser user = mockEPUser();
-               
-               assertEquals(user.getId(), new Long(1));
-               assertEquals(user.getManagerId(), new Long(1234));
-               assertEquals(user.getFirstName(), "test");
-               assertEquals(user.getLastName(), "test");
-               assertEquals(user.getMiddleInitial(), "test");
-               assertEquals(user.getPhone(), "test");
-               assertEquals(user.getFax(), "test");
-               assertEquals(user.getCellular(), "test");               
-               assertEquals(user.getEmail(), "test");
-               assertEquals(user.getAddressId(), new Long(123) );
-               assertEquals(user.getAlertMethodCd(), "test");
-               assertEquals(user.getHrid(), "test");
-               assertEquals(user.getOrgUserId(), "test");
-               assertEquals(user.getOrgCode(), "test");
-               assertEquals(user.getAddress1(), "test");
-               assertEquals(user.getAddress2(), "test");
-               assertEquals(user.getState(), "test");
-               assertEquals(user.getZipCode(), "test");
-               assertEquals(user.getCountry(), "test");
-               assertEquals(user.getOrgManagerUserId(), "test");
-               assertEquals(user.getLocationClli(), "test");
-               assertEquals(user.getBusinessCountryCode(), "test");
-               assertEquals(user.getBusinessCountryName(), "test");
-               assertEquals(user.getBusinessUnit(), "test");
-               assertEquals(user.getBusinessUnitName(), "test");
-               assertEquals(user.getDepartment(), "test");
-               assertEquals(user.getDepartmentName(), "test");
-               assertEquals(user.getCompanyCode(), "test");
-               assertEquals(user.getCompany(), "test");
-               assertEquals(user.getZipCodeSuffix(), "test");
-               assertEquals(user.getJobTitle(), "test");
-               assertEquals(user.getCommandChain(), "test");
-               assertEquals(user.getSiloStatus(), "test");
-               assertEquals(user.getFinancialLocCode(), "test");
-               assertEquals(user.getLoginId(), "test");
-               assertEquals(user.getLoginPwd(), "test");
-               assertEquals(user.getActive(), false);
-               assertEquals(user.getInternal(), false);
-               assertEquals(user.getSelectedProfileId(), new Long (12345));
-               assertEquals(user.getTimeZoneId(), new Long (12345));
-               assertEquals(user.getChatId(), "test");
-               
-               //assertEquals(user.toString(), "EPUser [orgId=null, managerId=1234, firstName=test, middleInitial=test, lastName=test, phone=test, fax=test, cellular=test, email=test, addressId=123, alertMethodCd=test, hrid=test, orgUserId=test, orgCode=test, address1=test, address2=test, city=test, state=test, zipCode=test, country=test, orgManagerUserId=test, locationClli=test, businessCountryCode=test, businessCountryName=test, businessUnit=test, businessUnitName=test, department=test, departmentName=test, companyCode=test, company=test, zipCodeSuffix=test, jobTitle=test, commandChain=test, siloStatus=test, costCenter=test, financialLocCode=test, loginId=test, loginPwd=test, lastLoginDate=Tue Sep 05 11:04:49 EDT 2017, active=false, internal=false, selectedProfileId=12345, timeZoneId=12345, online=false, chatId=test, isGuest=false, userApps=[], pseudoRoles=[]]");
-       }
-       
+    public EPUser mockEPUser(){
+        
+        EPUser epUser = new EPUser();
+        
+        epUser.setId((long)1);
+        epUser.setManagerId((long) 1234);
+        epUser.setFirstName("test");
+        epUser.setLastName("test");
+        epUser.setMiddleInitial("test");
+        epUser.setPhone("test");
+        epUser.setFax("test");
+        epUser.setCellular("test");
+        epUser.setEmail("test");
+        epUser.setAddressId((long) 123); 
+        epUser.setAlertMethodCd("test");
+        epUser.setHrid("test");
+        epUser.setOrgUserId("test");
+        epUser.setOrgCode("test");
+        epUser.setAddress1("test");
+        epUser.setAddress2("test");
+        epUser.setCity("test");
+        epUser.setState("test");
+        epUser.setZipCode("test");
+        epUser.setCountry("test");
+        epUser.setOrgManagerUserId("test");
+        epUser.setLocationClli("test");
+        epUser.setBusinessCountryCode("test");
+        epUser.setBusinessCountryName("test");
+        epUser.setBusinessUnit("test");
+        epUser.setBusinessUnitName("test");
+        epUser.setDepartment("test");
+        epUser.setDepartmentName("test");
+        epUser.setCompanyCode("test");
+        epUser.setCompany("test");
+        epUser.setZipCodeSuffix("test");
+        epUser.setJobTitle("test");
+        epUser.setCommandChain("test");
+        epUser.setSiloStatus("test");
+        epUser.setCostCenter("test");
+        epUser.setFinancialLocCode("test");
+        epUser.setLoginId("test");
+        epUser.setLoginPwd("test");
+        epUser.setLastLoginDate(new Date());
+        epUser.setActive(false);
+        epUser.setInternal(false);
+        epUser.setSelectedProfileId((long) 12345);
+        epUser.setTimeZoneId((long) 12345);
+        epUser.setOnline(false);
+        epUser.setChatId("test");
+        return epUser;
+                    
+    }
+    
+    @Test
+    public void userTest(){
+        EPUser user = mockEPUser();
+        
+        assertEquals(user.getId(), new Long(1));
+        assertEquals(user.getManagerId(), new Long(1234));
+        assertEquals(user.getFirstName(), "test");
+        assertEquals(user.getLastName(), "test");
+        assertEquals(user.getMiddleInitial(), "test");
+        assertEquals(user.getPhone(), "test");
+        assertEquals(user.getFax(), "test");
+        assertEquals(user.getCellular(), "test");        
+        assertEquals(user.getEmail(), "test");
+        assertEquals(user.getAddressId(), new Long(123) );
+        assertEquals(user.getAlertMethodCd(), "test");
+        assertEquals(user.getHrid(), "test");
+        assertEquals(user.getOrgUserId(), "test");
+        assertEquals(user.getOrgCode(), "test");
+        assertEquals(user.getAddress1(), "test");
+        assertEquals(user.getAddress2(), "test");
+        assertEquals(user.getState(), "test");
+        assertEquals(user.getZipCode(), "test");
+        assertEquals(user.getCountry(), "test");
+        assertEquals(user.getOrgManagerUserId(), "test");
+        assertEquals(user.getLocationClli(), "test");
+        assertEquals(user.getBusinessCountryCode(), "test");
+        assertEquals(user.getBusinessCountryName(), "test");
+        assertEquals(user.getBusinessUnit(), "test");
+        assertEquals(user.getBusinessUnitName(), "test");
+        assertEquals(user.getDepartment(), "test");
+        assertEquals(user.getDepartmentName(), "test");
+        assertEquals(user.getCompanyCode(), "test");
+        assertEquals(user.getCompany(), "test");
+        assertEquals(user.getZipCodeSuffix(), "test");
+        assertEquals(user.getJobTitle(), "test");
+        assertEquals(user.getCommandChain(), "test");
+        assertEquals(user.getSiloStatus(), "test");
+        assertEquals(user.getFinancialLocCode(), "test");
+        assertEquals(user.getLoginId(), "test");
+        assertEquals(user.getLoginPwd(), "test");
+        assertEquals(user.getActive(), false);
+        assertEquals(user.getInternal(), false);
+        assertEquals(user.getSelectedProfileId(), new Long (12345));
+        assertEquals(user.getTimeZoneId(), new Long (12345));
+        assertEquals(user.getChatId(), "test");
+        
+        EPUser another = mockEPUser();
+        assertTrue(user.compareTo(another) == 0);
+        another.setLastName("otherlastname");
+        assertTrue(user.compareTo(another) == 5);
+        
+        //assertEquals(user.toString(), "EPUser [orgId=null, managerId=1234, firstName=test, middleInitial=test, lastName=test, phone=test, fax=test, cellular=test, email=test, addressId=123, alertMethodCd=test, hrid=test, orgUserId=test, orgCode=test, address1=test, address2=test, city=test, state=test, zipCode=test, country=test, orgManagerUserId=test, locationClli=test, businessCountryCode=test, businessCountryName=test, businessUnit=test, businessUnitName=test, department=test, departmentName=test, companyCode=test, company=test, zipCodeSuffix=test, jobTitle=test, commandChain=test, siloStatus=test, costCenter=test, financialLocCode=test, loginId=test, loginPwd=test, lastLoginDate=Tue Sep 05 11:04:49 EDT 2017, active=false, internal=false, selectedProfileId=12345, timeZoneId=12345, online=false, chatId=test, isGuest=false, userApps=[], pseudoRoles=[]]");
+    }
+    
 }
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/utils/MusicCookieCsrfTokenRepositoryTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/utils/MusicCookieCsrfTokenRepositoryTest.java
new file mode 100644 (file)
index 0000000..896c10a
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright © 2018 IBM Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *             http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *             https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * 
+ */
+package org.onap.portalapp.portal.utils;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
+import org.springframework.security.web.csrf.CsrfToken;
+
+public class MusicCookieCsrfTokenRepositoryTest {
+    
+    MusicCookieCsrfTokenRepository repo;
+    
+    CookieCsrfTokenRepository cookieRepo;
+    
+    @Before
+    public void setup() {
+        cookieRepo = new CookieCsrfTokenRepository();
+        repo = new MusicCookieCsrfTokenRepository(cookieRepo);
+    }
+
+    @Test
+    public void  generateTokenTest(){
+        HttpServletRequest requestMock = Mockito.mock(HttpServletRequest.class);
+        CsrfToken expected = cookieRepo.generateToken(requestMock);
+        
+        CsrfToken actual = repo.generateToken(requestMock);
+        
+        Assert.assertEquals(expected.getHeaderName(), actual.getHeaderName());
+        Assert.assertEquals(expected.getParameterName(), actual.getParameterName());
+    }
+}
index e093471..0e9932e 100644 (file)
@@ -39,12 +39,10 @@ package org.onap.portalapp.portal.service;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import org.onap.portalapp.portal.domain.EPUser;
 import org.onap.portalapp.portal.logging.aop.EPMetricsLog;
-import org.onap.portalapp.portal.service.SearchService;
-import org.onap.portalapp.portal.service.SearchServiceImpl;
-import org.onap.portalapp.portal.service.UserService;
 import org.onap.portalapp.portal.transport.UserWithNameSurnameTitle;
 import org.onap.portalapp.portal.utils.EcompPortalUtils;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
@@ -75,15 +73,14 @@ public class SearchServiceImpl implements SearchService {
                return searchUsersInFnTable(searchString);
        }
        
+       
        @Override
        public String searchUsersInFnTable(String searchString) {
-               String orgUserId = null;
                List<String> tokens = EcompPortalUtils.parsingByRegularExpression(searchString, " ");
                while (tokens.size() > 2) { // we use no more then first 2 tokens (userId is removed, see above)
                        tokens.remove(tokens.size() - 1);
                }
                EPUser attrUser = new EPUser();
-               attrUser.setOrgUserId(orgUserId);
                List<UserWithNameSurnameTitle> resultOfSearch = new ArrayList<UserWithNameSurnameTitle>(), resultOfAdditionalSearch = null,
                                resultOfSearchUserId = new ArrayList<UserWithNameSurnameTitle>();
                if (tokens.size() == 2) {
@@ -101,6 +98,7 @@ public class SearchServiceImpl implements SearchService {
                        }
                } else if (tokens.size() == 1) {
                        attrUser.setFirstName(tokens.get(0));
+                       attrUser.setOrgUserId(tokens.get(0));
                        resultOfSearch = this.searchUsersByName(attrUser);
                        resultOfSearchUserId = this.searchUsersByUserId(attrUser);
                        resultOfSearch = this.removeWrongFirstNames(resultOfSearch, tokens.get(0));
@@ -115,6 +113,7 @@ public class SearchServiceImpl implements SearchService {
                        resultOfSearch.addAll(resultOfAdditionalSearch);
                }
                resultOfSearch.addAll(resultOfSearchUserId);
+               resultOfSearch.stream().distinct().collect(Collectors.toList());
                resultOfSearch = this.cutSearchResultToMaximumSize(resultOfSearch);
                ObjectMapper mapper = new ObjectMapper();
                String result = "[]";
@@ -126,7 +125,6 @@ public class SearchServiceImpl implements SearchService {
                return result;
        }
 
-       
        @SuppressWarnings("rawtypes")
        public List<UserWithNameSurnameTitle> searchUsersByUserId(EPUser attrUser) {
                List<UserWithNameSurnameTitle> foundUsers = new ArrayList<UserWithNameSurnameTitle>();
index c2067cc..fc7fd7c 100644 (file)
                           var warningMsg = "Passwords do not match, please try again.";
                           confirmBoxService.showInformation(warningMsg).then(isConfirmed => {return;});
                           return;
+                  } else if(/[^a-zA-Z0-9\-\@\_]/.test(this.newUser.loginId)){
+                          var warningMsg = "Login ID should not contain special characters except '@', '-', and '_'.";
+                          confirmBoxService.showInformation(warningMsg).then(isConfirmed => {return;});
+                          return;
                   }
                   else {
                           // check password length complexity.
index d8a476d..ff8d86e 100644 (file)
   
   -->
 <div class="search-users-directive">
-    <form name="searchUsersForm" novalidate method="post">
-        <div class="title" ng-bind="searchUsers.searchTitle"></div>
-        <div class="main">
-           <div ng-show="searchUsers.showSearch">
-                   <div class="search-instructions">Enter first name, last name or User ID</div>
-                   <div class="search">
-                       <input id="input-user-search"
-                              autocomplete="off"
-                              type="text"
-                              name="searchString"
-                              placeholder="Search"
-                              ng-model="searchUsers.searchUserString"
-                              ng-keyup="$event.keyCode===13 && searchUsersForm.searchString.$valid && searchUsers.searchUsers()"
-                              pattern="[a-zA-Z0-9-_'\s]{1,}"
-                              maxlength="80"
-                              required="true" auto-focus tabindex="0"/>
-                      
-                       <button class="btn btn-alt btn-small" tabindex="2" id="button-search-users"
-                               ng-class="{disabled: searchUsersForm.searchString.$invalid || searchUsers.searchUsersInProgress}"
-                               ng-click="searchUsersForm.searchString.$valid && searchUsers.searchUsers()">Search
-                       </button>
-                       
-                       <button class="btn btn-alt btn-small" id="Create-New-User-button" ng-click="searchUsers.showAddUserSection()">
-                               <i class="icon-people-userbookmark" aria-hidden="true"></i>&nbsp;New User
-                       </button> 
-                       
-                   </div>
-       
-                   <span class="ecomp-spinner" ng-show="searchUsers.isLoading"></span>
-                   <div ng-show="UserSearchsIsNull===false">
-                       <div class="search-results"
-                            ng-show="!searchUsers.isLoading
+       <form name="searchUsersForm" novalidate method="post">
+               <div class="title" ng-bind="searchUsers.searchTitle"></div>
+               <div class="main">
+                       <div ng-show="searchUsers.showSearch">
+                               <div class="search-instructions">Enter first name, last name
+                                       or User ID</div>
+                               <div class="search">
+                                       <input id="input-user-search" autocomplete="off" type="text"
+                                               name="searchString" placeholder="Search"
+                                               ng-model="searchUsers.searchUserString"
+                                               ng-keyup="$event.keyCode===13 && searchUsersForm.searchString.$valid && searchUsers.searchUsers()"
+                                               pattern="[a-zA-Z0-9-_'\s]{1,}" maxlength="80" required="true"
+                                               auto-focus tabindex="0" />
+
+                                       <button class="btn btn-alt btn-small" tabindex="2"
+                                               id="button-search-users"
+                                               ng-class="{disabled: searchUsersForm.searchString.$invalid || searchUsers.searchUsersInProgress}"
+                                               ng-click="searchUsersForm.searchString.$valid && searchUsers.searchUsers()">Search
+                                       </button>
+
+                                       <button class="btn btn-alt btn-small" id="Create-New-User-button"
+                                               ng-click="searchUsers.showAddUserSection()">
+                                               <i class="icon-people-userbookmark" aria-hidden="true"></i>&nbsp;New
+                                               User
+                                       </button>
+
+                               </div>
+
+                               <span class="ecomp-spinner" ng-show="searchUsers.isLoading"></span>
+                               <div ng-show="UserSearchsIsNull===false">
+                                       <div class="search-results"
+                                               ng-show="!searchUsers.isLoading
                             && searchUsers.searchUsersResults
                             && searchUsers.searchUsersResults.length">
-                           <div id="search-results" ng-show="UserSearchsIsNull===false"
-                                class="results-title"
-                                ng-bind="'Showing ' + searchUsers.searchUsersResults.length + ' results'"></div>
-                           <div class="results-container" scroll-top="searchUsers.scrollApi">
-                               <div id="search-result-{{$index}}"
-                                    class="user"
-                                    ng-repeat="user in (searchUsers.searchUsersResults | orderBy:['firstName','lastName','orgUserId']) | limitTo: 100 track by $index"
-                                    ng-click="searchUsers.setSelectedUser(user)"
-                                    ng-class="{selected: user.orgUserId === searchUsers.selectedUser.orgUserId}">
-                                   <div id="main-name-{{$index}}" class="main-name">
-                                       <span id="result-first-name-{{$index}}" ng-bind="::user.firstName"></span>
-                                       <span id="result-last-name-{{$index}}"  ng-bind="::user.lastName"></span>
-                                       <span id="result-uuid-{{$index}}" ng-bind="::user.orgUserId"></span></div>
-                                   <div id="job-title-{{$index}}" class="sub-job-title" ng-bind="::user.jobTitle"></div>
-                                   <br/>
-                               </div>
-                           </div>
-                       </div>
-                   </div>
-                   
-                   <div class="error-text"
-                        id="user-search-error-403"
-                        ng-show="UserSearchsIsNull===true">
-                       No match found.
-                   </div>
-                   
-                   <div id="no-user-found"
-                        class="no-user-found"
-                        ng-show="searchUsers.searchUsersResults && searchUsers.searchUsersResults.length===0 && !searchUsers.searchUsersInProgress">
-                        No users found
-                   </div>
-            </div>
+                                               <div id="search-results" ng-show="UserSearchsIsNull===false"
+                                                       class="results-title"
+                                                       ng-bind="'Showing ' + searchUsers.searchUsersResults.length + ' results'"></div>
+                                               <div class="results-container" scroll-top="searchUsers.scrollApi">
+                                                       <div id="search-result-{{$index}}" class="user"
+                                                               ng-repeat="user in (searchUsers.searchUsersResults | orderBy:['firstName','lastName','orgUserId']) | limitTo: 100 track by $index"
+                                                               ng-click="searchUsers.setSelectedUser(user)"
+                                                               ng-class="{selected: user.orgUserId === searchUsers.selectedUser.orgUserId}">
+                                                               <div id="main-name-{{$index}}" class="main-name">
+                                                                       <span id="result-first-name-{{$index}}"
+                                                                               ng-bind="::user.firstName"></span> <span
+                                                                               id="result-last-name-{{$index}}" ng-bind="::user.lastName"></span>
+                                                                       <span id="result-uuid-{{$index}}" ng-bind="::user.orgUserId"></span>
+                                                               </div>
+                                                               <div id="job-title-{{$index}}" class="sub-job-title"
+                                                                       ng-bind="::user.jobTitle"></div>
+                                                               <br />
+                                                       </div>
+                                               </div>
+                                       </div>
+                               </div>
+
+                               <div class="error-text" id="user-search-error-403"
+                                       ng-show="UserSearchsIsNull===true">No match found.</div>
 
-            
-            <div id="addWidget" class="add-user-section" ng-show="searchUsers.showAddUser">
-                               <div>           
-                                       <div class="input-new-user-div" >
-                                                 <div  class="">*First Name</div>
-                                                 <input  type="text"  ng-model="searchUsers.newUser.firstName"/>                                                           
+                               <div id="no-user-found" class="no-user-found"
+                                       ng-show="searchUsers.searchUsersResults && searchUsers.searchUsersResults.length===0 && !searchUsers.searchUsersInProgress">
+                                       No users found</div>
+                       </div>
+
+
+                       <div id="addWidget" class="add-user-section"
+                               ng-show="searchUsers.showAddUser">
+                               <div>
+                                       <div class="input-new-user-div">
+                                               <div class="">*First Name</div>
+                                               <input type="text" ng-model="searchUsers.newUser.firstName" />
                                        </div>
-                                       <div class="input-new-user-div" >
-                                                 <div  class="">Middle Name</div>
-                                                 <input  type="text"  ng-model="searchUsers.newUser.middleName"/>                                                          
+                                       <div class="input-new-user-div">
+                                               <div class="">Middle Name</div>
+                                               <input type="text" ng-model="searchUsers.newUser.middleName" />
                                        </div>
-                                       <div class="input-new-user-div" >
-                                                 <div class="">*Last Name</div>
-                                                 <input  type="text" ng-model="searchUsers.newUser.lastName"/>
+                                       <div class="input-new-user-div">
+                                               <div class="">*Last Name</div>
+                                               <input type="text" ng-model="searchUsers.newUser.lastName" />
                                        </div>
-                                       <div class="input-new-user-div" >
-                                                 <div class="">*Email Address ID</div>
-                                                 <input  type="text" ng-model="searchUsers.newUser.emailAddress"/>
+                                       <div class="input-new-user-div">
+                                               <div class="">*Email Address ID</div>
+                                               <input type="text" ng-model="searchUsers.newUser.emailAddress" />
                                        </div>
-                                       <div class="input-new-user-div" >
-                                                 <div class="">*Login ID</div>
-                                                 <input  type="text" ng-model="searchUsers.newUser.loginId"/>
+                                       <div class="input-new-user-div">
+                                               <div class="">*Login ID</div>
+                                               <input type="text" ng-model="searchUsers.newUser.loginId" />
                                        </div>
-                                       <div class="input-new-user-div" >
-                                                 <div class="">*Login Password</div>
-                                                 <input  type="password" ng-model="searchUsers.newUser.loginPwd"    autocomplete="off"/>
+                                       <div class="input-new-user-div">
+                                               <div class="">*Login Password</div>
+                                               <input type="password" ng-model="searchUsers.newUser.loginPwd"
+                                                       autocomplete="off" />
                                        </div>
-                                       <div class="input-new-user-div" >
-                                                 <div class="">*Confirm Login Password</div>
-                                                 <input  type="password" ng-model="searchUsers.newUser.loginPwdCheck"  autocomplete="off"/>
+                                       <div class="input-new-user-div">
+                                               <div class="">*Confirm Login Password</div>
+                                               <input type="password"
+                                                       ng-model="searchUsers.newUser.loginPwdCheck" autocomplete="off" />
                                        </div>
-                               <div ng-show="searchUsers.newUser.loginPwdCheck.length>=searchUsers.newUser.loginPwd.length&&searchUsers.newUser.loginPwdCheck.length>0&&searchUsers.newUser.loginPwd!=searchUsers.newUser.loginPwdCheck"
+                                       <div
+                                               ng-show="searchUsers.newUser.loginPwdCheck.length>=searchUsers.newUser.loginPwd.length&&searchUsers.newUser.loginPwdCheck.length>0&&searchUsers.newUser.loginPwd!=searchUsers.newUser.loginPwdCheck"
                                                style="color: #cf2a2a; font-size: 12px;">
-                                               <small
-                                                       style="position: absolute; margin-top: -6px;">The passwords do not match. Try again.
-                                               </small>
-                   </div>
-                   <div ng-show="userExist==true"
+                                               <small style="position: absolute; margin-top: -6px;">The
+                                                       passwords do not match. Try again. </small>
+                                       </div>
+                                       <div ng-show="userExist==true"
                                                style="color: #cf2a2a; font-size: 12px;">
-                                               <small
-                                                       style="position: absolute; margin-top: -6px;">User with same loginId already exists. Try again.
-                                               </small>
-                   </div>
-                               </div>
-                <div class="add-new-user-btn">
-                       <button class="btn btn-alt btn-small" ng-click="searchUsers.addNewUserFun()">Add New User</button>
+                                               <small style="position: absolute; margin-top: -6px;">User
+                                                       with same loginId already exists. Try again. </small>
+                                       </div>
+                                       <div class="search-instructions">
+                                               <strong style="color: red">Note:</strong> Login ID should not
+                                               contain special characters except '@', '-', and '_'.
+                                       </div>
                                </div>
+                               <div class="add-new-user-btn">
+                                       <button class="btn btn-alt btn-small"
+                                               ng-click="searchUsers.addNewUserFun()">Add New User</button>
                                </div>
-                                                                                                                                               
+                       </div>
 
-                   </div>
-            
-        </div>
 
-    </form>
+               </div>
+</div>
+
+</form>
 </div>