Skip to content
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

migrate to maintained kuchiki fork for testing #2182

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ ignore = [

"RUSTSEC-2023-0018", # rustwide -> remove_dir_all,TOCTOU / Race Condition
# https://github.com/rust-lang/docs.rs/issues/2074

"RUSTSEC-2023-0019", # kuchiki is unmaintained
# https://github.com/rust-lang/docs.rs/issues/2076
]
informational_warnings = ["unmaintained"] # warn for categories of informational advisories
severity_threshold = "low" # CVSS severity ("none", "low", "medium", "high", "critical")
Expand Down
31 changes: 21 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ procfs = "0.15.1"

[dev-dependencies]
criterion = "0.5.1"
kuchiki = "0.8"
kuchikiki = "0.8"
rand = "0.8"
mockito = "1.0.2"
test-case = "3.0.0"
Expand Down
14 changes: 7 additions & 7 deletions src/web/build_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub(crate) async fn build_details_handler(
#[cfg(test)]
mod tests {
use crate::test::{wrapper, FakeBuild};
use kuchiki::traits::TendrilSink;
use kuchikiki::traits::TendrilSink;
use test_case::test_case;

#[test]
Expand All @@ -112,7 +112,7 @@ mod tests {
.db_build_log("A build log")])
.create()?;

let page = kuchiki::parse_html().one(
let page = kuchikiki::parse_html().one(
env.frontend()
.get("/crate/foo/0.1.0/builds")
.send()?
Expand All @@ -123,7 +123,7 @@ mod tests {
let attrs = node.attributes.borrow();
let url = attrs.get("href").unwrap();

let page = kuchiki::parse_html().one(env.frontend().get(url).send()?.text()?);
let page = kuchikiki::parse_html().one(env.frontend().get(url).send()?.text()?);

let log = page.select("pre").unwrap().next().unwrap().text_contents();

Expand All @@ -142,7 +142,7 @@ mod tests {
.builds(vec![FakeBuild::default().s3_build_log("A build log")])
.create()?;

let page = kuchiki::parse_html().one(
let page = kuchikiki::parse_html().one(
env.frontend()
.get("/crate/foo/0.1.0/builds")
.send()?
Expand All @@ -153,7 +153,7 @@ mod tests {
let attrs = node.attributes.borrow();
let url = attrs.get("href").unwrap();

let page = kuchiki::parse_html().one(env.frontend().get(url).send()?.text()?);
let page = kuchikiki::parse_html().one(env.frontend().get(url).send()?.text()?);

let log = page.select("pre").unwrap().next().unwrap().text_contents();

Expand All @@ -174,7 +174,7 @@ mod tests {
.db_build_log("Another build log")])
.create()?;

let page = kuchiki::parse_html().one(
let page = kuchikiki::parse_html().one(
env.frontend()
.get("/crate/foo/0.1.0/builds")
.send()?
Expand All @@ -185,7 +185,7 @@ mod tests {
let attrs = node.attributes.borrow();
let url = attrs.get("href").unwrap();

let page = kuchiki::parse_html().one(env.frontend().get(url).send()?.text()?);
let page = kuchikiki::parse_html().one(env.frontend().get(url).send()?.text()?);

let log = page.select("pre").unwrap().next().unwrap().text_contents();

Expand Down
6 changes: 3 additions & 3 deletions src/web/builds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ mod tests {
web::cache::CachePolicy,
};
use chrono::{DateTime, Duration, Utc};
use kuchiki::traits::TendrilSink;
use kuchikiki::traits::TendrilSink;
use reqwest::StatusCode;

#[test]
Expand All @@ -176,7 +176,7 @@ mod tests {

let response = env.frontend().get("/crate/foo/0.1.0/builds").send()?;
assert_cache_control(&response, CachePolicy::NoCaching, &env.config());
let page = kuchiki::parse_html().one(response.text()?);
let page = kuchikiki::parse_html().one(response.text()?);

let rows: Vec<_> = page
.select("ul > li a.release")
Expand Down Expand Up @@ -294,7 +294,7 @@ mod tests {
],
)?;

let page = kuchiki::parse_html().one(
let page = kuchikiki::parse_html().one(
env.frontend()
.get("/crate/foo/0.1.0/builds")
.send()?
Expand Down
16 changes: 8 additions & 8 deletions src/web/crate_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ mod tests {
assert_cache_control, assert_redirect, assert_redirect_cached, wrapper, TestDatabase,
};
use anyhow::{Context, Error};
use kuchiki::traits::TendrilSink;
use kuchikiki::traits::TendrilSink;
use std::collections::HashMap;

fn assert_last_successful_build_equals(
Expand Down Expand Up @@ -792,7 +792,7 @@ mod tests {
.binary(true)
.create()?;

let page = kuchiki::parse_html()
let page = kuchikiki::parse_html()
.one(env.frontend().get("/crate/binary/0.1.0").send()?.text()?);
let warning = page.select_first("a.pure-menu-link.warn").unwrap();

Expand Down Expand Up @@ -910,7 +910,7 @@ mod tests {
.features(HashMap::new())
.create()?;

let page = kuchiki::parse_html().one(
let page = kuchikiki::parse_html().one(
env.frontend()
.get("/crate/library/0.1.0/features")
.send()?
Expand All @@ -934,7 +934,7 @@ mod tests {
.features(features)
.create()?;

let page = kuchiki::parse_html().one(
let page = kuchikiki::parse_html().one(
env.frontend()
.get("/crate/library/0.1.0/features")
.send()?
Expand All @@ -958,7 +958,7 @@ mod tests {
.features(features)
.create()?;

let page = kuchiki::parse_html().one(
let page = kuchikiki::parse_html().one(
env.frontend()
.get("/crate/library/0.1.0/features")
.send()?
Expand Down Expand Up @@ -990,7 +990,7 @@ mod tests {
.features(features)
.create()?;

let page = kuchiki::parse_html().one(
let page = kuchikiki::parse_html().one(
env.frontend()
.get("/crate/library/0.1.0/features")
.send()?
Expand Down Expand Up @@ -1018,7 +1018,7 @@ mod tests {
.conn()
.query("UPDATE releases SET features = NULL WHERE id = $1", &[&id])?;

let page = kuchiki::parse_html().one(
let page = kuchikiki::parse_html().one(
env.frontend()
.get("/crate/library/0.1.0/features")
.send()?
Expand All @@ -1044,7 +1044,7 @@ mod tests {
let response = env.frontend().get("/crate/dummy/0.4.0").send()?;
assert!(response.status().is_success());

let platform_links: Vec<(String, String)> = kuchiki::parse_html()
let platform_links: Vec<(String, String)> = kuchikiki::parse_html()
.one(response.text()?)
.select(r#"a[aria-label="Platform"] + ul li a"#)
.expect("invalid selector")
Expand Down
15 changes: 8 additions & 7 deletions src/web/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ pub(crate) type AxumResult<T> = Result<T, AxumNope>;
#[cfg(test)]
mod tests {
use crate::test::wrapper;
use kuchiki::traits::TendrilSink;
use kuchikiki::traits::TendrilSink;

#[test]
fn check_404_page_content_crate() {
wrapper(|env| {
let page = kuchiki::parse_html().one(
let page = kuchikiki::parse_html().one(
env.frontend()
.get("/crate-which-doesnt-exist")
.send()?
Expand All @@ -164,7 +164,7 @@ mod tests {
#[test]
fn check_404_page_content_resource() {
wrapper(|env| {
let page = kuchiki::parse_html().one(
let page = kuchikiki::parse_html().one(
env.frontend()
.get("/resource-which-doesnt-exist.js")
.send()?
Expand All @@ -188,8 +188,8 @@ mod tests {
fn check_404_page_content_not_semver_version() {
wrapper(|env| {
env.fake_release().name("dummy").create()?;
let page =
kuchiki::parse_html().one(env.frontend().get("/dummy/not-semver").send()?.text()?);
let page = kuchikiki::parse_html()
.one(env.frontend().get("/dummy/not-semver").send()?.text()?);
assert_eq!(page.select("#crate-title").unwrap().count(), 1);
assert_eq!(
page.select("#crate-title")
Expand All @@ -208,7 +208,8 @@ mod tests {
fn check_404_page_content_nonexistent_version() {
wrapper(|env| {
env.fake_release().name("dummy").version("1.0.0").create()?;
let page = kuchiki::parse_html().one(env.frontend().get("/dummy/2.0").send()?.text()?);
let page =
kuchikiki::parse_html().one(env.frontend().get("/dummy/2.0").send()?.text()?);
assert_eq!(page.select("#crate-title").unwrap().count(), 1);
assert_eq!(
page.select("#crate-title")
Expand All @@ -231,7 +232,7 @@ mod tests {
.version("1.0.0")
.yanked(true)
.create()?;
let page = kuchiki::parse_html().one(env.frontend().get("/dummy/*").send()?.text()?);
let page = kuchikiki::parse_html().one(env.frontend().get("/dummy/*").send()?.text()?);
assert_eq!(page.select("#crate-title").unwrap().count(), 1);
assert_eq!(
page.select("#crate-title")
Expand Down
15 changes: 8 additions & 7 deletions src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ mod test {
use super::*;
use crate::{docbuilder::DocCoverage, test::*, web::match_version};
use axum::http::StatusCode;
use kuchiki::traits::TendrilSink;
use kuchikiki::traits::TendrilSink;
use serde_json::json;
use test_case::test_case;

Expand Down Expand Up @@ -618,7 +618,7 @@ mod test {

fn clipboard_is_present_for_path(path: &str, web: &TestFrontend) -> bool {
let data = web.get(path).send().unwrap().text().unwrap();
let node = kuchiki::parse_html().one(data);
let node = kuchikiki::parse_html().one(data);
node.select("#clipboard").unwrap().count() == 1
}

Expand Down Expand Up @@ -647,15 +647,16 @@ mod test {
.create()?;
let web = env.frontend();

let foo_crate = kuchiki::parse_html().one(web.get("/crate/foo/0.0.1").send()?.text()?);
let foo_crate =
kuchikiki::parse_html().one(web.get("/crate/foo/0.0.1").send()?.text()?);
for value in &["60%", "6", "10", "2", "1"] {
assert!(foo_crate
.select(".pure-menu-item b")
.unwrap()
.any(|e| dbg!(e.text_contents()).contains(value)));
}

let foo_doc = kuchiki::parse_html().one(web.get("/foo/0.0.1/foo").send()?.text()?);
let foo_doc = kuchikiki::parse_html().one(web.get("/foo/0.0.1/foo").send()?.text()?);
assert!(foo_doc
.select(".pure-menu-link b")
.unwrap()
Expand Down Expand Up @@ -834,7 +835,7 @@ mod test {
release("0.1.0", env);
let web = env.frontend();
let text = web.get("/foo/0.1.0/foo").send()?.text()?;
let platform = kuchiki::parse_html()
let platform = kuchikiki::parse_html()
.one(text)
.select(r#"ul > li > a[aria-label="Platform"]"#)
.unwrap()
Expand All @@ -848,7 +849,7 @@ mod test {
.add_platform("x86_64-unknown-linux-musl")
.create()?;
let text = web.get("/foo/0.2.0/foo").send()?.text()?;
let platform = kuchiki::parse_html()
let platform = kuchikiki::parse_html()
.one(text)
.select(r#"ul > li > a[aria-label="Platform"]"#)
.unwrap()
Expand Down Expand Up @@ -1028,7 +1029,7 @@ mod test {
release("0.1.0", env);
let web = env.frontend();
let text = web.get("/foo/0.1.0/foo").send()?.text()?;
let tabindex = kuchiki::parse_html()
let tabindex = kuchikiki::parse_html()
.one(text)
.select(r#"#nav-search[tabindex="-1"]"#)
.unwrap()
Expand Down
Loading
Loading