From b359e32277a204ccdaf862e828d487e7753bdb3a Mon Sep 17 00:00:00 2001 From: Matthew Donoughe Date: Mon, 20 Nov 2023 11:19:47 -0500 Subject: [PATCH] use same test as package-url/purl-spec#273 --- purl_test/src/lib.rs | 14 +++++++------- .../src/generate_tests/phylum-test-suite-data.json | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/purl_test/src/lib.rs b/purl_test/src/lib.rs index 99847b1..c819ecd 100644 --- a/purl_test/src/lib.rs +++ b/purl_test/src/lib.rs @@ -1261,26 +1261,26 @@ fn plus_signs_and_spaces() { ); } #[test] -/// unsupported: percent signs -fn unsupported_percent_signs() { +/// unsupported: percent signs are properly encoded and decoded +fn unsupported_percent_signs_are_properly_encoded_and_decoded() { assert!( - matches!(Purl::from_str("pkg:generic/%40100%25/100%25@100%25?repository_url=https://example.com/100%2525/#100%25"), + matches!(Purl::from_str("pkg:generic/100%25/100%25@100%25?repository_url=https://example.com/100%2525/#100%25"), Err(PackageError::UnsupportedType)), "Type {} is not supported", "generic" ); let parsed = match GenericPurl::::from_str( - "pkg:generic/%40100%25/100%25@100%25?repository_url=https://example.com/100%2525/#100%25", + "pkg:generic/100%25/100%25@100%25?repository_url=https://example.com/100%2525/#100%25", ) { Ok(purl) => purl, Err(error) => { panic!( "Failed to parse valid purl {:?}: {}", - "pkg:generic/%40100%25/100%25@100%25?repository_url=https://example.com/100%2525/#100%25", + "pkg:generic/100%25/100%25@100%25?repository_url=https://example.com/100%2525/#100%25", error ) }, }; assert_eq!("generic", parsed.package_type(), "Incorrect package type"); - assert_eq!(Some("@100%"), parsed.namespace(), "Incorrect namespace"); + assert_eq!(Some("100%"), parsed.namespace(), "Incorrect namespace"); assert_eq!("100%", parsed.name(), "Incorrect name"); assert_eq!(Some("100%"), parsed.version(), "Incorrect version"); assert_eq!(Some("100%"), parsed.subpath(), "Incorrect subpath"); @@ -1291,7 +1291,7 @@ fn unsupported_percent_signs() { parsed.qualifiers().iter().map(|(k, v)| (k.as_str(), v)).collect::>() ); assert_eq!( - "pkg:generic/%40100%25/100%25@100%25?repository_url=https://example.com/100%2525/#100%25", + "pkg:generic/100%25/100%25@100%25?repository_url=https://example.com/100%2525/#100%25", &parsed.to_string(), "Incorrect string representation" ); diff --git a/xtask/src/generate_tests/phylum-test-suite-data.json b/xtask/src/generate_tests/phylum-test-suite-data.json index 2e931a0..8528201 100644 --- a/xtask/src/generate_tests/phylum-test-suite-data.json +++ b/xtask/src/generate_tests/phylum-test-suite-data.json @@ -122,11 +122,11 @@ "is_invalid": false }, { - "description": "percent signs", - "purl": "pkg:generic/%40100%25/100%25@100%25?repository_url=https://example.com/100%2525/#100%25", - "canonical_purl": "pkg:generic/%40100%25/100%25@100%25?repository_url=https://example.com/100%2525/#100%25", + "description": "percent signs are properly encoded and decoded", + "purl": "pkg:generic/100%25/100%25@100%25?repository_url=https://example.com/100%2525/#100%25", + "canonical_purl": "pkg:generic/100%25/100%25@100%25?repository_url=https://example.com/100%2525/#100%25", "type": "generic", - "namespace": "@100%", + "namespace": "100%", "name": "100%", "version": "100%", "qualifiers": {