core-wg / href

Other
2 stars 0 forks source link

test vectors: initial commit #12

Closed thomas-fossati closed 2 years ago

thomas-fossati commented 2 years ago

@cabo @chrysn @marco-tiloca-sics @henkbirkholz please review & merge -- I don't have the commit bits on this repo.

cabo commented 2 years ago

I think it might help to have another field that tells us whether we expect normalization to change the "uri" into a normalized "uri-from-cri". E.g., at the moment that is true for:

 69:[:norm, "\"a/./b\"", "\"a/b\""]
 75:[:norm, "\"./a/b\"", "\"a/b\""]
 81:[:norm, "\"../a\"", "\"a\""]
 87:[:norm, "\"../a/b/../c/.\"", "\"a/c\""]

Note that the third and fourth example are missing the initial "../", which should survive a URI-ref➔CRI-ref➔URI-ref cycle.

cabo commented 2 years ago

And there are still 37 hosts not in an array:

37 matches for ":_CRI" in buffer: *Shell Command Output*
     17:[:_CRI_IN_OUT, "[null, \"a\"]", "[null, [\"a\"]]"]
     26:[:_CRI_IN_OUT, "[null, h'C0A80061']", "[null, [h'C0A80061']]"]
     99:[:_CRI_IN_OUT, "[\"a\", \"b\"]", "[\"a\", [\"b\"]]"]
    108:[:_CRI_IN_OUT, "[\"a\", h'C0A80062']", "[\"a\", [h'C0A80062']]"]
    147:[:_CRI_IN_OUT, "[null, \"a\"]", "[null, [\"a\"]]"]
    156:[:_CRI_IN_OUT, "[null, \"a\", [\"\"]]", "[null, [\"a\"], [\"\"]]"]
    165:[:_CRI_IN_OUT, "[null, \"a\", [\"b\"]]", "[null, [\"a\"], [\"b\"]]"]
    174:[:_CRI_IN_OUT, "[null, \"a\", null, [\"b\"]]", "[null, [\"a\"], null, [\"b\"]]"]
    183:[:_CRI_IN_OUT, "[null, \"a\", null, null, \"b\"]", "[null, [\"a\"], null, null, \"b\"]"]
    197:[:_CRI_IN_OUT, "[null, h'C0A80061', [\"\"]]", "[null, [h'C0A80061'], [\"\"]]"]
    206:[:_CRI_IN_OUT, "[null, h'C0A80061', [\"b\"]]", "[null, [h'C0A80061'], [\"b\"]]"]
    215:[:_CRI_IN_OUT, "[null, h'C0A80061', null, [\"b\"]]", "[null, [h'C0A80061'], null, [\"b\"]]"]
    224:[:_CRI_IN_OUT, "[null, h'C0A80061', null, null, \"b\"]", "[null, [h'C0A80061'], null, null, \"b\"]"]
    283:[:_CRI_IN_OUT, "[\"a\", \"b\", [\"\"]]", "[\"a\", [\"b\"], [\"\"]]"]
    292:[:_CRI_IN_OUT, "[\"a\", \"b\", [\"c\"]]", "[\"a\", [\"b\"], [\"c\"]]"]
    301:[:_CRI_IN_OUT, "[\"a\", \"b\", null, [\"c\"]]", "[\"a\", [\"b\"], null, [\"c\"]]"]
    310:[:_CRI_IN_OUT, "[\"a\", \"b\", null, null, \"c\"]", "[\"a\", [\"b\"], null, null, \"c\"]"]
    324:[:_CRI_IN_OUT, "[\"a\", h'C0A80062', [\"\"]]", "[\"a\", [h'C0A80062'], [\"\"]]"]
    333:[:_CRI_IN_OUT, "[\"a\", h'C0A80062', [\"c\"]]", "[\"a\", [h'C0A80062'], [\"c\"]]"]
    342:[:_CRI_IN_OUT, "[\"a\", h'C0A80062', null, [\"c\"]]", "[\"a\", [h'C0A80062'], null, [\"c\"]]"]
    351:[:_CRI_IN_OUT, "[\"a\", h'C0A80062', null, null, \"c\"]", "[\"a\", [h'C0A80062'], null, null, \"c\"]"]
    430:[:_CRI_IN_OUT, "[null, \"a\", [\"\"], [\"c\"]]", "[null, [\"a\"], [\"\"], [\"c\"]]"]
    439:[:_CRI_IN_OUT, "[null, \"a\", [\"\"], null, \"c\"]", "[null, [\"a\"], [\"\"], null, \"c\"]"]
    448:[:_CRI_IN_OUT, "[null, \"a\", [\"b\", \"\"]]", "[null, [\"a\"], [\"b\", \"\"]]"]
    457:[:_CRI_IN_OUT, "[null, \"a\", [\"b\", \"c\"]]", "[null, [\"a\"], [\"b\", \"c\"]]"]
    466:[:_CRI_IN_OUT, "[null, \"a\", [\"b\"], [\"c\"]]", "[null, [\"a\"], [\"b\"], [\"c\"]]"]
    475:[:_CRI_IN_OUT, "[null, \"a\", [\"b\"], null, \"c\"]", "[null, [\"a\"], [\"b\"], null, \"c\"]"]
    484:[:_CRI_IN_OUT, "[null, \"a\", null, [\"b\", \"c\"]]", "[null, [\"a\"], null, [\"b\", \"c\"]]"]
    493:[:_CRI_IN_OUT, "[null, \"a\", null, [\"b\"], \"c\"]", "[null, [\"a\"], null, [\"b\"], \"c\"]"]
    527:[:_CRI_IN_OUT, "[null, h'C0A80061', [\"\"], [\"c\"]]", "[null, [h'C0A80061'], [\"\"], [\"c\"]]"]
    536:[:_CRI_IN_OUT, "[null, h'C0A80061', [\"\"], null, \"c\"]", "[null, [h'C0A80061'], [\"\"], null, \"c\"]"]
    545:[:_CRI_IN_OUT, "[null, h'C0A80061', [\"b\", \"\"]]", "[null, [h'C0A80061'], [\"b\", \"\"]]"]
    554:[:_CRI_IN_OUT, "[null, h'C0A80061', [\"b\", \"c\"]]", "[null, [h'C0A80061'], [\"b\", \"c\"]]"]
    563:[:_CRI_IN_OUT, "[null, h'C0A80061', [\"b\"], [\"c\"]]", "[null, [h'C0A80061'], [\"b\"], [\"c\"]]"]
    572:[:_CRI_IN_OUT, "[null, h'C0A80061', [\"b\"], null, \"c\"]", "[null, [h'C0A80061'], [\"b\"], null, \"c\"]"]
    581:[:_CRI_IN_OUT, "[null, h'C0A80061', null, [\"b\", \"c\"]]", "[null, [h'C0A80061'], null, [\"b\", \"c\"]]"]
    590:[:_CRI_IN_OUT, "[null, h'C0A80061', null, [\"b\"], \"c\"]", "[null, [h'C0A80061'], null, [\"b\"], \"c\"]"]1
thomas-fossati commented 2 years ago

@cabo I am not sure where all these errors come from. I have extracted all the cris and resolved-cris from the test file:

# cri
jq '."test-vectors"[]."cri"' tests.json | sed -e 's/"//g' | while read l ; do echo $l | xxd -p -r | cbor2diag.rb ; done > cri.diag

# resolved-cri
jq '."test-vectors"[]."resolved-cri"' tests.json | sed -e 's/"//g' | while read l ; do echo $l | xxd -p -r | cbor2diag.rb ; done > resolved-cri.diag

and there's only one error I could find (i.e., the resolved-cri in the third entry):

jq '."test-vectors"[2]."resolved-cri"' tests.json | sed -e 's/"//g' | xxd -p -r | cbor2diag.rb
[-2, h'C0A80061']

all the rest looks OK.

cabo commented 2 years ago

Hmm. I found a bug in my test script; I now get different errors :-)

These are still there, anyway:

{"uri"=>"../a", "cri"=>"8202816161", "uri-from-cri"=>"a", "resolved-cri"=>"83218263666f6f191267816161", "resolved-uri"=>"coaps://foo:4711/a"}
["../a", "[2, [\"a\"]]", "a", "[-2, [\"foo\", 4711], [\"a\"]]", "coaps://foo:4711/a"]
["../a", [2, ["a"]], "a", [-2, ["foo", 4711], ["a"]], "coaps://foo:4711/a"]
[:norm, "\"../a\"", "\"a\""]
"[2, [\"a\"]]"

{"uri"=>"../a/b/../c/.", "cri"=>"82028261616163", "uri-from-cri"=>"a/c", "resolved-cri"=>"83218263666f6f1912678261616163", "resolved-uri"=>"coaps://foo:4711/a/c"}
["../a/b/../c/.", "[2, [\"a\", \"c\"]]", "a/c", "[-2, [\"foo\", 4711], [\"a\", \"c\"]]", "coaps://foo:4711/a/c"]
["../a/b/../c/.", [2, ["a", "c"]], "a/c", [-2, ["foo", 4711], ["a", "c"]], "coaps://foo:4711/a/c"]
[:norm, "\"../a/b/../c/.\"", "\"a/c\""]
"[2, [\"a\", \"c\"]]"

The uri and uri-from-cri entries differ, which is OK due to the normalization. However, [2, ["a", "c"]] should turn into ../a/c, not a/c.

I'll now try to diagnose the other errors.

cabo commented 2 years ago

Here is the other problem:

{"uri"=>"//a", "cri"=>"82f6816161", "uri-from-cri"=>"//a", "resolved-cri"=>"82f6816161", "resolved-uri"=>"coaps://a"}
["//a", "[null, [\"a\"]]", "//a", "[null, [\"a\"]]", "coaps://a"]
["//a", [nil, ["a"]], "//a", [nil, ["a"]], "coaps://a"]
"[null, [\"a\"]]"
[:_RES_IN_URI, "\"coaps://a\"", "\"//a\""]
[:_RES_CRI, "[null, [\"a\"]]", "[-2, [\"a\"]]"]
[:_RES_URI_CRI, "[-2, [\"a\"]]", "[null, [\"a\"]]"]

82f6816161 == [nil, ["a"]], which is not a good resolved-cri.

I find 25 places where resolved-cri is missing the URI scheme.

thomas-fossati commented 2 years ago

Here is the other problem:

{"uri"=>"//a", "cri"=>"82f6816161", "uri-from-cri"=>"//a", "resolved-cri"=>"82f6816161", "resolved-uri"=>"coaps://a"}
["//a", "[null, [\"a\"]]", "//a", "[null, [\"a\"]]", "coaps://a"]
["//a", [nil, ["a"]], "//a", [nil, ["a"]], "coaps://a"]
"[null, [\"a\"]]"
[:_RES_IN_URI, "\"coaps://a\"", "\"//a\""]
[:_RES_CRI, "[null, [\"a\"]]", "[-2, [\"a\"]]"]
[:_RES_URI_CRI, "[-2, [\"a\"]]", "[null, [\"a\"]]"]

82f6816161 == [nil, ["a"]], which is not a good resolved-cri.

I find 25 places where resolved-cri is missing the URI scheme.

This should be now fixed in 071103c

All the tests pass in my implementation. Please check yours :-)

cabo commented 2 years ago

Maybe I don't understand what the "resolved_cri" field is. I would have expected to see a CRI, not a CRI reference. A CRI should have a scheme. (Maybe what's in there is also useful as a separate field.)

For the 25 cases I don't understand, here's what they are in the test vectors (first on line), and then what I think they should be (second on line). Sorry for the quote noise.

"[null, [\"a\"]]", "[-2, [\"a\"]]"
"[null, [\"a\"], [\"\"]]", "[-2, [\"a\"], [\"\"]]"
"[null, [\"a\"], [\"b\"]]", "[-2, [\"a\"], [\"b\"]]"
"[null, [\"a\"], null, [\"b\"]]", "[-2, [\"a\"], null, [\"b\"]]"
"[null, [\"a\"], null, null, \"b\"]", "[-2, [\"a\"], null, null, \"b\"]"
"[null, [h'C0A80061'], [\"\"]]", "[-2, [h'C0A80061'], [\"\"]]"
"[null, [h'C0A80061'], [\"b\"]]", "[-2, [h'C0A80061'], [\"b\"]]"
"[null, [h'C0A80061'], null, [\"b\"]]", "[-2, [h'C0A80061'], null, [\"b\"]]"
"[null, [h'C0A80061'], null, null, \"b\"]", "[-2, [h'C0A80061'], null, null, \"b\"]"
"[null, [\"a\"], [\"\"], [\"c\"]]", "[-2, [\"a\"], [\"\"], [\"c\"]]"
"[null, [\"a\"], [\"\"], null, \"c\"]", "[-2, [\"a\"], [\"\"], null, \"c\"]"
"[null, [\"a\"], [\"b\", \"\"]]", "[-2, [\"a\"], [\"b\", \"\"]]"
"[null, [\"a\"], [\"b\", \"c\"]]", "[-2, [\"a\"], [\"b\", \"c\"]]"
"[null, [\"a\"], [\"b\"], [\"c\"]]", "[-2, [\"a\"], [\"b\"], [\"c\"]]"
"[null, [\"a\"], [\"b\"], null, \"c\"]", "[-2, [\"a\"], [\"b\"], null, \"c\"]"
"[null, [\"a\"], null, [\"b\", \"c\"]]", "[-2, [\"a\"], null, [\"b\", \"c\"]]"
"[null, [\"a\"], null, [\"b\"], \"c\"]", "[-2, [\"a\"], null, [\"b\"], \"c\"]"
"[null, [h'C0A80061'], [\"\"], [\"c\"]]", "[-2, [h'C0A80061'], [\"\"], [\"c\"]]"
"[null, [h'C0A80061'], [\"\"], null, \"c\"]", "[-2, [h'C0A80061'], [\"\"], null, \"c\"]"
"[null, [h'C0A80061'], [\"b\", \"\"]]", "[-2, [h'C0A80061'], [\"b\", \"\"]]"
"[null, [h'C0A80061'], [\"b\", \"c\"]]", "[-2, [h'C0A80061'], [\"b\", \"c\"]]"
"[null, [h'C0A80061'], [\"b\"], [\"c\"]]", "[-2, [h'C0A80061'], [\"b\"], [\"c\"]]"
"[null, [h'C0A80061'], [\"b\"], null, \"c\"]", "[-2, [h'C0A80061'], [\"b\"], null, \"c\"]"
"[null, [h'C0A80061'], null, [\"b\", \"c\"]]", "[-2, [h'C0A80061'], null, [\"b\", \"c\"]]"
"[null, [h'C0A80061'], null, [\"b\"], \"c\"]", "[-2, [h'C0A80061'], null, [\"b\"], \"c\"]"
thomas-fossati commented 2 years ago

Maybe I don't understand what the "resolved_cri" field is. I would have expected to see a CRI, not a CRI reference. A CRI should have a scheme. (Maybe what's in there is also useful as a separate field.)

For the 25 cases I don't understand, here's what they are in the test vectors (first on line), and then what I think they should be (second on line). Sorry for the quote noise. [...]

I am not sure we are looking at the same file?

If I run:

jq '."test-vectors"[]."resolved-cri"' tests.json | sed -e 's/"//g' | while read l ; do echo $l | xxd -p -r | cbor2diag.rb ; done

I get:

[-2, ["foo", 4711], ["pa", "th"], ["query"], "frag"]
[-2, ["a"]]
[-2, [h'C0A80061']]
[-2, ["foo", 4711], ["pa", "th"], ["query"], "frag"]
[-2, ["foo", 4711], [""]]
[-2, ["foo", 4711], ["a"]]
[-2, ["foo", 4711], ["pa", "th"], ["a"]]
[-2, ["foo", 4711], ["pa", "th"], ["query"], "a"]
[-2, ["foo", 4711], ["pa", "a"]]
[-2, ["foo", 4711], ["pa", "a", "b"]]
[-2, ["foo", 4711], ["pa", "a", "b"]]
[-2, ["foo", 4711], ["pa", "a", "b"]]
[-2, ["foo", 4711], ["a"]]
[-2, ["foo", 4711], ["a", "c"]]
[-2, ["foo", 4711], ["pa", "th"], ["query"], "frag"]
["a", ["b"]]
["a", [h'C0A80062']]
["a"]
["a", true, ["b"]]
["a", null, null, ["b"]]
["a", null, ["b"]]
["a", null, null, null, "b"]
[-2, ["a", 25186]]
[-2, ["a"], [""]]
[-2, ["a"], ["b"]]
[-2, ["a"], null, ["b"]]
[-2, ["a"], null, null, "b"]
[-2, [h'C0A80061', 25186]]
[-2, [h'C0A80061'], [""]]
[-2, [h'C0A80061'], ["b"]]
[-2, [h'C0A80061'], null, ["b"]]
[-2, [h'C0A80061'], null, null, "b"]
[-2, ["foo", 4711], ["pa", "th"], ["query"], "frag"]
[-2, ["foo", 4711], [""], ["b"]]
[-2, ["foo", 4711], [""], null, "b"]
[-2, ["foo", 4711], ["a", ""]]
[-2, ["foo", 4711], ["a", "b"]]
[-2, ["foo", 4711], ["a"], ["b"]]
[-2, ["foo", 4711], ["a"], null, "b"]
[-2, ["foo", 4711], ["pa", "th"], ["a", "b"]]
[-2, ["foo", 4711], ["pa", "th"], ["a"], "b"]
["a", ["b", 25443]]
["a", ["b"], [""]]
["a", ["b"], ["c"]]
["a", ["b"], null, ["c"]]
["a", ["b"], null, null, "c"]
["a", [h'C0A80062', 25443]]
["a", [h'C0A80062'], [""]]
["a", [h'C0A80062'], ["c"]]
["a", [h'C0A80062'], null, ["c"]]
["a", [h'C0A80062'], null, null, "c"]
[-2, ["foo", 4711], ["pa", "th"], ["query"], "frag"]
["a", null, null, ["c"]]
["a", null, null, null, "c"]
["a", true, ["b", ""]]
["a", true, ["b", "c"]]
["a", true, ["b?c"]]
["a", true, ["b"], null, "c"]
["a", null, null, ["b", "c"]]
["a", null, null, ["b"], "c"]
[-2, ["a", 25186], [""]]
[-2, ["a", 25186], ["c"]]
[-2, ["a", 25186], null, ["c"]]
[-2, ["a", 25186], null, null, "c"]
[-2, ["foo", 4711], ["pa", "th"], ["query"], "frag"]
[-2, ["a"], [""], ["c"]]
[-2, ["a"], [""], null, "c"]
[-2, ["a"], ["b", ""]]
[-2, ["a"], ["b", "c"]]
[-2, ["a"], ["b"], ["c"]]
[-2, ["a"], ["b"], null, "c"]
[-2, ["a"], null, ["b", "c"]]
[-2, ["a"], null, ["b"], "c"]
[-2, [h'C0A80061', 25186], [""]]
[-2, [h'C0A80061', 25186], ["c"]]
[-2, [h'C0A80061', 25186], null, ["c"]]
[-2, [h'C0A80061', 25186], null, null, "c"]
[-2, ["foo", 4711], ["pa", "th"], ["query"], "frag"]
[-2, [h'C0A80061'], [""], ["c"]]
[-2, [h'C0A80061'], [""], null, "c"]
[-2, [h'C0A80061'], ["b", ""]]
[-2, [h'C0A80061'], ["b", "c"]]
[-2, [h'C0A80061'], ["b"], ["c"]]
[-2, [h'C0A80061'], ["b"], null, "c"]
[-2, [h'C0A80061'], null, ["b", "c"]]
[-2, [h'C0A80061'], null, ["b"], "c"]
[-2, ["foo", 4711], ["pa", "th"], ["query"], "frag"]
[-2, ["foo", 4711], [""], ["b", "c"]]
[-2, ["foo", 4711], [""], ["b"], "c"]
[-2, ["foo", 4711], ["a", "", ""]]
[-2, ["foo", 4711], ["a", "", "c"]]
[-2, ["foo", 4711], ["a", ""], ["c"]]
[-2, ["foo", 4711], ["a", ""], null, "c"]
[-2, ["foo", 4711], ["a", "b", ""]]
[-2, ["foo", 4711], ["a", "b", "c"]]
[-2, ["foo", 4711], ["a", "b"], ["c"]]
[-2, ["foo", 4711], ["a", "b"], null, "c"]
[-2, ["foo", 4711], ["a"], ["b", "c"]]
[-2, ["foo", 4711], ["a"], ["b"], "c"]
[-2, ["foo", 4711], ["pa", "th"], ["a", "b", "c"]]