diff --git a/src/main/java/com/loafle/overflow/module/apikey/model/ApiKey.java b/src/main/java/com/loafle/overflow/module/apikey/model/ApiKey.java index 4ada0c1..e1487ff 100644 --- a/src/main/java/com/loafle/overflow/module/apikey/model/ApiKey.java +++ b/src/main/java/com/loafle/overflow/module/apikey/model/ApiKey.java @@ -26,7 +26,7 @@ public class ApiKey { this.id = id; } - @Column(name = "API_KEY", nullable = false, length = 50) + @Column(name = "API_KEY", nullable = false, unique = true,length = 50) public String getApiKey() { return apiKey; } diff --git a/src/main/java/com/loafle/overflow/module/apikey/service/ApiKeyService.java b/src/main/java/com/loafle/overflow/module/apikey/service/ApiKeyService.java new file mode 100644 index 0000000..93d9d3c --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/apikey/service/ApiKeyService.java @@ -0,0 +1,35 @@ +package com.loafle.overflow.module.apikey.service; + +import com.loafle.overflow.module.apikey.dao.ApiKeyDAO; +import com.loafle.overflow.module.apikey.model.ApiKey; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * Created by snoop on 17. 6. 28. + */ +@Service +public class ApiKeyService { + + + @Autowired + private ApiKeyDAO apiKeyDAO; + + + public void regist(ApiKey apiKey) { + + this.apiKeyDAO.save(apiKey); + } + + public boolean check(String apiKey) { + + ApiKey retApiKey = this.apiKeyDAO.findByApiKey(apiKey); + + if(retApiKey == null) { + return false; + } + + return true; + } + +} diff --git a/src/test/java/com/loafle/overflow/module/apikey/service/ApiKeyServiceTest.java b/src/test/java/com/loafle/overflow/module/apikey/service/ApiKeyServiceTest.java new file mode 100644 index 0000000..fc01b92 --- /dev/null +++ b/src/test/java/com/loafle/overflow/module/apikey/service/ApiKeyServiceTest.java @@ -0,0 +1,60 @@ +package com.loafle.overflow.module.apikey.service; + +import com.loafle.overflow.module.apikey.model.ApiKey; +import com.loafle.overflow.module.domain.model.Domain; +import com.loafle.overflow.spring.AppConfig; +import com.loafle.overflow.spring.JdbcConfiguration; +import org.junit.Assert; +import org.junit.Ignore; +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; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 6. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) + +public class ApiKeyServiceTest { + + @Autowired + private ApiKeyService apiKeyService; + + @Ignore + @Test + public void regist() throws Exception { + + ApiKey apiKey = new ApiKey(); + + apiKey.setApiKey("70124b775bd511e7b059080027658d13"); + + Domain domain = new Domain(); + domain.setId(1); + + apiKey.setDomain(domain); + + this.apiKeyService.regist(apiKey); + + + Assert.assertNotEquals(apiKey.getId(), 0); + } + + @Ignore + @Test + public void check() throws Exception { + +// ApiKey apiKey = this.apiKeyDAO.findByApiKey("52abd6fd57e511e7ac52080027658d13"); + + regist(); + + boolean result= this.apiKeyService.check("70124b775bd511e7b059080027658d13"); + + Assert.assertNotEquals(result, false); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java b/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java index 37356eb..3ce3a74 100644 --- a/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java +++ b/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java @@ -30,7 +30,7 @@ public class MemberDAOTest { m.setName("insanity2"); m.setCompanyName("loafle"); m.setPw("bbbbbbbbb"); - m.setPwSalt("salktttt"); +// m.setPwSalt("salktttt"); m.setPhone("000-000-0000"); m.setEmail("insanity111@loafle.com"); m.setStatus(new MetaMemberStatus((short)1)); diff --git a/src/test/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeServiceTest.java b/src/test/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeServiceTest.java index d019524..4f53591 100644 --- a/src/test/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeServiceTest.java @@ -6,6 +6,7 @@ import com.loafle.overflow.module.noauthprobe.model.NoAuthProbe; import com.loafle.overflow.spring.AppConfig; import com.loafle.overflow.spring.JdbcConfiguration; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -26,6 +27,7 @@ public class NoAuthProbeServiceTest { @Autowired private NoAuthProbeService noAuthProbeService; + @Ignore @Test public void regist() throws Exception { @@ -53,6 +55,7 @@ public class NoAuthProbeServiceTest { } + @Ignore @Test public void readAllByDomain() throws Exception { @@ -65,6 +68,7 @@ public class NoAuthProbeServiceTest { } + @Ignore @Test public void read() throws Exception { diff --git a/src/test/java/com/loafle/overflow/module/probe/service/ProbeServiceTest.java b/src/test/java/com/loafle/overflow/module/probe/service/ProbeServiceTest.java index fd2f07a..9aa640d 100644 --- a/src/test/java/com/loafle/overflow/module/probe/service/ProbeServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/probe/service/ProbeServiceTest.java @@ -6,6 +6,7 @@ import com.loafle.overflow.module.probe.model.Probe; import com.loafle.overflow.spring.AppConfig; import com.loafle.overflow.spring.JdbcConfiguration; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -24,6 +25,7 @@ public class ProbeServiceTest { @Autowired private ProbeService probeService; + @Ignore @Test public void regist() throws Exception { @@ -50,10 +52,12 @@ public class ProbeServiceTest { Assert.assertNotEquals(probe.getId(), 0); } + @Ignore @Test public void readAllByDomain() throws Exception { } + @Ignore @Test public void readByProbeKey() throws Exception { } diff --git a/src/test/java/com/loafle/overflow/module/probe/service/ProbeTaskServiceTest.java b/src/test/java/com/loafle/overflow/module/probe/service/ProbeTaskServiceTest.java index 7e27885..a95636f 100644 --- a/src/test/java/com/loafle/overflow/module/probe/service/ProbeTaskServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/probe/service/ProbeTaskServiceTest.java @@ -6,6 +6,7 @@ import com.loafle.overflow.module.probe.model.ProbeTask; import com.loafle.overflow.spring.AppConfig; import com.loafle.overflow.spring.JdbcConfiguration; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -26,6 +27,7 @@ public class ProbeTaskServiceTest { @Autowired private ProbeTaskService probeTaskService; + @Ignore @Test public void regist() throws Exception { @@ -47,6 +49,7 @@ public class ProbeTaskServiceTest { Assert.assertNotEquals(probeTask.getId(), 0); } + @Ignore @Test public void readAllByProbe() throws Exception {