From 96e842decfcaf5b677dfff5dbc1bb284b33ad948 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Mon, 7 Aug 2023 20:44:56 -0600 Subject: [PATCH] Fixed some of the issues with GQL tests, still need to fix ACL --- gql.go | 6 +++--- gql_test.go | 11 ++++++----- lockable_test.go | 2 +- node.go | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gql.go b/gql.go index d57fe01..df9dde6 100644 --- a/gql.go +++ b/gql.go @@ -197,7 +197,7 @@ func NewResolveContext(ctx *Context, server *Node, gql_ext *GQLExt, r *http.Requ auth_uuid, err := uuid.FromBytes([]byte(id_bytes)) 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) @@ -1060,7 +1060,7 @@ func (ext *GQLExt) Process(ctx *Context, node *Node, msg Message) []Message { if signal.Type() == ErrorSignalType { // TODO: Forward to resolver if waiting for it sig := signal.(*ErrorSignal) - response_chan := ext.FreeResponseChannel(sig.UUID) + response_chan := ext.FreeResponseChannel(sig.ReqID) if response_chan != nil { select { case response_chan <- sig: @@ -1074,7 +1074,7 @@ func (ext *GQLExt) Process(ctx *Context, node *Node, msg Message) []Message { } } else if signal.Type() == ReadResultSignalType { sig := signal.(*ReadResultSignal) - response_chan := ext.FreeResponseChannel(sig.ID()) + response_chan := ext.FreeResponseChannel(sig.ReqID) if response_chan != nil { select { case response_chan <- sig: diff --git a/gql_test.go b/gql_test.go index 41df6ac..4cfae45 100644 --- a/gql_test.go +++ b/gql_test.go @@ -13,8 +13,8 @@ import ( "bytes" ) -func TestGQL(t *testing.T) { - ctx := logTestContext(t, []string{"gql", "lockable", "node_timeout", "listener"}) +func TestGQLServer(t *testing.T) { + ctx := logTestContext(t, []string{"gql", "lockable", "signal"}) TestNodeType := NodeType("TEST") err := ctx.RegisterNodeType(TestNodeType, []ExtType{LockableExtType}) @@ -68,7 +68,7 @@ func TestGQL(t *testing.T) { key_bytes, err := x509.MarshalPKCS8PrivateKey(n1.Key) 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) fatalErr(t, err) @@ -85,10 +85,11 @@ func TestGQL(t *testing.T) { ctx.Log.Logf("test", "RESP_2: %s", resp_2) stop_signal := StringSignal{NewBaseSignal(GQLStateSignalType, Direct), "stop_server"} - ctx.Send(n1.ID, []Message{{gql.ID, &stop_signal}}) - _, err = WaitForSignal(ctx, listener_ext, 100*time.Millisecond, GQLStateSignalType, func(sig *StringSignal) bool { + ctx.Send(gql.ID, []Message{{gql.ID, &stop_signal}}) + _, err = WaitForSignal(ctx, listener_ext, 100*time.Millisecond, StatusSignalType, func(sig *IDStringSignal) bool { return sig.Str == "server_stopped" }) + fatalErr(t, err) } func TestGQLDB(t *testing.T) { diff --git a/lockable_test.go b/lockable_test.go index 33d6bd9..c436176 100644 --- a/lockable_test.go +++ b/lockable_test.go @@ -98,7 +98,7 @@ func TestLink10K(t *testing.T) { } func TestLock(t *testing.T) { - ctx := lockableTestContext(t, []string{"lockable", "listener"}) + ctx := lockableTestContext(t, []string{}) NewLockable := func()(*Node, *ListenerExt) { listener := NewListenerExt(100) diff --git a/node.go b/node.go index b86134b..a6e4b34 100644 --- a/node.go +++ b/node.go @@ -256,7 +256,7 @@ func nodeLoop(ctx *Context, node *Node) error { err := node.Allows(KeyID(sig.Principal), sig.Signal.Permission()) if err != nil { 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 { // Unwrap the signal without changing the source msg = Message{msg.NodeID, sig.Signal}