-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create test group for issue with URL encoding (#8)
An issue was reported in rust-lang/crates.io#4891 related to how the `+` character is encoded in URLs. The issue was fixed by ensuring files are uploaded with consistent file names and by rewriting URLs with the wrong encoding in the Content Delivery Networks. The test group will request various URLs with different encoding from the CDNs to ensure they work correctly.
- Loading branch information
Showing
6 changed files
with
175 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//! Configuration to test rust-lang/crates.io#4891 | ||
use getset::Getters; | ||
|
||
use crate::environment::Environment; | ||
|
||
/// Configuration to test rust-lang/crates.io#4891 | ||
/// | ||
/// The smoke tests try to access a crate with a `+` character in its version on all the different | ||
/// Content Delivery Networks. The configuration provides a crate in the different environments that | ||
/// can be used for the tests as well as the URLs for the CDNs. | ||
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default, Getters)] | ||
pub struct Config { | ||
/// The name of the crate | ||
#[get(get = "pub")] | ||
krate: &'static str, | ||
|
||
/// The version with the `+` character | ||
#[get(get = "pub")] | ||
version: &'static str, | ||
|
||
/// The URL for the CloudFront CDN | ||
#[get(get = "pub")] | ||
cloudfront_url: &'static str, | ||
|
||
/// The URL for the Fastly CDN | ||
#[get(get = "pub")] | ||
fastly_url: &'static str, | ||
} | ||
|
||
impl Config { | ||
/// Return the configuration for the given environment | ||
pub fn for_env(env: Environment) -> Self { | ||
match env { | ||
Environment::Staging => Self { | ||
krate: "rust-cratesio-4891", | ||
version: "0.1.0+1", | ||
cloudfront_url: "https://cloudfront-static.staging.crates.io", | ||
fastly_url: "https://fastly-static.staging.crates.io", | ||
}, | ||
Environment::Production => Self { | ||
krate: "libgit2-sys", | ||
version: "0.12.25+1.3.0", | ||
cloudfront_url: "https://cloudfront-static.crates.io", | ||
fastly_url: "https://fastly-static.crates.io", | ||
}, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::test_utils::*; | ||
|
||
use super::*; | ||
|
||
#[test] | ||
fn trait_send() { | ||
assert_send::<Config>(); | ||
} | ||
|
||
#[test] | ||
fn trait_sync() { | ||
assert_sync::<Config>(); | ||
} | ||
|
||
#[test] | ||
fn trait_unpin() { | ||
assert_unpin::<Config>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
//! Encoded URLs with a + sign fail | ||
use std::fmt::{Display, Formatter}; | ||
|
||
use crate::environment::Environment; | ||
use crate::test::{TestGroup, TestGroupResult}; | ||
|
||
use self::config::Config; | ||
|
||
mod config; | ||
|
||
/// Encoded URLs with a + sign fail | ||
/// | ||
/// An issue was reported where requests that encoded the `+` character in the URL would receive an | ||
/// HTTP 403 Forbidden response. The cause for this issue was that the `+` character has a special | ||
/// meaning in S3, which was not considered when uploading crates in the past. The smoke tests | ||
/// ensure that the Content Delivery Networks correctly rewrite the URL to avoid this issue. | ||
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)] | ||
pub struct Issue4891 { | ||
/// Configuration for the test group | ||
config: Config, | ||
} | ||
|
||
impl Issue4891 { | ||
/// Create a new instance of the test group | ||
pub fn new(env: Environment) -> Self { | ||
Self { | ||
config: Config::for_env(env), | ||
} | ||
} | ||
} | ||
|
||
impl Display for Issue4891 { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "rust-lang/crates.io#4891") | ||
} | ||
} | ||
|
||
impl TestGroup for Issue4891 { | ||
async fn run(&self) -> TestGroupResult { | ||
todo!() | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use pretty_assertions::assert_eq; | ||
|
||
use crate::test_utils::*; | ||
|
||
use super::*; | ||
|
||
#[test] | ||
fn trait_display() { | ||
let issue_4891 = Issue4891::new(Environment::Staging); | ||
|
||
assert_eq!("rust-lang/crates.io#4891", issue_4891.to_string()); | ||
} | ||
|
||
#[test] | ||
fn trait_send() { | ||
assert_send::<Issue4891>(); | ||
} | ||
|
||
#[test] | ||
fn trait_sync() { | ||
assert_sync::<Issue4891>(); | ||
} | ||
|
||
#[test] | ||
fn trait_unpin() { | ||
assert_unpin::<Issue4891>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters