-
Notifications
You must be signed in to change notification settings - Fork 172
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
fix(test-suite-data): Fix subpath tests #404
Conversation
The purls are valid as input, but the dots should be dropped from the canonical output. The test should list the canonical component for `subpath`, not the input component.
As background, https://github.com/package-url/packageurl-java currently compares all components in the canonical purl to the components in the test suite JSON file, and this is the only test that is currently failing that comparison. |
The spec is unclear here. I think this is due to confusing the input (when certain things are allowed) with canonical output (where certain things are now allowed). I know this based on how many times different implementations can't agree on things. Where the spec says "When percent-decoded", maybe it means "When canonicalized". Not allowed ("MUST NOT"): "When percent-decoded, a segment: - MUST NOT contain a '/' - MUST NOT be any of '..' or '.' - MUST NOT be empty" Yet, it apparently is allowed: "Discard empty, '.' and '..' segments" |
This change makes the two test pass that were introduced in package-url/purl-spec#368. See also package-url/purl-spec#404.
That is because the test is a non-intended one. one the test-suite was not built for. the purpose of the test suite: purl-spec/PURL-SPECIFICATION.rst Lines 473 to 485 in 65d98c4
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
altering the value of the component would drop one of the intended test scenarios:
it would no longer test for the correctness of the following process:
- building a
purl
from the test components should return the test canonicalpurl
as of
purl-spec/PURL-SPECIFICATION.rst
Lines 473 to 485 in 65d98c4
To test ``purl`` parsing and building, a tool can use this test suite and for | |
every listed test object, run these tests: | |
- parsing the test canonical ``purl`` then re-building a ``purl`` from these parsed | |
components should return the test canonical ``purl`` | |
- parsing the test ``purl`` should return the components parsed from the test | |
canonical ``purl`` | |
- parsing the test ``purl`` then re-building a ``purl`` from these parsed components | |
should return the test canonical ``purl`` | |
- building a ``purl`` from the test components should return the test canonical ``purl`` |
Therefore, the modification in this PR is undesired!
lets play this though: the test is: take all the given components, craft a PURL from them, and the result MUST BE the canonicalized purl. This all is intended to work with or without the ..
/.
in the components.
So if we have those ..
/.
in the components, we have a proper test whether the implementation drops those characters in accordance with the spec.
If you'd remove these characters from the test suite, there would be no case anymore.
Therefore, your change is removing a significant part of the test suite.
and therefore, your change is undesired.
and why would all these rule need modifications on the test suite components that are used for input only? PS: let me show whatthe test suite is actually meant for:
means:
means:
means:
means: |
All that is still the case in this pull request. The change is about something else entirely. The change is about what the components themselves are supposed to represent. Currently, it is the case for all other tests except this one that if
This one test changes this assumption by having If the fields can hold either the value of Then, you have to make the stipulation that implementation authors MUST NOT ever compare against the test fields directly. |
Currently, In either case The question is what |
Didi I get you right? you use: But what the purpose of the test suite is:
i see that the above is quite different. You are holding it wrong.
thats what Ive told you:
true. and it was also the case before you changed anything. your change is undesireable. |
I wonder whether the wording/phasing of the test-purpose is note nought, people seam to be confused. Maybe it can be improved? |
Please confirm that this code is wrong, then, since what it's testing cannot be assumed to be true However, you intend the test to be used this way However, this doesn't work for tests with
Well, I already tried to state the problem: there's nothing there about the meaning of |
this can be summarized as the following, right? |
I would summarize it as:
I cannot say about It doesn't appear to be "intended" based on what you said. But again, shouldn't I am referring to this case here purl-spec/test-suite-data.json Line 42 in 7f7e82f
That line has the canonical form, whereas this test has the relaxed form. |
but thats not what the code does.
please read purl-spec/PURL-SPECIFICATION.rst Lines 473 to 485 in 65d98c4
does this have anything todo with the topic of this pullrequest? nope. |
That is incorrect. It is like I said: it compares the canonical purl to the fields in the JSON. It does not look a the original string. That string is "lost" when the purl is created. |
The pull request changed the value of the components under the assumption that the components were supposed to be in the canonical form, based on that example. This pull request exposes an inconsistency in the test cases. Right now, it seems to me that the test author may just randomly choose any form to put for the field, which may or may not be related to the input string. I apologize if you still do not see the issue. As far as the pull request, you may close it if my assumption is incorrect, but I still wish for someone to define what the correct assumption should be. Thanks. |
To be more clear, the tests will currently fail on the golang example if comparing the non-canonical/original fields to the JSON fields, or the subpath example if comparing the canonical fields to the JSON fields. The simple answer may be that the fields can be anything and to never compare fields directly, but to only use them for composing the purl. But, then it's unclear what meaning, if any, should be assigned to those fields in any given example. |
Sorry, I just saw #409 after I posted comments to this issue. It does clear up the meaning of the fields now. It apparently also shows that the current Java code is making the wrong assumption. And since the Java implementation "loses" the original value of the fields, there's nothing to compare to. I guess it could just delete any field comparison code altogether and only use the fields for constructing. |
Exactly. So can we close this PR, then? |
This change makes the two test pass that were introduced in package-url/purl-spec#368. See also package-url/purl-spec#404.
Sure. |
The purls are valid as input, but the dots should be dropped from the canonical output.
The test should list the canonical component for
subpath
, not the input component.