summaryrefslogtreecommitdiffstats
path: root/response_test.go
diff options
context:
space:
mode:
authorclsr <clsr@clsr.net>2017-08-25 17:04:42 +0200
committerclsr <clsr@clsr.net>2017-08-25 17:04:44 +0200
commit9ca364d8753a5f2c7529c5b3dd7178bfd51effc6 (patch)
treedc5ab072ffbbd37da910d440e05b5bc56dc3f6da /response_test.go
parentba217ddeef9c6cd502a6f150bf59cf3ce329cc61 (diff)
downloadcnp-go-9ca364d8753a5f2c7529c5b3dd7178bfd51effc6.tar.gz
cnp-go-9ca364d8753a5f2c7529c5b3dd7178bfd51effc6.zip
Add support for the draft/cnp-select "select" request/response parameterv0.1.2
Diffstat (limited to 'response_test.go')
-rw-r--r--response_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/response_test.go b/response_test.go
index 8033335..97e810b 100644
--- a/response_test.go
+++ b/response_test.go
@@ -101,6 +101,10 @@ var (
{"error", Parameters{"reason": "syntax\n"}, nil, ErrorInvalid{}},
{"error", Parameters{"reason": " server_error"}, nil, ErrorInvalid{}},
{"error", Parameters{"reason": "invalid "}, nil, ErrorInvalid{}},
+ {"ok", Parameters{"select": "w"}, nil, ErrorInvalid{}},
+ {"ok", Parameters{"select": " "}, nil, ErrorInvalid{}},
+ {"ok", Parameters{"select": ":"}, nil, ErrorInvalid{}},
+ {"ok", Parameters{"select": ":foobar"}, nil, ErrorInvalid{}},
// invalid: redirect *requires* the location parameter
{"redirect", nil, nil, ErrorInvalid{}},
@@ -163,6 +167,11 @@ var (
{"redirect", Parameters{"location": "/bar"}, nil, nil},
{"redirect", Parameters{"location": "[::1]:12345/ foo\n\x01\xff/"}, nil, nil},
{"redirect", Parameters{"location": "/../../////././.."}, nil, nil},
+
+ {"ok", Parameters{"select": "\x00:\x00"}, nil, nil},
+ {"ok", Parameters{"select": "foo:bar:baz"}, nil, nil},
+ {"ok", Parameters{"select": "byte:5-"}, nil, nil},
+ {"ok", Parameters{"select": "cnm:#/foo/bar"}, nil, nil},
}
)
@@ -308,6 +317,20 @@ func TestResponseGetSet(t *testing.T) {
case "reason":
e(k, v, tst.v, resp.SetReason(v))
c(k, v, tst.v, resp.Reason())
+ case "select":
+ if tst.v != nil {
+ continue
+ }
+ sel := ""
+ ss := strings.SplitN(v, ":", 2)
+ if len(ss) == 2 {
+ resp.SetSelect(ss[0], ss[1])
+ a, b := resp.Select()
+ if a != "" {
+ sel = a + ":" + b
+ }
+ }
+ c(k, v, tst.v, sel)
default:
resp.SetParam(k, v)
c(k, v, tst.v, resp.Param(k))