fmt
This commit is contained in:
parent
60d5ab3232
commit
f93fbeea2f
@ -1,12 +1,12 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"reflect"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"encoding/json"
|
||||
"github.com/golang/glog"
|
||||
"fmt"
|
||||
"github.com/golang/glog"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"git.loafle.net/overflow/overflow_service/proxy/member"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/target"
|
||||
@ -26,7 +26,6 @@ func TestServices(t *testing.T) {
|
||||
|
||||
va := reflect.ValueOf(meb).MethodByName("Regist").Call([]reflect.Value{})
|
||||
|
||||
|
||||
//reflect.ValueOf(meb).MethodByName("Read").Call(reflect.ValueOf(meb))
|
||||
|
||||
assert.Equal(t, 0, len(va))
|
||||
@ -42,7 +41,6 @@ func TestServiceParam(t *testing.T) {
|
||||
m["email"] = "geek@loafle.com"
|
||||
m["pw"] = "qwer5795"
|
||||
|
||||
|
||||
paramStr, err := json.Marshal(m)
|
||||
|
||||
if err != nil {
|
||||
@ -55,6 +53,7 @@ func TestServiceParam(t *testing.T) {
|
||||
|
||||
//assert.ObjectsAreEqual(proxy.MemberService{}, meb)
|
||||
}
|
||||
|
||||
//
|
||||
//type Member struct {
|
||||
// Email string `json:"email"`
|
||||
@ -110,7 +109,6 @@ func TestExecServices(t *testing.T) {
|
||||
//ms := reflect.New(reflect.ValueOf(ss.Param).Type()).Elem()
|
||||
//fmt.Printf("created a [%T]\n", reflect.ValueOf(ms).Type())
|
||||
|
||||
|
||||
//}
|
||||
|
||||
func TestConvertParamModel(t *testing.T) {
|
||||
@ -133,7 +131,7 @@ func TestParamTypeCreate(t *testing.T) {
|
||||
|
||||
method := reflect.ValueOf(ms).MethodByName("Regist")
|
||||
|
||||
var NewObj reflect.Value;
|
||||
var NewObj reflect.Value
|
||||
for i := 0; i < method.Type().NumIn(); i++ {
|
||||
tt := method.Type().In(i)
|
||||
|
||||
@ -144,7 +142,6 @@ func TestParamTypeCreate(t *testing.T) {
|
||||
NewObj = reflect.New(tt.Elem())
|
||||
}
|
||||
|
||||
|
||||
//obj = NewObj.Elem().Interface()
|
||||
|
||||
//intPtr := reflect.New(tt)
|
||||
@ -160,31 +157,25 @@ func TestParamTypeCreate(t *testing.T) {
|
||||
|
||||
params := make([]reflect.Value, method.Type().NumIn())
|
||||
|
||||
params[0] = NewObj;
|
||||
params[0] = NewObj
|
||||
|
||||
result := method.Call(params)[0].String()
|
||||
|
||||
t.Log(result)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
func TestListReflect(t *testing.T) {
|
||||
|
||||
res := "[{\"id\":1,\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL\",\"version\":\"9.5.0\",\"createDate\":1496631864025,\"member\":{\"id\":1,\"email\":\"ddddd@loafle.com\",\"pwSalt\":\"salktttt\",\"digest\":\"bbbbbbbbb\",\"name\":\"snnnnn\",\"company\":\"loafle\",\"phone\":\"000-000-0000\",\"authorizedDate\":null}},{\"id\":2,\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL\",\"version\":\"9.5.0\",\"createDate\":1496635285090,\"member\":{\"id\":1,\"email\":\"ddddd@loafle.com\",\"pwSalt\":\"salktttt\",\"digest\":\"bbbbbbbbb\",\"name\":\"snnnnn\",\"company\":\"loafle\",\"phone\":\"000-000-0000\",\"authorizedDate\":null}},{\"id\":3,\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL\",\"version\":\"9.5.0\",\"createDate\":1496642868260,\"member\":{\"id\":1,\"email\":\"ddddd@loafle.com\",\"pwSalt\":\"salktttt\",\"digest\":\"bbbbbbbbb\",\"name\":\"snnnnn\",\"company\":\"loafle\",\"phone\":\"000-000-0000\",\"authorizedDate\":null}},{\"id\":4,\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL\",\"version\":\"9.5.0\",\"createDate\":1496814093714,\"member\":{\"id\":1,\"email\":\"ddddd@loafle.com\",\"pwSalt\":\"salktttt\",\"digest\":\"bbbbbbbbb\",\"name\":\"snnnnn\",\"company\":\"loafle\",\"phone\":\"000-000-0000\",\"authorizedDate\":null}},{\"id\":5,\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL\",\"version\":\"9.5.0\",\"createDate\":1496814103052,\"member\":{\"id\":1,\"email\":\"ddddd@loafle.com\",\"pwSalt\":\"salktttt\",\"digest\":\"bbbbbbbbb\",\"name\":\"snnnnn\",\"company\":\"loafle\",\"phone\":\"000-000-0000\",\"authorizedDate\":null}},{\"id\":6,\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL\",\"version\":\"9.5.0\",\"createDate\":1496814184478,\"member\":{\"id\":1,\"email\":\"ddddd@loafle.com\",\"pwSalt\":\"salktttt\",\"digest\":\"bbbbbbbbb\",\"name\":\"snnnnn\",\"company\":\"loafle\",\"phone\":\"000-000-0000\",\"authorizedDate\":null}}]";
|
||||
res := "[{\"id\":1,\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL\",\"version\":\"9.5.0\",\"createDate\":1496631864025,\"member\":{\"id\":1,\"email\":\"ddddd@loafle.com\",\"pwSalt\":\"salktttt\",\"digest\":\"bbbbbbbbb\",\"name\":\"snnnnn\",\"company\":\"loafle\",\"phone\":\"000-000-0000\",\"authorizedDate\":null}},{\"id\":2,\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL\",\"version\":\"9.5.0\",\"createDate\":1496635285090,\"member\":{\"id\":1,\"email\":\"ddddd@loafle.com\",\"pwSalt\":\"salktttt\",\"digest\":\"bbbbbbbbb\",\"name\":\"snnnnn\",\"company\":\"loafle\",\"phone\":\"000-000-0000\",\"authorizedDate\":null}},{\"id\":3,\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL\",\"version\":\"9.5.0\",\"createDate\":1496642868260,\"member\":{\"id\":1,\"email\":\"ddddd@loafle.com\",\"pwSalt\":\"salktttt\",\"digest\":\"bbbbbbbbb\",\"name\":\"snnnnn\",\"company\":\"loafle\",\"phone\":\"000-000-0000\",\"authorizedDate\":null}},{\"id\":4,\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL\",\"version\":\"9.5.0\",\"createDate\":1496814093714,\"member\":{\"id\":1,\"email\":\"ddddd@loafle.com\",\"pwSalt\":\"salktttt\",\"digest\":\"bbbbbbbbb\",\"name\":\"snnnnn\",\"company\":\"loafle\",\"phone\":\"000-000-0000\",\"authorizedDate\":null}},{\"id\":5,\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL\",\"version\":\"9.5.0\",\"createDate\":1496814103052,\"member\":{\"id\":1,\"email\":\"ddddd@loafle.com\",\"pwSalt\":\"salktttt\",\"digest\":\"bbbbbbbbb\",\"name\":\"snnnnn\",\"company\":\"loafle\",\"phone\":\"000-000-0000\",\"authorizedDate\":null}},{\"id\":6,\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL\",\"version\":\"9.5.0\",\"createDate\":1496814184478,\"member\":{\"id\":1,\"email\":\"ddddd@loafle.com\",\"pwSalt\":\"salktttt\",\"digest\":\"bbbbbbbbb\",\"name\":\"snnnnn\",\"company\":\"loafle\",\"phone\":\"000-000-0000\",\"authorizedDate\":null}}]"
|
||||
|
||||
t.Log(res)
|
||||
|
||||
|
||||
ts := target.NewTargetService()
|
||||
|
||||
|
||||
method := reflect.ValueOf(ts).MethodByName("CreateList")
|
||||
|
||||
|
||||
var NewObj reflect.Value;
|
||||
var NewObj reflect.Value
|
||||
for i := 0; i < method.Type().NumIn(); i++ {
|
||||
tt := method.Type().In(i)
|
||||
|
||||
@ -208,14 +199,12 @@ func TestListReflect(t *testing.T) {
|
||||
|
||||
params := make([]reflect.Value, method.Type().NumIn())
|
||||
|
||||
params[0] = NewObj;
|
||||
params[0] = NewObj
|
||||
|
||||
result := method.Call(params)[0].String()
|
||||
|
||||
t.Log(result)
|
||||
|
||||
|
||||
//ts.cre
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,27 +1,26 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"golang.org/x/net/context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
pb "git.loafle.net/overflow/overflow_api_service/grpc"
|
||||
"github.com/golang/glog"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"errors"
|
||||
"golang.org/x/net/context"
|
||||
"log"
|
||||
"reflect"
|
||||
|
||||
"git.loafle.net/overflow/overflow_service/proxy/noauthprobe"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/target"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/member"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/crawler"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/crawlerInputItem"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/crawlerinputitemmapping"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/member"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/noauthprobe"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/probe"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/sensor"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/sensorItem"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/sensorItemCategory"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/sensorItemMapping"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/probe"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/target"
|
||||
//"google.golang.org/grpc/metadata"
|
||||
|
||||
)
|
||||
|
||||
var g_services map[string]interface{}
|
||||
@ -35,7 +34,7 @@ func AddServices(name string, s interface{}) {
|
||||
}
|
||||
|
||||
type Services interface {
|
||||
GetModel()(interface{})
|
||||
GetModel() interface{}
|
||||
}
|
||||
|
||||
func InitServices() {
|
||||
@ -56,8 +55,8 @@ func InitServices() {
|
||||
AddServices("SensorItemMapping", sensorItemMapping.NewSensorItemMappingService())
|
||||
|
||||
}
|
||||
type ServiceImpl struct {
|
||||
|
||||
type ServiceImpl struct {
|
||||
}
|
||||
|
||||
func (s *ServiceImpl) ExecServices(c context.Context, in *pb.ServiceInput) (*pb.ServiceOutput, error) {
|
||||
@ -71,12 +70,9 @@ func (s *ServiceImpl) ExecServices(c context.Context, in *pb.ServiceInput) (*pb.
|
||||
return nil, errors.New("Not Exist Service Name")
|
||||
}
|
||||
|
||||
|
||||
|
||||
pbs := &pb.ServiceOutput{}
|
||||
methodName := reflect.ValueOf(serviceName).MethodByName(in.MethodName)
|
||||
|
||||
|
||||
if methodName.IsValid() == false {
|
||||
return pbs, errors.New("Not Exist Method Name")
|
||||
}
|
||||
@ -96,11 +92,11 @@ func (s *ServiceImpl) ExecServices(c context.Context, in *pb.ServiceInput) (*pb.
|
||||
}
|
||||
|
||||
// Todo Call Service Method
|
||||
results := methodName.Call(params);
|
||||
results := methodName.Call(params)
|
||||
|
||||
result := results[0].Interface().(string)
|
||||
|
||||
var err error = nil;
|
||||
var err error = nil
|
||||
if len(result) > 1 {
|
||||
obj := results[1].Interface()
|
||||
if obj != nil {
|
||||
@ -110,7 +106,6 @@ func (s *ServiceImpl) ExecServices(c context.Context, in *pb.ServiceInput) (*pb.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pbs.ResultStr = result
|
||||
|
||||
return pbs, nil
|
||||
|
@ -2,11 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"github.com/golang/glog"
|
||||
"git.loafle.net/overflow/overflow_service/server"
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
defer glog.Flush()
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
)
|
||||
|
||||
type ApiKeyService struct {
|
||||
|
||||
}
|
||||
|
||||
type ApiKey struct {
|
||||
@ -19,15 +18,12 @@ type ApiKey struct {
|
||||
HostName string `json:"hostName,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
func NewApiKeyService() *ApiKeyService {
|
||||
return &ApiKeyService{}
|
||||
}
|
||||
|
||||
|
||||
func (k *ApiKeyService) SaveApikey(key *ApiKey) (string, error) {
|
||||
|
||||
|
||||
//bytes, err := json.Marshal(key)
|
||||
//
|
||||
//if err != nil {
|
||||
@ -80,5 +76,4 @@ func(k *ApiKeyService)CheckApikey(apikey string) (bool, error) {
|
||||
|
||||
return true, nil
|
||||
|
||||
|
||||
}
|
@ -1,3 +1 @@
|
||||
package apikey
|
||||
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package discovery
|
||||
|
||||
import (
|
||||
"git.loafle.net/overflow/overflow_service/proxy/probe"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
"encoding/json"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/probe"
|
||||
)
|
||||
|
||||
type Discovery struct {
|
||||
@ -15,16 +15,13 @@ type Discovery struct {
|
||||
Probe *probe.Probe `json:"probe,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
type DiscoveryService struct {
|
||||
|
||||
}
|
||||
|
||||
func NewDiscoveryService() *DiscoveryService {
|
||||
return &DiscoveryService{}
|
||||
}
|
||||
|
||||
|
||||
func (dis *DiscoveryService) Discovery(d *Discovery) (string, error) {
|
||||
|
||||
pts := probe.NewProbeTaskService()
|
||||
|
@ -1,8 +1,8 @@
|
||||
package discovery
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/probe"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDiscovery(t *testing.T) {
|
||||
@ -29,5 +29,4 @@ func TestDiscovery(t *testing.T) {
|
||||
|
||||
t.Log(out)
|
||||
|
||||
|
||||
}
|
||||
|
@ -12,16 +12,13 @@ type Domain struct {
|
||||
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
type DomainService struct {
|
||||
|
||||
}
|
||||
|
||||
func NewDomainService() *DomainService {
|
||||
return &DomainService{}
|
||||
}
|
||||
|
||||
|
||||
func (d *DomainService) Create(dm *Domain) (string, error) {
|
||||
|
||||
str, err := utils.InvokeDBByModel("domain", "save", dm, "com.loafle.overflow.module.domain.model.Domain")
|
||||
|
@ -8,7 +8,6 @@ func TestSave(t *testing.T) {
|
||||
|
||||
d.Name = "snoop's domain"
|
||||
|
||||
|
||||
str, err := NewDomainService().Create(&d)
|
||||
|
||||
if err != nil {
|
||||
|
@ -7,13 +7,13 @@ import (
|
||||
"git.loafle.net/overflow/commons_go/model/timestamp"
|
||||
"git.loafle.net/overflow/overflow_service/proxy"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/member"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/utils"
|
||||
"github.com/google/uuid"
|
||||
"log"
|
||||
"net"
|
||||
"net/mail"
|
||||
"net/smtp"
|
||||
"strings"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -168,7 +168,6 @@ func (es *EmailService) CheckAuthURL(e *Email) bool {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
tempEmail := &Email{}
|
||||
json.Unmarshal([]byte(re), tempEmail)
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package email
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/member"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func getEmailObj() (*Email, *EmailService) {
|
||||
|
@ -6,10 +6,8 @@ import (
|
||||
)
|
||||
|
||||
type KeyStoreService struct {
|
||||
|
||||
}
|
||||
|
||||
|
||||
func NewKeyStoreSerivce() *KeyStoreService {
|
||||
return &KeyStoreService{}
|
||||
}
|
||||
|
@ -2,17 +2,13 @@ package keystore
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
)
|
||||
|
||||
func TestGetKey(t *testing.T) {
|
||||
|
||||
|
||||
str, _ := NewKeyStoreSerivce().CreateKey()
|
||||
|
||||
|
||||
t.Log(str)
|
||||
t.Log(len(str))
|
||||
|
||||
|
||||
}
|
@ -6,8 +6,8 @@ import (
|
||||
"git.loafle.net/overflow/encryption_go"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/apikey"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/keystore"
|
||||
"log"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/utils"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Member struct {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package member
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"encoding/json"
|
||||
"github.com/golang/glog"
|
||||
"fmt"
|
||||
"github.com/golang/glog"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMemberService_Login(t *testing.T) {
|
||||
|
@ -9,6 +9,7 @@ const (
|
||||
PROBE_STATUS_INITIAL = 1
|
||||
PROBE_STATUS_NORMAL = 2
|
||||
)
|
||||
|
||||
var metaProbeStatusMap = map[int]string{
|
||||
1: "INITIAL",
|
||||
2: "NORMAL",
|
||||
@ -31,4 +32,3 @@ func NewMetaProbeStatus(types int) *MetaProbeStatus {
|
||||
Name: str,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,16 +6,14 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
|
||||
const (
|
||||
PROBE_TASK_TYPE_DISOCVERY = 1
|
||||
|
||||
)
|
||||
|
||||
var metaProbeTaskTypeMap = map[int]string{
|
||||
1: "DISOCVERY",
|
||||
}
|
||||
|
||||
|
||||
type MetaProbeTaskType struct {
|
||||
Id json.Number `json:"id,Number,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
|
@ -1,16 +1,15 @@
|
||||
package noauthprobe
|
||||
|
||||
import (
|
||||
|
||||
"git.loafle.net/overflow/commons_go/model/timestamp"
|
||||
|
||||
"encoding/json"
|
||||
|
||||
"git.loafle.net/overflow/overflow_service/proxy/probe"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/domain"
|
||||
"errors"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/utils"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/domain"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/probe"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/utils"
|
||||
)
|
||||
|
||||
type NoAuthProbeService struct {
|
||||
@ -20,7 +19,6 @@ func NewNoAuthProbeService() *NoAuthProbeService {
|
||||
return &NoAuthProbeService{}
|
||||
}
|
||||
|
||||
|
||||
type NoAuthProbe struct {
|
||||
Id json.Number `json:"id,Number,omitempty"`
|
||||
|
||||
@ -37,10 +35,8 @@ type NoAuthProbe struct {
|
||||
ApiKey string `json:"apiKey,omitempty"`
|
||||
Domain *domain.Domain `json:"domain,omitempty"`
|
||||
Probe *probe.Probe `json:"probe,omitempty"`
|
||||
|
||||
}
|
||||
|
||||
|
||||
func NewNoAuthProbe(apikey string, ipAddress int64, hostName string, md int64) *NoAuthProbe {
|
||||
|
||||
na := &NoAuthProbe{
|
||||
@ -54,7 +50,6 @@ func NewNoAuthProbe(apikey string, ipAddress int64, hostName string, md int64) *
|
||||
return na
|
||||
}
|
||||
|
||||
|
||||
func (as *NoAuthProbeService) Regist(na *NoAuthProbe) (string, error) {
|
||||
|
||||
out, err := utils.InvokeDBByModel("noauthProbe", "save", na, utils.MODEL_NOAUTHPROBE)
|
||||
@ -63,7 +58,7 @@ func(as *NoAuthProbeService)Regist(na *NoAuthProbe) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return out, nil;
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (as *NoAuthProbeService) CheckAuth(tempKey string) (string, error) {
|
||||
@ -95,23 +90,20 @@ func(as *NoAuthProbeService)CheckAuth(tempKey string) (string,error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return out,nil;
|
||||
return out, nil
|
||||
}
|
||||
|
||||
|
||||
func (as *NoAuthProbeService) ReadAllByDomain(d *domain.Domain) (string, error) {
|
||||
|
||||
out, err := utils.InvokeDBByModel("noauthProbe","findAllByDomain", d, utils.MODEL_DOMAIN);
|
||||
out, err := utils.InvokeDBByModel("noauthProbe", "findAllByDomain", d, utils.MODEL_DOMAIN)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return out,nil;
|
||||
return out, nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (as *NoAuthProbeService) RequestAuth(np *NoAuthProbe, domainId int, desc string) (string, error) {
|
||||
//paramMap := make(map[string]string)
|
||||
//noauthAgt.Status = "A"
|
||||
@ -123,7 +115,7 @@ func (as *NoAuthProbeService)RequestAuth(np *NoAuthProbe, domainId int, desc str
|
||||
//paramMap["com.loafle.overflow.noauthprobe.model.NoAuthProbe"] = string(bytes)
|
||||
//out, err := proxy.InvokeDB("noauthProbe", "update", paramMap)
|
||||
|
||||
out ,err := utils.InvokeDBByModel("noauthProbe","findByTempProbeKey", np.TempProbeKey, utils.MODEL_STRING);
|
||||
out, err := utils.InvokeDBByModel("noauthProbe", "findByTempProbeKey", np.TempProbeKey, utils.MODEL_STRING)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -133,12 +125,12 @@ func (as *NoAuthProbeService)RequestAuth(np *NoAuthProbe, domainId int, desc str
|
||||
}
|
||||
dbnp := NoAuthProbe{}
|
||||
|
||||
err = json.Unmarshal([]byte(out), &dbnp);
|
||||
err = json.Unmarshal([]byte(out), &dbnp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
dbnp.Status = np.Status;
|
||||
dbnp.Status = np.Status
|
||||
|
||||
//FIXME:: probe
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package noauthprobe
|
||||
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"testing"
|
||||
@ -10,7 +9,6 @@ import (
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
)
|
||||
|
||||
|
||||
func TestCreateUUid(t *testing.T) {
|
||||
|
||||
uu, err := uuid.NewUUID()
|
||||
@ -22,12 +20,12 @@ func TestCreateUUid(t *testing.T) {
|
||||
t.Log(uu)
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
func TestCreateNoAuthAgent(t *testing.T) {
|
||||
|
||||
na := NewNoAuthProbe("52abd6fd57e511e7ac52080027658d13", 3232235521, "Snoop2222", 8796753988883)
|
||||
|
||||
|
||||
ns := &meta.MetaNoAuthProbeStatus{}
|
||||
ns.Id = "3"
|
||||
na.Status = ns
|
||||
@ -49,6 +47,7 @@ func TestCreateNoAuthAgent(t *testing.T) {
|
||||
t.Log(out)
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
//func TestCheckAuthNoAuthAgent(t *testing.T) {
|
||||
//
|
||||
@ -69,10 +68,8 @@ func TestCreateNoAuthAgent(t *testing.T) {
|
||||
// //
|
||||
//}
|
||||
|
||||
|
||||
func TestNoAuthList(t *testing.T) {
|
||||
|
||||
|
||||
nas := NewNoAuthProbeService()
|
||||
|
||||
d := domain.Domain{}
|
||||
@ -87,6 +84,7 @@ func TestNoAuthList(t *testing.T) {
|
||||
t.Log(out)
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
//func TestRequestAuth(t *testing.T) {
|
||||
// nas := NewNoAuthProbeService()
|
||||
@ -102,10 +100,8 @@ func TestNoAuthList(t *testing.T) {
|
||||
// t.Log(newone)
|
||||
//}
|
||||
|
||||
|
||||
func TestCheckAuth(t *testing.T) {
|
||||
|
||||
|
||||
ns := NewNoAuthProbeService()
|
||||
|
||||
str, err := ns.CheckAuth("3398473-90847903874")
|
||||
@ -117,7 +113,6 @@ func TestCheckAuth(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
func TestRead(t *testing.T) {
|
||||
|
||||
out, err := NewNoAuthProbeService().Read("1")
|
||||
|
@ -7,9 +7,9 @@ import (
|
||||
|
||||
"git.loafle.net/overflow/overflow_service/proxy/utils"
|
||||
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
"git.loafle.net/overflow/commons_go/model/timestamp"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/domain"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
)
|
||||
|
||||
type ProbeService struct {
|
||||
@ -26,7 +26,6 @@ type Probe struct {
|
||||
EncryptionKey string `json:"encryptionKey,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
func NewProbeService() *ProbeService {
|
||||
return &ProbeService{}
|
||||
}
|
||||
@ -37,7 +36,6 @@ func NewProbe(probeKey string, encryptionKey string) *Probe {
|
||||
Status: meta.NewMetaProbeStatus(meta.PROBE_STATUS_INITIAL),
|
||||
ProbeKey: probeKey,
|
||||
EncryptionKey: encryptionKey,
|
||||
|
||||
}
|
||||
return na
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
package probe
|
||||
|
||||
import (
|
||||
|
||||
"testing"
|
||||
|
||||
"git.loafle.net/overflow/overflow_service/proxy/keystore"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/domain"
|
||||
|
||||
|
||||
"git.loafle.net/overflow/overflow_service/proxy/keystore"
|
||||
)
|
||||
|
||||
func TestSaveProbe(t *testing.T) {
|
||||
@ -32,7 +29,6 @@ func TestListProbe(t *testing.T) {
|
||||
|
||||
d := &domain.Domain{Id: "1"}
|
||||
|
||||
|
||||
if res, err := as.ReadAllByDomain(d); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
@ -55,7 +51,6 @@ func TestReadProbeKey(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
func TestDDDD(t *testing.T) {
|
||||
|
||||
}
|
@ -2,8 +2,8 @@ package probe
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
"git.loafle.net/overflow/commons_go/model/timestamp"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/utils"
|
||||
)
|
||||
|
||||
@ -30,7 +30,6 @@ func NewProbeTask(types *meta.MetaProbeTaskType, data string, p *Probe) *ProbeTa
|
||||
}
|
||||
|
||||
type ProbeTaskService struct {
|
||||
|
||||
}
|
||||
|
||||
func NewProbeTaskService() *ProbeTaskService {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package probe
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
@ -24,7 +24,6 @@ func TestCreate(t *testing.T) {
|
||||
t.Log(out)
|
||||
}
|
||||
|
||||
|
||||
func TestListByProbe(t *testing.T) {
|
||||
|
||||
p := &Probe{}
|
||||
@ -40,6 +39,4 @@ func TestListByProbe(t *testing.T) {
|
||||
|
||||
t.Log(out)
|
||||
|
||||
|
||||
|
||||
}
|
@ -2,11 +2,11 @@ package sensorItemMapping
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/sensor"
|
||||
"testing"
|
||||
"fmt"
|
||||
"sync"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/sensor"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSensorItemMappingService_List(t *testing.T) {
|
||||
@ -19,7 +19,6 @@ func TestSensorItemMappingService_List(t *testing.T) {
|
||||
t.Log(res)
|
||||
}
|
||||
|
||||
|
||||
func TestSensorItemMappingService_List_GoRutine(t *testing.T) {
|
||||
//s := &sensor.Sensor{}
|
||||
//s.Id = json.Number("14")
|
||||
@ -36,7 +35,6 @@ func TestSensorItemMappingService_List_GoRutine(t *testing.T) {
|
||||
|
||||
for _, ii := range il {
|
||||
|
||||
|
||||
go func(i int) {
|
||||
s := &sensor.Sensor{}
|
||||
s.Id = json.Number(strconv.Itoa(ii))
|
||||
@ -44,14 +42,12 @@ func TestSensorItemMappingService_List_GoRutine(t *testing.T) {
|
||||
fmt.Print(res)
|
||||
}(ii)
|
||||
|
||||
|
||||
}
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
|
||||
wg.Add(1)
|
||||
|
||||
|
||||
wg.Wait()
|
||||
|
||||
//res, _ := sims.List(s)
|
||||
|
@ -1,14 +1,12 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"log"
|
||||
pb "git.loafle.net/overflow/overflow_api_db/build/golang"
|
||||
"google.golang.org/grpc"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"log"
|
||||
)
|
||||
|
||||
|
||||
func InvokeDB(targetDb, methodName string, param map[string]string) (string, error) {
|
||||
|
||||
in := &pb.DBInput{}
|
||||
@ -34,4 +32,3 @@ func InvokeDB(targetDb, methodName string, param map[string]string) (string, err
|
||||
|
||||
return out.Result, nil
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import "git.loafle.net/overflow/overflow_service/proxy/member"
|
||||
func GetSessionMember() *member.Member {
|
||||
|
||||
m := member.NewMember()
|
||||
m.Id = "1";
|
||||
m.Id = "1"
|
||||
|
||||
return m;
|
||||
return m
|
||||
}
|
@ -8,7 +8,7 @@ import (
|
||||
// Deprecated: package rule changed...T__T
|
||||
func InvokeDB(db string, method string, obj interface{}) (string, error) {
|
||||
|
||||
var m map[string]string = nil;
|
||||
var m map[string]string = nil
|
||||
|
||||
if obj != nil {
|
||||
bytes, err := json.Marshal(obj)
|
||||
@ -21,7 +21,6 @@ func InvokeDB( db string, method string, obj interface{}) (string, error) {
|
||||
m[GenerateModelStr(db)] = string(bytes)
|
||||
}
|
||||
|
||||
|
||||
out, err := proxy.InvokeDB(db, method, m)
|
||||
|
||||
return out, err
|
||||
@ -40,6 +39,5 @@ func InvokeDBByModel( db string, method string, obj interface{}, model string) (
|
||||
|
||||
out, err := proxy.InvokeDB(db, method, m)
|
||||
|
||||
|
||||
return out, err
|
||||
}
|
@ -11,7 +11,6 @@ func GenerateModelStr(model string) string {
|
||||
|
||||
tm := strings.Title(model)
|
||||
|
||||
|
||||
res := defaultPackage
|
||||
res += model
|
||||
res += modelPackageName
|
||||
|
@ -1,8 +1,8 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStringUpper(t *testing.T) {
|
||||
@ -11,10 +11,8 @@ func TestStringUpper(t *testing.T) {
|
||||
|
||||
aa := strings.Title(res)
|
||||
|
||||
|
||||
t.Log(aa)
|
||||
|
||||
|
||||
}
|
||||
|
||||
func TestGM(t *testing.T) {
|
||||
@ -23,16 +21,14 @@ func TestGM(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
func TestNil(t *testing.T) {
|
||||
|
||||
var oo interface{}
|
||||
|
||||
oo = nil;
|
||||
oo = nil
|
||||
|
||||
if oo == nil {
|
||||
t.Log("nil!!!")
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,13 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"git.loafle.net/overflow/overflow_service/gateway"
|
||||
"flag"
|
||||
"github.com/golang/glog"
|
||||
"git.loafle.net/overflow/overflow_service/gateway"
|
||||
"git.loafle.net/overflow/overflow_service/server"
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
defer glog.Flush()
|
||||
|
@ -2,13 +2,13 @@ package server
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"golang.org/x/net/context"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"google.golang.org/grpc"
|
||||
pb "git.loafle.net/overflow/overflow_api_service/grpc"
|
||||
"github.com/golang/glog"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"net/http"
|
||||
"strings"
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -32,7 +32,6 @@ func RunGwRpc() (err error) {
|
||||
return http.ListenAndServe(":8080", allowCORS(mux))
|
||||
}
|
||||
|
||||
|
||||
//https://github.com/grpc-ecosystem/grpc-gateway/blob/master/examples/main.go
|
||||
|
||||
func allowCORS(h http.Handler) http.Handler {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net"
|
||||
"google.golang.org/grpc"
|
||||
pb "git.loafle.net/overflow/overflow_api_service/grpc"
|
||||
"git.loafle.net/overflow/overflow_service/gateway"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
)
|
||||
|
||||
func RunRpc() error {
|
||||
|
@ -1,20 +1,20 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"git.loafle.net/overflow/overflow_gateway_service/gateway"
|
||||
"flag"
|
||||
"github.com/golang/glog"
|
||||
"time"
|
||||
"fmt"
|
||||
"os"
|
||||
"net/http"
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
pb "git.loafle.net/overflow/overflow_api_service/grpc"
|
||||
"git.loafle.net/overflow/overflow_gateway_service/gateway"
|
||||
"github.com/golang/glog"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"google.golang.org/grpc"
|
||||
pb "git.loafle.net/overflow/overflow_api_service/grpc"
|
||||
"golang.org/x/net/context"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func startRpcServerTest() <-chan error {
|
||||
@ -80,7 +80,6 @@ func TestRpcServer(t *testing.T) {
|
||||
chStr <- callGatewayRpc()
|
||||
}()
|
||||
|
||||
|
||||
select {
|
||||
case err := <-errch:
|
||||
log.Println(err)
|
||||
@ -91,17 +90,14 @@ func TestRpcServer(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func TestRPC(t *testing.T) {
|
||||
|
||||
|
||||
conn, err := grpc.Dial(":9090", grpc.WithInsecure());
|
||||
conn, err := grpc.Dial(":9090", grpc.WithInsecure())
|
||||
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
}
|
||||
|
||||
|
||||
client := pb.NewOverflowGatewayClient(conn)
|
||||
|
||||
si := pb.ServiceInput{}
|
||||
@ -114,6 +110,4 @@ func TestRPC(t *testing.T) {
|
||||
|
||||
t.Log(so.ResultStr)
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user