ing
This commit is contained in:
parent
1f35613c0c
commit
0e4db38e2c
|
@ -12,20 +12,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface NoAuthProbeDAO extends JpaRepository<NoAuthProbe, Long> {
|
public interface NoAuthProbeDAO extends JpaRepository<NoAuthProbe, Long> {
|
||||||
|
|
||||||
NoAuthProbe findByTempProbeKey(String tempProbeKey);
|
NoAuthProbe findByTempProbeKey(String tempProbeKey);
|
||||||
|
|
||||||
List<NoAuthProbe> findAllByDomainIdAndMetaNoAuthProbeStatusId(Long domainID, Short metaNoAuthProbeStatusId);
|
List<NoAuthProbe> findAllByDomainIdAndMetaNoAuthProbeStatusId(Long domainID, Short metaNoAuthProbeStatusId);
|
||||||
|
|
||||||
// NoAuthProbeDeprecate findByTempKey(NoAuthProbeDeprecate noAuthAgent);
|
|
||||||
// List<NoAuthProbeDeprecate> findAllByNoAuth(NoAuthProbeDeprecate noAuthAgent);
|
|
||||||
// @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey")
|
|
||||||
// @Query("select m from Member m WHERE m.email = :#{#m2.email}")
|
|
||||||
|
|
||||||
// @Modifying(clearAutomatically = true)
|
|
||||||
// @Query("UPDATE NoAuthProbe n set n.connectDate = :connectDate,
|
|
||||||
// n.connectAddress = :connectAddress where n.tempProbeKey = :tempProbeKey")
|
|
||||||
// int saveConnect(@Param("tempProbeKey") String tempProbeKey,
|
|
||||||
// @Param("connectDate") Date connectDate, @Param("connectAddress") String
|
|
||||||
// connectAddress);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.loafle.overflow.central.module.noauthprobe.dao;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.loafle.overflow.central.spring.AppConfigTest;
|
||||||
|
import com.loafle.overflow.model.meta.MetaNoAuthProbeStatus;
|
||||||
|
import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by snoop on 17. 9. 14.
|
||||||
|
*/
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@ContextConfiguration(classes = {AppConfigTest.class})
|
||||||
|
public class NoAuthProbeDAOTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private NoAuthProbeDAO noAuthProbeDAO;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void findByTempProbeKey() throws Exception {
|
||||||
|
|
||||||
|
NoAuthProbe noAuthProbe = this.noAuthProbeDAO.findByTempProbeKey("1cf2555c57d511e79714080027658d13");
|
||||||
|
|
||||||
|
assertNotNull(noAuthProbe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void findAllMemberByDomainId() throws Exception {
|
||||||
|
|
||||||
|
List<NoAuthProbe> noAuthProbes = this.noAuthProbeDAO.findAllByDomainIdAndMetaNoAuthProbeStatusId((long) 1, MetaNoAuthProbeStatus.Enum.PROCESSING.getValue());
|
||||||
|
|
||||||
|
assertNotNull(noAuthProbes);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,21 +1,15 @@
|
||||||
package com.loafle.overflow.central.module.noauthprobe.service;
|
package com.loafle.overflow.central.module.noauthprobe.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.commons.service.MessagePublisher;
|
|
||||||
import com.loafle.overflow.central.spring.AppConfigTest;
|
import com.loafle.overflow.central.spring.AppConfigTest;
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
|
||||||
import com.loafle.overflow.model.domain.Domain;
|
|
||||||
import com.loafle.overflow.model.meta.MetaNoAuthProbeStatus;
|
|
||||||
import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
|
import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,125 +22,56 @@ public class NoAuthProbeServiceTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CentralNoAuthProbeService noAuthProbeService;
|
private CentralNoAuthProbeService noAuthProbeService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MessagePublisher messagePublisher;
|
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void regist() throws Exception {
|
public void regist() throws Exception {
|
||||||
|
|
||||||
NoAuthProbe noAuthProbe = new NoAuthProbe();
|
NoAuthProbe noAuthProbe = new NoAuthProbe();
|
||||||
|
|
||||||
// noAuthProbe.setHostName("snoop");
|
noAuthProbe.setApiKey("52abd6fd57e511e7ac52080027658d13");
|
||||||
// noAuthProbe.setIpAddress(3232235980L);
|
|
||||||
// noAuthProbe.setMacAddress(8796753988883L);
|
|
||||||
noAuthProbe.setInfraHostMeta(
|
noAuthProbe.setInfraHostMeta(
|
||||||
"{\"host\":{\"name\":\"snoop-ubuntu\",\"os\":\"linux\",\"paltform\":\"ubuntu\",\"platformFamily\":\"debian\",\"platformVersion\":\"\",\"kernelVersion\":\"4.4.0-93-generic\",\"hostID\":\"DE60E4C3-347A-4D38-AEAB-1760471665EA\"},\"network\":{\"name\":\"enp3s0\",\"address\":\"192.168.1.106/24|fe80::36c0:6c3e:6006:dd23/64\",\"gateway\":\"192.168.1.254\",\"macAddress\":\"44:8a:5b:f1:f1:f3\"}}");
|
"{\"host\":{\"name\":\"snoop-ubuntu\",\"os\":\"linux\",\"paltform\":\"ubuntu\",\"platformFamily\":\"debian\",\"platformVersion\":\"\",\"kernelVersion\":\"4.4.0-93-generic\",\"hostID\":\"DE60E4C3-347A-4D38-AEAB-1760471665EA\"},\"network\":{\"name\":\"enp3s0\",\"address\":\"192.168.1.106/24|fe80::36c0:6c3e:6006:dd23/64\",\"gateway\":\"192.168.1.254\",\"macAddress\":\"44:8a:5b:f1:f1:f3\"}}");
|
||||||
|
|
||||||
noAuthProbe.setApiKey("52abd6fd57e511e7ac52080027658d13");
|
noAuthProbe = this.noAuthProbeService.regist(noAuthProbe);
|
||||||
|
|
||||||
MetaNoAuthProbeStatus metaNoAuthProbeStatus = new MetaNoAuthProbeStatus();
|
Assert.assertNotNull(noAuthProbe.getId());
|
||||||
metaNoAuthProbeStatus.setId((short) 3);
|
|
||||||
|
|
||||||
noAuthProbe.setMetaNoAuthProbeStatus(metaNoAuthProbeStatus);
|
|
||||||
noAuthProbe.setTempProbeKey("ac7f252b5bc811e784ad080027658d13");
|
|
||||||
|
|
||||||
Domain d = new Domain();
|
|
||||||
d.setId(Long.valueOf(1));
|
|
||||||
noAuthProbe.setDomain(d);
|
|
||||||
|
|
||||||
this.noAuthProbeService.regist(noAuthProbe);
|
|
||||||
|
|
||||||
Assert.assertNotEquals(noAuthProbe.getId().longValue(), 0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
|
||||||
public void registForNoAuthProbes() throws Exception {
|
|
||||||
|
|
||||||
NoAuthProbe noAuthProbe = new NoAuthProbe();
|
|
||||||
|
|
||||||
// noAuthProbe.setHostName("geek");
|
|
||||||
// noAuthProbe.setIpAddress(3232235980L);
|
|
||||||
// noAuthProbe.setMacAddress(8796753988883L);
|
|
||||||
noAuthProbe.setInfraHostMeta(
|
|
||||||
"{\"host\":{\"name\":\"geek-ubuntu\",\"os\":\"linux\",\"paltform\":\"ubuntu\",\"platformFamily\":\"debian\",\"platformVersion\":\"\",\"kernelVersion\":\"4.4.0-93-generic\",\"hostID\":\"03000200-0400-0500-0006-000700080009\"},\"network\":{\"name\":\"enp3s0\",\"address\":\"192.168.1.103/24|fe80::36c0:6c3e:6006:dd23/64\",\"gateway\":\"192.168.1.254\",\"macAddress\":\"44:8a:5b:f1:f1:f3\"}}");
|
|
||||||
noAuthProbe.setApiKey("521abd6fd57e511e7ac52080027658d13");
|
|
||||||
|
|
||||||
MetaNoAuthProbeStatus metaNoAuthProbeStatus = new MetaNoAuthProbeStatus();
|
|
||||||
metaNoAuthProbeStatus.setId((short) 3);
|
|
||||||
|
|
||||||
noAuthProbe.setMetaNoAuthProbeStatus(metaNoAuthProbeStatus);
|
|
||||||
noAuthProbe.setTempProbeKey("a1c7f252b5bc811e784ad080027658d13");
|
|
||||||
|
|
||||||
Domain d = new Domain();
|
|
||||||
d.setId(Long.valueOf(1));
|
|
||||||
noAuthProbe.setDomain(d);
|
|
||||||
|
|
||||||
List<NoAuthProbe> noAuthProbes = new ArrayList<NoAuthProbe>();
|
|
||||||
|
|
||||||
noAuthProbes.add(noAuthProbe);
|
|
||||||
// List<NoAuthProbe> dd =
|
|
||||||
// this.noAuthProbeService.registForNoAuthProbes(noAuthProbes);
|
|
||||||
|
|
||||||
// System.out.println(dd.get(0).getId());
|
|
||||||
|
|
||||||
Assert.assertNotEquals(noAuthProbes.size(), 2);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
|
||||||
public void readAllByDomainID() throws Exception {
|
|
||||||
List<NoAuthProbe> probes = this.noAuthProbeService.readAllByDomainID(Long.valueOf(1));
|
|
||||||
|
|
||||||
Assert.assertNotEquals(probes.size(), 0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
|
||||||
public void read() throws Exception {
|
|
||||||
NoAuthProbe noAuthProbe = this.noAuthProbeService.read(Long.valueOf(1));
|
|
||||||
|
|
||||||
Assert.assertNotEquals(noAuthProbe, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
|
||||||
public void acceptProbe() throws Exception {
|
|
||||||
|
|
||||||
this.noAuthProbeService.acceptNoAuthProbe(Long.valueOf(1), "192.168.1.0/24");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
|
||||||
public void ssss() {
|
|
||||||
String ss = "192.168.1.106/24|fe80::36c0:6c3e:6006:dd23/64";
|
|
||||||
|
|
||||||
String[] sss = ss.split("\\|");
|
|
||||||
|
|
||||||
System.out.println(sss[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readByTempKey() throws Exception {
|
public void readByTempProbeKey() throws Exception {
|
||||||
|
|
||||||
NoAuthProbe noAuthProbe = this.noAuthProbeService.readByTempProbeKey("1cf2555c57d511e79714080027658d15");
|
NoAuthProbe noAuthProbe = this.noAuthProbeService.readByTempProbeKey("1cf2555c57d511e79714080027658d15");
|
||||||
|
|
||||||
Assert.assertNotEquals(noAuthProbe, null);
|
Assert.assertNotNull(noAuthProbe);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
public void readAllByDomainID() throws Exception {
|
||||||
public void sendWeb() throws OverflowException {
|
List<NoAuthProbe> noAuthProbes = this.noAuthProbeService.readAllByDomainID((long) 1);
|
||||||
List<NoAuthProbe> probes = this.noAuthProbeService.readAllByDomainID(Long.valueOf(1));
|
|
||||||
|
|
||||||
messagePublisher.publishToDomainMembers(Long.valueOf(1), "NoAuthProbeService.regist", probes);
|
Assert.assertNotEquals(noAuthProbes.size(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void acceptNoAuthProbe() throws Exception {
|
||||||
|
List<NoAuthProbe> noAuthProbes = this.noAuthProbeService.acceptNoAuthProbe((long) 1, "192.168.1.0/24");
|
||||||
|
|
||||||
|
Assert.assertNotEquals(noAuthProbes.size(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void denyNoauthProbe() throws Exception {
|
||||||
|
List<NoAuthProbe> noAuthProbes = this.noAuthProbeService.denyNoauthProbe((long) 1);
|
||||||
|
|
||||||
|
Assert.assertNotEquals(noAuthProbes.size(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onConnect() throws Exception {
|
||||||
|
this.noAuthProbeService.onConnect("1cf2555c57d511e79714080027658d15", "192.168.1.101");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onDisconnect() throws Exception {
|
||||||
|
this.noAuthProbeService.onDisconnect("1cf2555c57d511e79714080027658d15");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user