Skip to content

Commit

Permalink
Fix nil pointer when checking for event authorizer (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
mthenw authored Jun 29, 2018
1 parent 0dd9f87 commit 24c3c35
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libkv/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
}
}
Expand Down
1 change: 1 addition & 0 deletions libkv/function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 24c3c35

Please sign in to comment.