Skip to content

Commit

Permalink
migrate to maintained kuchiki fork for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
syphar committed Aug 3, 2023
1 parent 6c42373 commit c088458
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 67 deletions.
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 @@ -474,7 +474,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 @@ -838,7 +838,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 @@ -956,7 +956,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 @@ -980,7 +980,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 @@ -1004,7 +1004,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 @@ -1036,7 +1036,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 @@ -1064,7 +1064,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 @@ -1090,7 +1090,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

0 comments on commit c088458

Please sign in to comment.