fn deny_list_works_during_recursion_with_inverted_parents() {
    let srv = MockServer::start();
    let urls = [
        "js".to_string(),
        "prod".to_string(),
        "dev".to_string(),
        "api".to_string(),
        "file.js".to_string(),
    ];
    let (tmp_dir, file) = setup_tmp_directory(&urls, "wordlist").unwrap();

    let js_mock = srv.mock(|when, then| {
        when.method(GET).path("/js");
        then.status(301).header("Location", &srv.url("/js/"));
    });

    let api_mock = srv.mock(|when, then| {
        when.method(GET).path("/api");
        then.status(200);
    });

    let js_prod_mock = srv.mock(|when, then| {
        when.method(GET).path("/js/prod");
        then.status(301).header("Location", &srv.url("/js/prod/"));
    });

    let js_dev_mock = srv.mock(|when, then| {
        when.method(GET).path("/js/dev");
        then.status(301).header("Location", &srv.url("/js/dev/"));
    });

    let js_dev_file_mock = srv.mock(|when, then| {
        when.method(GET).path("/js/dev/file.js");
        then.status(200)
            .body("this is a test and is more bytes than other ones");
    });

    let cmd = Command::cargo_bin("feroxbuster")
        .unwrap()
        .arg("--url")
        .arg(srv.url("/js"))
        .arg("--wordlist")
        .arg(file.as_os_str())
        .arg("-t")
        .arg("1")
        .arg("-vvvv")
        .arg("--dont-scan")
        .arg(srv.url("/"))
        .unwrap();

    cmd.assert().success().stdout(
        predicate::str::is_match("301.*js")
            .unwrap()
            .and(predicate::str::is_match("301.*js/prod").unwrap())
            .and(predicate::str::is_match("301.*js/dev").unwrap())
            .and(predicate::str::is_match("200.*js/dev/file.js").unwrap())
            .and(predicate::str::is_match("200.*api").unwrap())
            .not(),
    );

    assert_eq!(js_mock.hits(), 1);
    assert_eq!(js_prod_mock.hits(), 1);
    assert_eq!(js_dev_mock.hits(), 1);
    assert_eq!(js_dev_file_mock.hits(), 1);
    assert_eq!(api_mock.hits(), 0);

    teardown_tmp_directory(tmp_dir);
}
/// test that the deny list prevents requests of urls found during recursion when the denier is a
/// parent of a user-specified scan
test that the deny list prevents requests of urls found during recursion when the denier is a
parent of a user-specified scan
test that the deny list prevents requests of urls found during recursion when the denier is a parent of a user - specified scan
fn deny_list_works_during_recursion_with_inverted_parents() {
    let srv = MockServer::start();
    let urls = [
        "js".to_string(),
        "prod".to_string(),
        "dev".to_string(),
        "api".to_string(),
        "file.js".to_string(),
    ];
    let (tmp_dir, file) = setup_tmp_directory(&urls, "wordlist").unwrap();
    let js_mock = srv.mock(|when, then| {
        when.method(GET).path("/js");
        then.status(301).header("Location", &srv.url("/js/"));
    });
    let api_mock = srv.mock(|when, then| {
        when.method(GET).path("/api");
        then.status(200);
    });
    let js_prod_mock = srv.mock(|when, then| {
        when.method(GET).path("/js/prod");
        then.status(301).header("Location", &srv.url("/js/prod/"));
    });
    let js_dev_mock = srv.mock(|when, then| {
        when.method(GET).path("/js/dev");
        then.status(301).header("Location", &srv.url("/js/dev/"));
    });
    let js_dev_file_mock = srv.mock(|when, then| {
        when.method(GET).path("/js/dev/file.js");
        then.status(200)
            .body("this is a test and is more bytes than other ones");
    });
    let cmd = Command::cargo_bin("feroxbuster")
        .unwrap()
        .arg("--url")
        .arg(srv.url("/js"))
        .arg("--wordlist")
        .arg(file.as_os_str())
        .arg("-t")
        .arg("1")
        .arg("-vvvv")
        .arg("--dont-scan")
        .arg(srv.url("/"))
        .unwrap();
    cmd.assert().success().stdout(
        predicate::str::is_match("301.*js")
            .unwrap()
            .and(predicate::str::is_match("301.*js/prod").unwrap())
            .and(predicate::str::is_match("301.*js/dev").unwrap())
            .and(predicate::str::is_match("200.*js/dev/file.js").unwrap())
            .and(predicate::str::is_match("200.*api").unwrap())
            .not(),
    );
    assert_eq!(js_mock.hits(), 1);
    assert_eq!(js_prod_mock.hits(), 1);
    assert_eq!(js_dev_mock.hits(), 1);
    assert_eq!(js_dev_file_mock.hits(), 1);
    assert_eq!(api_mock.hits(), 0);
    teardown_tmp_directory(tmp_dir);
}
fn deny_list_works_during_recursion_with_inverted_parents ( ) { let srv = MockServer :: start ( ) ; let urls = [ " " . to_string ( ) , " " . to_string ( ) , " " . to_string ( ) , " " . to_string ( ) , " " . to_string ( ) , ] ; let ( tmp_dir , file ) = setup_tmp_directory ( & urls , " " ) . unwrap ( ) ; let js_mock = srv . mock ( | when , then | { when . method ( GET ) . path ( " " ) ; then . status ( 301 ) . header ( " " , & srv . url ( " " ) ) ; } ) ; let api_mock = srv . mock ( | when , then | { when . method ( GET ) . path ( " " ) ; then . status ( 200 ) ; } ) ; let js_prod_mock = srv . mock ( | when , then | { when . method ( GET ) . path ( " " ) ; then . status ( 301 ) . header ( " " , & srv . url ( " " ) ) ; } ) ; let js_dev_mock = srv . mock ( | when , then | { when . method ( GET ) . path ( " " ) ; then . status ( 301 ) . header ( " " , & srv . url ( " " ) ) ; } ) ; let js_dev_file_mock = srv . mock ( | when , then | { when . method ( GET ) . path ( " " ) ; then . status ( 200 ) . body ( " " ) ; } ) ; let cmd = Command :: cargo_bin ( " " ) . unwrap ( ) . arg ( " " ) . arg ( srv . url ( " " ) ) . arg ( " " ) . arg ( file . as_os_str ( ) ) . arg ( " " ) . arg ( " " ) . arg ( " " ) . arg ( " " ) . arg ( srv . url ( " " ) ) . unwrap ( ) ; cmd . assert ( ) . success ( ) . stdout ( predicate :: str :: is_match ( " " ) . unwrap ( ) . and ( predicate :: str :: is_match ( " " ) . unwrap ( ) ) . and ( predicate :: str :: is_match ( " " ) . unwrap ( ) ) . and ( predicate :: str :: is_match ( " " ) . unwrap ( ) ) . and ( predicate :: str :: is_match ( " " ) . unwrap ( ) ) . not ( ) , ) ; assert_eq ! ( js_mock hits ( ) 1 ) ; assert_eq ! ( js_prod_mock hits ( ) 1 ) ; assert_eq ! ( js_dev_mock hits ( ) 1 ) ; assert_eq ! ( js_dev_file_mock hits ( ) 1 ) ; assert_eq ! ( api_mock hits ( ) 0 ) ; teardown_tmp_directory ( tmp_dir ) ; }
test that the deny list prevents requests of urls found during recursion when the denier is a
parent of a user-specified scan
test that the deny list prevents requests of urls found during recursion when the denier is a parent of a user - specified scan