| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package handler
- import (
- "bytes"
- "log/slog"
- "testing"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/mock"
- "github.com/mk6i/retro-aim-server/wire"
- )
- func TestPermitDenyHandler_RightsQuery(t *testing.T) {
- input := wire.SNACMessage{
- Frame: wire.SNACFrame{
- FoodGroup: wire.PermitDeny,
- SubGroup: wire.PermitDenyRightsQuery,
- },
- Body: struct{}{},
- }
- output := wire.SNACMessage{
- Frame: wire.SNACFrame{
- FoodGroup: wire.PermitDeny,
- SubGroup: wire.PermitDenyRightsReply,
- },
- Body: wire.SNAC_0x09_0x03_PermitDenyRightsReply{
- TLVRestBlock: wire.TLVRestBlock{
- TLVList: wire.TLVList{
- wire.NewTLV(0x01, uint16(1000)),
- },
- },
- },
- }
- svc := newMockPermitDenyService(t)
- svc.EXPECT().
- RightsQuery(mock.Anything, input.Frame).
- Return(output)
- h := NewPermitDenyHandler(slog.Default(), svc)
- responseWriter := newMockResponseWriter(t)
- responseWriter.EXPECT().
- SendSNAC(output.Frame, output.Body).
- Return(nil)
- buf := &bytes.Buffer{}
- assert.NoError(t, wire.Marshal(input.Body, buf))
- assert.NoError(t, h.RightsQuery(nil, nil, input.Frame, buf, responseWriter))
- }
|