2-add-keyword-support (#6)
More development. More types. Fixed attribute groups in requests. Started on client. Saving data to file. More types. Printing from chromeos works a little bit. More types. Spelling corrections. WIP: Fix keyword handling Move request to a separate file and add test. Co-authored-by: Henrik Sölver <henrik.solver@gmail.com> Reviewed-on: #6 Co-Authored-By: henrik <henrik.solver@gmail.com> Co-Committed-By: henrik <henrik.solver@gmail.com>
This commit was merged in pull request #6.
This commit is contained in:
79
packages/ipp/request_test.go
Normal file
79
packages/ipp/request_test.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package ipp
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var testRequest = []byte{0x01, 0x01, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x11,
|
||||
0x01,
|
||||
0x47,
|
||||
0x00, 0x12,
|
||||
0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x2d, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, 0x74,
|
||||
0x00, 0x05,
|
||||
0x75, 0x74, 0x66, 0x2d, 0x38,
|
||||
0x48,
|
||||
0x00, 0x1b,
|
||||
0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x2d, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x61, 0x6c, 0x2d, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65,
|
||||
0x00, 0x05,
|
||||
0x65, 0x6e, 0x2d, 0x75, 0x73,
|
||||
0x45, // uriValueTag
|
||||
0x00, 0x0b,
|
||||
0x70, 0x72, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x2d, 0x75, 0x72, 0x69,
|
||||
0x00, 0x20,
|
||||
0x69, 0x70, 0x70, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38, 0x2e, 0x30, 0x2e, 0x32, 0x3a, 0x31, 0x32, 0x33, 0x34, 0x2f, 0x69, 0x70, 0x70, 0x2f, 0x70, 0x72, 0x69, 0x6e, 0x74,
|
||||
0x44, // keywordValueTag
|
||||
0x00, 0x14,
|
||||
0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x65, 0x64, 0x2d, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73,
|
||||
0x00, 0x16,
|
||||
0x70, 0x72, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x2d, 0x6d, 0x61, 0x6b, 0x65, 0x2d, 0x61, 0x6e, 0x64, 0x2d, 0x6d, 0x6f, 0x64, 0x65, 0x6c,
|
||||
0x44, // keywordValueTag
|
||||
0x00, 0x00,
|
||||
0x00, 0x16,
|
||||
0x69, 0x70, 0x70, 0x2d, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2d, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64,
|
||||
0x44, // keywordValueTag
|
||||
0x00, 0x00,
|
||||
0x00, 0x16,
|
||||
0x69, 0x70, 0x70, 0x2d, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x2d, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64,
|
||||
0x44, // keywordValueTag
|
||||
0x00, 0x00,
|
||||
0x00, 0x19,
|
||||
0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2d, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2d, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64,
|
||||
0x44,
|
||||
0x00, 0x00,
|
||||
0x00, 0x0d,
|
||||
0x70, 0x72, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65,
|
||||
0x44,
|
||||
0x00, 0x00,
|
||||
0x00, 0x15,
|
||||
0x70, 0x72, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2d, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x73,
|
||||
0x44,
|
||||
0x00, 0x00,
|
||||
0x00, 0x15,
|
||||
0x70, 0x72, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
||||
0x03}
|
||||
|
||||
func TestUnmarshalRequestPrinterAttributes(T *testing.T) {
|
||||
buf := bytes.NewBuffer(testRequest)
|
||||
|
||||
req := NewRequest(GetPrinterAttributes, 17)
|
||||
|
||||
req.UnMarshal(buf)
|
||||
fmt.Print(req)
|
||||
assert.Equal(T, versionNumber(0x0101), req.header.versionNumber, "Wrong version number")
|
||||
assert.Equal(T, GetPrinterAttributes, req.header.operationId, "Wrong Operation")
|
||||
assert.Equal(T, uint32(17), req.header.requestId, "Wrong request id")
|
||||
assert.Len(T, req.operationAttributes, 4)
|
||||
v := req.operationAttributes["requested-attributes"].(*keyWord).sos.values
|
||||
assert.Len(T, v, 7)
|
||||
assert.Contains(T, v, "printer-make-and-model")
|
||||
assert.Contains(T, v, "ipp-versions-supported")
|
||||
assert.Contains(T, v, "ipp-features-supported")
|
||||
assert.Contains(T, v, "document-format-supported")
|
||||
assert.Contains(T, v, "printer-state-reasons")
|
||||
assert.Contains(T, v, "printer-state-message")
|
||||
assert.Contains(T, v, "printer-state")
|
||||
}
|
||||
Reference in New Issue
Block a user