From ccad895c8bea47e483fb2c61d2684ca88c4290a1 Mon Sep 17 00:00:00 2001 From: Maciej Winnicki Date: Fri, 29 Jun 2018 15:25:57 +0200 Subject: [PATCH] Fix nil pointer when checking for event authorizer --- libkv/function.go | 2 +- libkv/function_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libkv/function.go b/libkv/function.go index 6a3483d..3ecf6b1 100644 --- a/libkv/function.go +++ b/libkv/function.go @@ -138,7 +138,7 @@ func (service Service) DeleteFunction(space string, id function.ID) error { return err } for _, eventType := range eventTypes { - if id == *eventType.AuthorizerID { + if eventType.AuthorizerID != nil && id == *eventType.AuthorizerID { return &function.ErrFunctionIsAuthorizer{ID: id, EventType: string(eventType.Name)} } } diff --git a/libkv/function_test.go b/libkv/function_test.go index 7068cc4..98c02cf 100644 --- a/libkv/function_test.go +++ b/libkv/function_test.go @@ -264,6 +264,7 @@ func TestDeleteFunction(t *testing.T) { t.Run("function is authorizer", func(t *testing.T) { kvs := []*store.KVPair{ + {Value: []byte(`{"name":"test.event.noauth"}`)}, {Value: []byte(`{"name":"test.event","authorizerId":"testid"}`)}} eventTypesDB := mock.NewMockStore(ctrl) eventTypesDB.EXPECT().List("default/", &store.ReadOptions{Consistent: true}).Return(kvs, nil)