Fixed some of the issues with GQL tests, still need to fix ACL

gql_cataclysm
noah metz 2023-08-07 20:44:56 -06:00
parent 8770d6f433
commit 96e842decf
4 changed files with 11 additions and 10 deletions

@ -197,7 +197,7 @@ func NewResolveContext(ctx *Context, server *Node, gql_ext *GQLExt, r *http.Requ
auth_uuid, err := uuid.FromBytes([]byte(id_bytes)) auth_uuid, err := uuid.FromBytes([]byte(id_bytes))
if err != nil { if err != nil {
return nil, fmt.Errorf("GQL_REQUEST_ERR: failed to parse ID from auth username") return nil, fmt.Errorf("GQL_REQUEST_ERR: failed to parse ID from auth username %+v", id_bytes)
} }
auth_id := NodeID(auth_uuid) auth_id := NodeID(auth_uuid)
@ -1060,7 +1060,7 @@ func (ext *GQLExt) Process(ctx *Context, node *Node, msg Message) []Message {
if signal.Type() == ErrorSignalType { if signal.Type() == ErrorSignalType {
// TODO: Forward to resolver if waiting for it // TODO: Forward to resolver if waiting for it
sig := signal.(*ErrorSignal) sig := signal.(*ErrorSignal)
response_chan := ext.FreeResponseChannel(sig.UUID) response_chan := ext.FreeResponseChannel(sig.ReqID)
if response_chan != nil { if response_chan != nil {
select { select {
case response_chan <- sig: case response_chan <- sig:
@ -1074,7 +1074,7 @@ func (ext *GQLExt) Process(ctx *Context, node *Node, msg Message) []Message {
} }
} else if signal.Type() == ReadResultSignalType { } else if signal.Type() == ReadResultSignalType {
sig := signal.(*ReadResultSignal) sig := signal.(*ReadResultSignal)
response_chan := ext.FreeResponseChannel(sig.ID()) response_chan := ext.FreeResponseChannel(sig.ReqID)
if response_chan != nil { if response_chan != nil {
select { select {
case response_chan <- sig: case response_chan <- sig:

@ -13,8 +13,8 @@ import (
"bytes" "bytes"
) )
func TestGQL(t *testing.T) { func TestGQLServer(t *testing.T) {
ctx := logTestContext(t, []string{"gql", "lockable", "node_timeout", "listener"}) ctx := logTestContext(t, []string{"gql", "lockable", "signal"})
TestNodeType := NodeType("TEST") TestNodeType := NodeType("TEST")
err := ctx.RegisterNodeType(TestNodeType, []ExtType{LockableExtType}) err := ctx.RegisterNodeType(TestNodeType, []ExtType{LockableExtType})
@ -68,7 +68,7 @@ func TestGQL(t *testing.T) {
key_bytes, err := x509.MarshalPKCS8PrivateKey(n1.Key) key_bytes, err := x509.MarshalPKCS8PrivateKey(n1.Key)
fatalErr(t, err) fatalErr(t, err)
req.SetBasicAuth(n1.ID.String(), string(key_bytes)) req.SetBasicAuth(string(n1.ID.Serialize()), string(key_bytes))
resp, err := client.Do(req) resp, err := client.Do(req)
fatalErr(t, err) fatalErr(t, err)
@ -85,10 +85,11 @@ func TestGQL(t *testing.T) {
ctx.Log.Logf("test", "RESP_2: %s", resp_2) ctx.Log.Logf("test", "RESP_2: %s", resp_2)
stop_signal := StringSignal{NewBaseSignal(GQLStateSignalType, Direct), "stop_server"} stop_signal := StringSignal{NewBaseSignal(GQLStateSignalType, Direct), "stop_server"}
ctx.Send(n1.ID, []Message{{gql.ID, &stop_signal}}) ctx.Send(gql.ID, []Message{{gql.ID, &stop_signal}})
_, err = WaitForSignal(ctx, listener_ext, 100*time.Millisecond, GQLStateSignalType, func(sig *StringSignal) bool { _, err = WaitForSignal(ctx, listener_ext, 100*time.Millisecond, StatusSignalType, func(sig *IDStringSignal) bool {
return sig.Str == "server_stopped" return sig.Str == "server_stopped"
}) })
fatalErr(t, err)
} }
func TestGQLDB(t *testing.T) { func TestGQLDB(t *testing.T) {

@ -98,7 +98,7 @@ func TestLink10K(t *testing.T) {
} }
func TestLock(t *testing.T) { func TestLock(t *testing.T) {
ctx := lockableTestContext(t, []string{"lockable", "listener"}) ctx := lockableTestContext(t, []string{})
NewLockable := func()(*Node, *ListenerExt) { NewLockable := func()(*Node, *ListenerExt) {
listener := NewListenerExt(100) listener := NewListenerExt(100)

@ -256,7 +256,7 @@ func nodeLoop(ctx *Context, node *Node) error {
err := node.Allows(KeyID(sig.Principal), sig.Signal.Permission()) err := node.Allows(KeyID(sig.Principal), sig.Signal.Permission())
if err != nil { if err != nil {
ctx.Log.Logf("signal", "AUTHORIZED_SIGNAL_POLICY_ERR: %s", err) ctx.Log.Logf("signal", "AUTHORIZED_SIGNAL_POLICY_ERR: %s", err)
ctx.Send(node.ID, []Message{Message{msg.NodeID, NewErrorSignal(sig.ID(), err.Error())}}) ctx.Send(node.ID, []Message{Message{msg.NodeID, NewErrorSignal(sig.Signal.ID(), err.Error())}})
} else { } else {
// Unwrap the signal without changing the source // Unwrap the signal without changing the source
msg = Message{msg.NodeID, sig.Signal} msg = Message{msg.NodeID, sig.Signal}