central-api/golang/central-api_test.go

61 lines
1.0 KiB
Go
Raw Normal View History

2018-04-25 09:35:38 +00:00
package central_api
2018-04-06 10:16:19 +00:00
import (
2018-04-25 09:35:38 +00:00
"io/ioutil"
2018-04-06 10:16:19 +00:00
"testing"
2018-04-25 09:35:38 +00:00
2018-04-06 10:16:19 +00:00
"golang.org/x/net/context"
2018-04-25 09:35:38 +00:00
"google.golang.org/grpc"
2018-04-06 10:16:19 +00:00
)
func TestTarDis_saveAllTarget(t *testing.T) {
2018-04-25 09:35:38 +00:00
contents, _ := ioutil.ReadFile("../dh.json")
2018-04-06 10:16:19 +00:00
si := &ServerInput{}
si.Target = "TargetDiscoveryService"
si.Method = "saveAllTarget"
si.Params = append(si.Params, string(contents))
si.Params = append(si.Params, "{\"id\":1}")
callRPC(t, si)
}
func TestRPCNP_readAllByDomain(t *testing.T) {
si := &ServerInput{}
si.Target = "NoAuthProbeService"
si.Method = "readAllByDomain"
//sp := &ServerParam{}
//sp.IsCollection = false
//sp.Type = "com.loafle.overflow.module.domain.model.Domain"
//sp.Data = "{\"id\":1}"
2018-04-25 09:35:38 +00:00
si.Params = append(si.Params, "{\"id\":1}")
2018-04-06 10:16:19 +00:00
callRPC(t, si)
}
func callRPC(t *testing.T, si *ServerInput) {
conn, err := grpc.Dial(":50006", grpc.WithInsecure())
if err != nil {
t.Log(err)
}
client := NewOverflowApiServerClient(conn)
out, err := client.Exec(context.Background(), si)
if err != nil {
t.Fatal(err)
}
t.Log(out)
2018-04-25 09:35:38 +00:00
}