Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch: mocktr181 returns 520 for unsupported commands #195

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/wrphandlers/mocktr181/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ func (h Handler) HandleWrp(msg wrp.Message) error {

default:
// currently only get and set are implemented for existing mocktr181
statusCode = http.StatusOK
statusCode = 520
payloadResponse = []byte(fmt.Sprintf(`{"message": "command %s is not support"}`, command))
}

response := msg
Expand Down
15 changes: 15 additions & 0 deletions internal/wrphandlers/mocktr181/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ func TestHandler_HandleWrp(t *testing.T) {
a.Equal(int64(520), *msg.Status)
a.True(h.Enabled())

return nil
},
}, {
description: "unknown command",
egressCallCount: 1,
msg: wrp.Message{
Type: wrp.SimpleEventMessageType,
Source: "dns:tr1d1um.example.com/service/ignored",
Destination: "event:event_1/ignored",
Payload: []byte("{\"command\":\"FOOBAR\",\"parameters\":[{\"name\":\"Device.Bridging.MaxBridgeEntries\",\"dataType\":0,\"value\":\"anothername\",\"attributes\":{\"notify\":0}}]}"),
},
validate: func(a *assert.Assertions, msg wrp.Message, h *Handler) error {
a.Equal(int64(520), *msg.Status)
a.True(h.Enabled())

return nil
},
},
Expand Down
Loading