summaryrefslogtreecommitdiff
path: root/crates/tor-netdoc
Commit message (Collapse)AuthorAgeFilesLines
...
* | tor-netdoc: Provide B16U for printing hex uppercaseIan Jackson2026-04-142-3/+32
| | | | | | | | | | | | | | Test the parsing and printing success cases. Given that the parsing implementation is just a wrapper around B16's, we don't need explicit tests for that.
* | tor-netdoc: Make B16 pub and improve its APIIan Jackson2026-04-142-15/+8
| | | | | | | | | | Make this a public BytesTransparent newtype like B64, implementing all the same traits etc.
* | tor-netdoc: impl Display for B16, as lowercaseIan Jackson2026-04-141-1/+16
| | | | | | | | | | | | | | | | On reflection, and looking at the test cases, I think the name `B16` should refer to the lowercase version. I'll introduce a type for uppercase in a moment. Test the display implementation.
* | tor-netdoc: Clean up base16 testIan Jackson2026-04-141-4/+11
| | | | | | | | | | | | | | Replace the open-coded .parse() calls with a closure. This will let us test round trips, other types, etc., for each pairs of test values.
* | tor-netdoc: Adjust API of B64Ian Jackson2026-04-142-2/+5
| | | | | | | | | | | | | | | | Firstly, make its field pub. Secondly, make the into_array method crate-private. It has a crate-specific (albeit public) error type, The same basic effect can be achieved with methods from std on arrays and slices.
* | tor-netdoc: Use BytesTransparent for FixedB64, and make it pubIan Jackson2026-04-142-9/+5
| | | | | | | | | | | | Make this type public. The new macro call means this type now implements many more traits.
* | tor-netdoc: impl many more traits for B64, by improving Bytes TransparentIan Jackson2026-04-142-1/+49
| | | | | | | | | | I think these are all the traits that a parsing/printing newtype adapter ought to implement.
* | tor-netdoc: types/misc.rs: Introduce BytesTransparent macro (finish macro)Ian Jackson2026-04-141-10/+14
| | | | | | | | | | | | | | Actually make the macro be a proper d-d macro. Replace uses of .0 with $fname, B64 with $ftype, etc. No functional change in this commit.
* | tor-netdoc: types/misc.rs: Introduce BytesTransparent macro (code motion)Ian Jackson2026-04-141-18/+50
| | | | | | | | | | | | | | | | | | | | | | Break various open-coded impls on B64 into this macro. That will let us reuse this code for other types, making all these bytes wrappers similar to each other. In this commit, we just move the code. The macro is wrong because it ought to refer to $ttype and so on. Review with git show --color-moved. No functional change in this commit.
* | tor-netdoc: Move a Hash deriveIan Jackson2026-04-141-2/+2
| | | | | | | | | | This is slightly more logical and will make the next commit slightly easier to read.
* | tor-netdoc: Move some imports to the top of types/misc.rsIan Jackson2026-04-141-3/+3
|/ | | | This will reduce some duplication and simplify some macrology.
* Merge branch 'contact-info' into 'main'Clara Engler2026-04-133-3/+100
|\ | | | | | | | | tor-netdoc: ContactInfo See merge request tpo/core/arti!3866
| * tor-netdoc: ContactInfo: Fix unused attributeIan Jackson2026-04-091-3/+1
| |
| * tor-netdoc: ContactInfo: Add some roundtrip testsIan Jackson2026-04-081-0/+30
| |
| * tor-netdoc: ContactInfo: Use FromStr impl for netdoc item parsingIan Jackson2026-04-081-5/+15
| |
| * tor-netdoc: ContactInfo: derive Display tooIan Jackson2026-04-081-1/+1
| |
| * tor-netdoc: ContactInfo: Impose a syntax restrictionIan Jackson2026-04-081-2/+41
| | | | | | | | | | | | | | Otherwise you might, for example, receive a String from a config file, JSON API submission, RPC call, or whatever, containing a newline, and then encode it into a netdoc giving a syntax error or, worse, smuggling additional items into the document!
| * tor-netdoc: ContactInfo: semver entryIan Jackson2026-04-081-0/+1
| |
| * tor-netdoc: ContactInfo: derive ItemValueEncodableIan Jackson2026-04-081-0/+1
| |
| * tor-netdoc: ContactInfo: Use d_d_adhoc technique to de-cfgIan Jackson2026-04-081-1/+3
| | | | | | | | Otherwise the cfg_attr for the field would need to name both features.
| * tor-netdoc: ContactInfo: Improve doc with an xref and item nameIan Jackson2026-04-081-1/+5
| |
| * tor-netdoc: Add ContactInfoClara Engler2026-04-082-1/+13
| |
* | Merge branch 'netdoc-test-fix' into 'main'Clara Engler2026-04-0849-2668/+2825
|\ \ | | | | | | | | | | | | Fix the testdata2 situation See merge request tpo/core/arti!3861
| * | tor-netdoc: Add manual happy families microdesc testClara Engler2026-04-081-0/+35
| | | | | | | | | | | | | | | | | | | | | This commit adds a manual test case for happy families in microdesc with parse2. Manual in the sense that we hardcode a microdescriptor taken from the wild here, as testdata2 does not contain them at the current moment, which is unfortunate but reported.
| * | tor-netdoc: Adjust family values for microdesc testClara Engler2026-04-081-12/+1
| | | | | | | | | | | | | | | This commit adjust the family value for the microdesc test to the one actually found in testdata2/.
| * | tor-netdoc: Update microdesc test EC keysClara Engler2026-04-081-9/+8
| | | | | | | | | | | | | | | | | | This commit updates the microdesc test EC keys with the new ones from testdata2/ while also changing the encoding from a byte array to the base64 value found in the microdesc itself.
| * | tor-netdoc: Update microdesc test onion keyClara Engler2026-04-081-5/+5
| | | | | | | | | | | | | | | This commit updates the microdesc onion key with the new one from testdata2.
| * | tor-netdoc: "Remove" assert_eq for mds[6]Clara Engler2026-04-081-40/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit removes the assert_eq for mds[6]. The reason for this was to have a test case with happy families set. However, these values were manually hacked into the respective file which is not the correct way. Instead, we will test this in a separate test that will be added later, as the current testdata2/ is not capable of this. This is an already reported chutney issue.
| * | tor-netdoc: No longer ignore microdesc parse2 testClara Engler2026-04-081-2/+0
| | |
| * | tor-netdoc: Remove dead authcert test codeClara Engler2026-04-081-29/+0
| | | | | | | | | | | | | | | This removes unused imports as well as the read_b64 and to_der helper functions which are all no longer used.
| * | tor-netdoc: Update dir_auth_cross_cert() test caseClara Engler2026-04-081-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit updates the dir_auth_cross_cert() test case with the new constants, replacing the longclaw ones. The replacement also involves a slight refactoring on the way how we obtain the encoded and decoded variable, namely because we have the data in a PEM encoded string now and no longer in separate file, making the use of read_b64 impossible.
| * | tor-netdoc: Update invalid outer signature test caseClara Engler2026-04-081-10/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit updates the invalid outer signature test case by copying the outer signature of the alternative certificate into our test object, which should obviously render this to a failure. It also updates the test vectors to the constant ones because it moves away from longclaw.
| * | tor-netdoc: Update the invalid cross-cert test caseClara Engler2026-04-081-10/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit updates the invalid cross-cert test case by copying the cross-cert from the alternative cert into our test object, resulting in a failure. Of course this also updates the other test vectors to use the constants declared above, as this moves away from longclaw.
| * | tor-netdoc: Update inconsistent fingerprint test caseClara Engler2026-04-081-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit updates the inconsistent fingerprint test case that tests whether the fingerprint matches with the identity RSA key. For this, we load the alternative authority cert and move its identity key into the identity key of the canonical cert. Of course, this also replaces the other test vectors that are now required for this change because it moves away from longclaw.
| * | tor-netdoc: Constify ALTERNATIVE_AUTHCERT_RAWClara Engler2026-04-081-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | This commit adds a new constant to the parse2 authcert unit tests, ALTERNATIVE_AUTHCERT_RAW, with the idea being to be different than AUTHCERT_RAW, which we will utilize in order to mix up cross-cert objects from one authcert with the one of another one in order to see it fail.
| * | tor-netdoc: Update "trivial" test cases in dir_auth_signature()Clara Engler2026-04-081-50/+20
| | | | | | | | | | | | | | | | | | | | | | | | This commit updates the "trivial" test cases in the dir_auth_signature unit tests, namely the ones concerning the outer signature as well as the timestamp tolerance. A follow-up commit will also update the more tricky ones, such as the ones testing inconsistent cross-certificates, etc.
| * | tor-netdoc: Constify VALID_SYSTEM_TIMEClara Engler2026-04-081-0/+5
| | | | | | | | | | | | | | | | | | This commit constifies VALID_SYSTEM_TIME, a timestamp indicating a point in time at which the certificate is valid. We will need this to test timestamp validation.
| * | tor-netdoc: Update test vectors in dir_auth_certClara Engler2026-04-081-15/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit replaces the longclaw test vectors in dir_auth_cert with the ones we constified previously and represent the ones found in testdata2/. It may look a bit odd that we replaced the file includes for the public keys but this is because those files should have never existed in testdata2/ in the first place and were only added by accident, meaning that the current approach is the correct one.
| * | tor-netdoc: Remove outdated longclaw comment in testClara Engler2026-04-081-2/+0
| | |
| * | tor-netdoc: Replace a File::open with include_strClara Engler2026-04-081-7/+2
| | | | | | | | | | | | | | | This commit replaces a File::open with the AUTHCERT_RAW constant in the dir_auth_cert test because that is obviously less error prone.
| * | tor-netdoc: Constify the raw authcert test vectorClara Engler2026-04-081-0/+1
| | | | | | | | | | | | | | | | | | | | | This commit adds `const AUTHCERT_RAW` which `include_str`'s the actual raw authcert we will use for parsing test purposes. The reason for that being that a single include_str! of the same file is obviously better than multiple ones.
| * | tor-netdoc: Constify the authcert test vectorsClara Engler2026-04-081-0/+41
| | | | | | | | | | | | | | | This commit constifies the authcert test vectors by extracting them from testdata2/keys/authority_certificate.
| * | tor-netdoc: Add to_rsa_id() helper functionClara Engler2026-04-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a to_rsa_id() helper function to the authcert tests in order to convert a hex-encoded RSA identity to an RsaIdentity. It will be required later on for converting the test vector values to the inner representations and this function is helpful here because it avoids us to do repetitive unwrapping and RsaIdentity::from_hex calls, which overall increase the length/readability.
| * | tor-netdoc: Add pem_to_rsa_pk helper functionClara Engler2026-04-081-0/+7
| | | | | | | | | | | | | | | | | | | | | This commit adds the pem_to_rsa_pk helper function to the authcert tests in order to convert a PEM encoded RSA public key to the internal data structure. It will be required later on in order to convert the test vector strings to internal representations.
| * | tor-netdoc: Add to_system_time helper functionClara Engler2026-04-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | This commit adds a to_system_time helper function accepting an &str in the Iso8601TimeSp format and converting it to a SystemTime to the authcert test cases. It will be required later on in order to conveniently convert human readable timestamps to the test vectors expected from parsed data.
| * | tor-netdoc: Fix broken poc testsClara Engler2026-04-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These tests got broken due to the replacement of the testdata. The changes required to make them work again were trivial, namely to increase a timestamp by two hours in a consensus, as the new consensus has a `valid-after 2000-01-01 00:02:20` followed by a fingerprint replacement for a directory authority because the authority identity keys were obviously also rotated.
| * | testdata2: Update with job 1468137Clara Engler2026-04-0745-2468/+2610
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This updates the testdata2 directory with job 1468137 using the following command: ./testdata2-download \ "https://gitlab.torproject.org/tpo/core/arti/-/jobs/1468137/artifacts/download" The artifact will expire at one point, so you may not be able to reproduce it anymore.
| * | testdata2: Patch lines starting with "@"Clara Engler2026-04-071-0/+13
| | | | | | | | | | | | | | | | | | | | | This commit patches so-called at-lines in cached-descriptors.new and cached-microdescs.new, as ctor adds those annotations manually in order to store metadata, which renders this to become an invalid network document.
| * | testdata: Embed testdata2/README update into scriptClara Engler2026-04-071-0/+5
| | | | | | | | | | | | | | | This commit embeds the message added in 509145592452a5aeca573af00579233 into the generated README.
| * | testdata2: Fix directory structure in zip archiveClara Engler2026-04-071-1/+2
| | | | | | | | | | | | | | | | | | The data resides in `shadow.chutney.data/hosts/host` now and not at the the top-level anymore. A fix might include to use wildcards, but I feel this is potentially more error-prone.