email token duplication check
This commit is contained in:
		
							parent
							
								
									fb239e2249
								
							
						
					
					
						commit
						ee5f6ddd99
					
				@ -317,6 +317,23 @@ public class CentralInfraService implements InfraService {
 | 
			
		||||
    return infras;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public List<Infra> testRegistDiscoverd(Long probeID, List<Host> hosts, List<com.loafle.overflow.model.discovery.Service> services) throws OverflowException  {
 | 
			
		||||
 | 
			
		||||
    List<Infra> infras = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    if (null != hosts) {
 | 
			
		||||
      for (Host host : hosts) {
 | 
			
		||||
        infras.add(this.registByHost(probeID, host));
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    if (null != services) {
 | 
			
		||||
      for (com.loafle.overflow.model.discovery.Service service : services) {
 | 
			
		||||
        infras.add(this.registByService(probeID, service));
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return infras;
 | 
			
		||||
  }
 | 
			
		||||
  public InfraZone registInfraZoneByInfraHostIP(Long probeID, InfraHostIP infraHostIP) throws OverflowException {
 | 
			
		||||
    if (null == infraHostIP) {
 | 
			
		||||
      throw new OverflowException("InfraHostIP is not valid");
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,15 @@
 | 
			
		||||
package com.loafle.overflow.central.module.meta.dao;
 | 
			
		||||
 | 
			
		||||
import com.loafle.overflow.core.exception.OverflowException;
 | 
			
		||||
import com.loafle.overflow.model.meta.MetaCollectionItemMapping;
 | 
			
		||||
import org.springframework.data.jpa.repository.JpaRepository;
 | 
			
		||||
import org.springframework.stereotype.Repository;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Repository
 | 
			
		||||
public interface MetaCollectionItemMappingDAO extends JpaRepository<MetaCollectionItemMapping, Short> {
 | 
			
		||||
  List<MetaCollectionItemMapping> findAllByMetaDisplayItemMappingId(Long metaDisplayItemMappingID) throws OverflowException;
 | 
			
		||||
 | 
			
		||||
  List<MetaCollectionItemMapping> findAllByMetaCollectionItemId(Long metaCollectionItemID) throws OverflowException;
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,32 @@
 | 
			
		||||
package com.loafle.overflow.central.module.meta.service;
 | 
			
		||||
 | 
			
		||||
import com.loafle.overflow.central.module.meta.dao.MetaCollectionItemMappingDAO;
 | 
			
		||||
import com.loafle.overflow.core.exception.OverflowException;
 | 
			
		||||
import com.loafle.overflow.model.meta.MetaCollectionItemMapping;
 | 
			
		||||
import com.loafle.overflow.service.central.meta.MetaCollectionItemMappingService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Service("MetaCollectionItemMappingService")
 | 
			
		||||
public class CentralMetaCollectionItemMappingService implements MetaCollectionItemMappingService {
 | 
			
		||||
 | 
			
		||||
  @Autowired
 | 
			
		||||
  MetaCollectionItemMappingDAO metaCollectionItemMappingDAO;
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  public List<MetaCollectionItemMapping> readAll() throws OverflowException {
 | 
			
		||||
    return this.metaCollectionItemMappingDAO.findAll();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  public List<MetaCollectionItemMapping> readAllByMetaDisplayItemMappingID(Long metaDisplayItemMappingID) throws OverflowException {
 | 
			
		||||
    return this.metaCollectionItemMappingDAO.findAllByMetaDisplayItemMappingId(metaDisplayItemMappingID);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  public List<MetaCollectionItemMapping> readAllByMetaCollectionItemID(Long metaCollectionItemID) throws OverflowException {
 | 
			
		||||
    return this.metaCollectionItemMappingDAO.findAllByMetaCollectionItemId(metaCollectionItemID);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -12,6 +12,7 @@ import com.loafle.overflow.model.meta.MetaIPType;
 | 
			
		||||
import com.loafle.overflow.model.meta.MetaPortType;
 | 
			
		||||
import com.loafle.overflow.service.central.infra.InfraService;
 | 
			
		||||
import com.loafle.overflow.service.central.meta.MetaCryptoTypeService;
 | 
			
		||||
import org.junit.Ignore;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.junit.runner.RunWith;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
@ -26,11 +27,15 @@ import java.util.List;
 | 
			
		||||
@RunWith(SpringJUnit4ClassRunner.class)
 | 
			
		||||
@ActiveProfiles("test")
 | 
			
		||||
@ContextConfiguration(classes = { AppConfigTest.class })
 | 
			
		||||
@Ignore
 | 
			
		||||
public class CentralInfraServiceTest {
 | 
			
		||||
 | 
			
		||||
  @Autowired
 | 
			
		||||
  InfraService infraService;
 | 
			
		||||
 | 
			
		||||
  @Autowired
 | 
			
		||||
  CentralInfraService centralInfraService;
 | 
			
		||||
 | 
			
		||||
  @Autowired
 | 
			
		||||
  MetaCryptoTypeService metaCryptoTypeService;
 | 
			
		||||
 | 
			
		||||
@ -47,50 +52,49 @@ public class CentralInfraServiceTest {
 | 
			
		||||
    MetaCryptoType cryptoType = null;
 | 
			
		||||
 | 
			
		||||
    Zone zone = new Zone();
 | 
			
		||||
    zone.setAddress("192.168.10.101/24");
 | 
			
		||||
    zone.setAddress("192.168.1.103/24");
 | 
			
		||||
    zone.setDiscoveredDate(new Date());
 | 
			
		||||
    zone.setIface("enf03");
 | 
			
		||||
    zone.setMac("44:8a:5b:44:8c:e4");
 | 
			
		||||
    zone.setMetaIPType(MetaIPType.Enum.V4.to());
 | 
			
		||||
    zone.setNetwork("192.168.10.0/24");
 | 
			
		||||
    zone.setNetwork("192.168.1.0/24");
 | 
			
		||||
 | 
			
		||||
    // for (int i = 1; i < 6; i++) {
 | 
			
		||||
    host = new Host();
 | 
			
		||||
    host.setMetaIPType(MetaIPType.Enum.V4.to());
 | 
			
		||||
    host.getMetaIPType().setKey("V4");
 | 
			
		||||
    host.setAddress("192.168.10.12");
 | 
			
		||||
    host.setMac("44:8a:5b:44:8c:e7");
 | 
			
		||||
    host.setAddress("192.168.1.103");
 | 
			
		||||
    host.setMac("44:8a:5b:44:8c:e4");
 | 
			
		||||
    host.setDiscoveredDate(new Date());
 | 
			
		||||
    host.setZone(zone);
 | 
			
		||||
    for (int j = 24; j < 25; j++) {
 | 
			
		||||
//    for (int j = 22; j < 25; j++) {
 | 
			
		||||
      port = new Port();
 | 
			
		||||
      port.setDiscoveredDate(new Date());
 | 
			
		||||
      port.setHost(host);
 | 
			
		||||
      port.setMetaPortType(MetaPortType.Enum.TCP.to());
 | 
			
		||||
      port.setPortNumber(j);
 | 
			
		||||
      port.setPortNumber(22);
 | 
			
		||||
 | 
			
		||||
      for (int x = 24; x < 25; x++) {
 | 
			
		||||
//      for (int x = 24; x < 25; x++) {
 | 
			
		||||
        service = new Service();
 | 
			
		||||
        cryptoType = new MetaCryptoType();
 | 
			
		||||
        cryptoType.setKey("UNKNOWN");
 | 
			
		||||
        cryptoType.setId(Short.valueOf((short) 2));
 | 
			
		||||
        cryptoType.setName("Unknown");
 | 
			
		||||
        cryptoType.setKey("TLS");
 | 
			
		||||
        cryptoType.setId(Short.valueOf((short) 17));
 | 
			
		||||
        cryptoType.setName("TLS");
 | 
			
		||||
 | 
			
		||||
        service.setMetaCryptoType(cryptoType);
 | 
			
		||||
        service.setPort(port);
 | 
			
		||||
        service.setDiscoveredDate(new Date());
 | 
			
		||||
        service.setKey("Unknown");
 | 
			
		||||
        service.setKey("SSH");
 | 
			
		||||
        services.add(service);
 | 
			
		||||
      }
 | 
			
		||||
//      }
 | 
			
		||||
      port.setServiceList(services);
 | 
			
		||||
      ports.add(port);
 | 
			
		||||
    }
 | 
			
		||||
//    }
 | 
			
		||||
    host.setPortList(ports);
 | 
			
		||||
    hosts.add(host);
 | 
			
		||||
    // }
 | 
			
		||||
 | 
			
		||||
    // List<Infra> infras = this.infraService.registDiscoverd(Long.valueOf((long)1),
 | 
			
		||||
    // hosts, services);
 | 
			
		||||
     List<Infra> infras = this.centralInfraService.testRegistDiscoverd(Long.valueOf((long)1), hosts, services);
 | 
			
		||||
    // System.out.println("CentralInfraServiceTest Infra List Size: " +
 | 
			
		||||
    // infras.size());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user