Forbid wildcard import.
This commit is contained in:
parent
04c31f3a71
commit
c792710f50
|
|
@ -20,3 +20,4 @@ warnings = "deny"
|
|||
empty_structs_with_brackets = "deny"
|
||||
manual_string_new = "deny"
|
||||
semicolon_if_nothing_returned = "deny"
|
||||
wildcard-imports = "deny"
|
||||
|
|
|
|||
|
|
@ -30,19 +30,19 @@ use encoding::{DecoderTrap, Encoding};
|
|||
use hurl_core::typing::Count;
|
||||
|
||||
use crate::http::certificate::Certificate;
|
||||
use crate::http::core::*;
|
||||
use crate::http::curl_cmd::CurlCmd;
|
||||
use crate::http::debug::log_body;
|
||||
use crate::http::header::{
|
||||
HeaderVec, ACCEPT_ENCODING, AUTHORIZATION, CONTENT_TYPE, EXPECT, LOCATION, USER_AGENT,
|
||||
};
|
||||
use crate::http::options::ClientOptions;
|
||||
use crate::http::request::*;
|
||||
use crate::http::request_spec::*;
|
||||
use crate::http::response::*;
|
||||
use crate::http::timings::Timings;
|
||||
use crate::http::url::Url;
|
||||
use crate::http::{easy_ext, Call, Header, HttpError, Verbosity};
|
||||
use crate::http::{
|
||||
easy_ext, Call, Cookie, FileParam, Header, HttpError, HttpVersion, IpResolve, Method,
|
||||
MultipartParam, Param, Request, RequestCookie, RequestSpec, RequestedHttpVersion, Response,
|
||||
Verbosity,
|
||||
};
|
||||
use crate::runner::Output;
|
||||
use crate::util::logger::Logger;
|
||||
use crate::util::path::ContextDir;
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@
|
|||
*/
|
||||
use std::fmt;
|
||||
|
||||
use crate::http::core::*;
|
||||
use crate::http::header::{HeaderVec, COOKIE};
|
||||
use crate::http::url::Url;
|
||||
use crate::http::RequestCookie;
|
||||
|
||||
/// Represents a runtime HTTP request.
|
||||
/// This is a real request, that has been executed by our HTTP client.
|
||||
|
|
|
|||
|
|
@ -17,9 +17,8 @@
|
|||
*/
|
||||
use core::fmt;
|
||||
|
||||
use crate::http::core::*;
|
||||
use crate::http::header::HeaderVec;
|
||||
use crate::http::Url;
|
||||
use crate::http::{Param, RequestCookie, Url};
|
||||
|
||||
/// Represents the HTTP request asked to be executed by our user (different from the runtime
|
||||
/// executed HTTP request [`crate::http::Request`].
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::ast::{Assert, SourceInfo};
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use crate::http;
|
||||
|
|
@ -210,7 +210,10 @@ pub fn eval_explicit_assert(
|
|||
pub mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::ast::{
|
||||
Filter, FilterValue, LineTerminator, Predicate, PredicateFunc, PredicateFuncValue,
|
||||
PredicateValue, SourceInfo, Whitespace,
|
||||
};
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::super::query;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
use std::path::PathBuf;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::ast::{Base64, Body, Bytes, File, Hex, Template};
|
||||
|
||||
use crate::http;
|
||||
use crate::runner::error::{RunnerError, RunnerErrorKind};
|
||||
|
|
@ -91,7 +91,7 @@ pub fn eval_file(
|
|||
mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::ast::{SourceInfo, TemplateElement, Whitespace};
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::ast::Capture;
|
||||
|
||||
use crate::http;
|
||||
use crate::runner::cache::BodyCache;
|
||||
|
|
@ -74,7 +74,9 @@ pub fn eval_capture(
|
|||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::ast::{
|
||||
LineTerminator, Query, QueryValue, SourceInfo, Template, TemplateElement, Whitespace,
|
||||
};
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use self::super::super::query;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::ast::{Entry, SourceInfo};
|
||||
|
||||
use crate::http;
|
||||
use crate::http::{ClientOptions, CurlCmd};
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
use std::ffi::OsStr;
|
||||
use std::path::Path;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::ast::{FileParam, FileValue, KeyValue, MultipartParam};
|
||||
|
||||
use crate::http;
|
||||
use crate::runner::body::eval_file;
|
||||
|
|
@ -93,7 +93,7 @@ pub fn file_value_content_type(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::ast::{LineTerminator, SourceInfo, Template, TemplateElement, Whitespace};
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -15,10 +15,9 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::ast::{Predicate, PredicateFunc, PredicateFuncValue, PredicateValue, SourceInfo};
|
||||
use hurl_core::reader::Pos;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use crate::runner::error::RunnerError;
|
||||
use crate::runner::predicate_value::{eval_predicate_value, eval_predicate_value_template};
|
||||
|
|
@ -935,9 +934,11 @@ fn contains(haystack: &[u8], needle: &[u8]) -> bool {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
use super::{AssertResult, *};
|
||||
use hurl_core::ast::{
|
||||
Expr, ExprKind, Float, Placeholder, Regex, Template, TemplateElement, Variable, Whitespace,
|
||||
};
|
||||
use std::path::Path;
|
||||
|
||||
fn whitespace() -> Whitespace {
|
||||
Whitespace {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::ast::{Number, Placeholder, PredicateValue};
|
||||
|
||||
use crate::runner::body::eval_file; // TODO move function out of body module
|
||||
use crate::runner::error::RunnerError;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::ast::{
|
||||
CertificateAttributeName, CookieAttribute, CookieAttributeName, CookiePath, Query, QueryValue,
|
||||
RegexValue, SourceInfo, Template,
|
||||
};
|
||||
use regex::Regex;
|
||||
use sha2::Digest;
|
||||
|
||||
|
|
@ -448,7 +451,7 @@ impl Value {
|
|||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use hex_literal::hex;
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::ast::{SourceInfo, TemplateElement, Whitespace};
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ use std::str::FromStr;
|
|||
|
||||
use base64::engine::general_purpose;
|
||||
use base64::Engine;
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::ast::{
|
||||
Body, Bytes, Method, MultilineString, MultilineStringKind, Request, Template,
|
||||
};
|
||||
|
||||
use crate::http;
|
||||
use crate::http::{HeaderVec, HttpError, Url, AUTHORIZATION};
|
||||
|
|
@ -191,7 +193,10 @@ fn eval_method(method: &Method) -> http::Method {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::runner::Value;
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::ast::{
|
||||
Comment, Expr, ExprKind, KeyValue, LineTerminator, Placeholder, Section, SectionValue,
|
||||
SourceInfo, TemplateElement, Variable, Whitespace,
|
||||
};
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::super::error::RunnerErrorKind;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::ast::{Placeholder, Template, TemplateElement};
|
||||
|
||||
use crate::runner::error::RunnerError;
|
||||
use crate::runner::{expr, VariableSet};
|
||||
|
|
@ -45,7 +45,7 @@ fn eval_template_element(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::ast::{Expr, ExprKind, SourceInfo, Variable, Whitespace};
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -15,10 +15,15 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::{
|
||||
BooleanOption, CookieAttribute, CookieAttributeName, CookiePath, CountOption, DurationOption,
|
||||
Expr, ExprKind, Float, Function, Hex, Method, MultilineString, MultilineStringAttribute,
|
||||
MultilineStringKind, NaturalOption, Number, Placeholder, PredicateFuncValue, Regex, Status,
|
||||
StatusValue, Template, TemplateElement, Variable, VariableDefinition, VariableValue, Version,
|
||||
VersionValue,
|
||||
};
|
||||
use core::fmt;
|
||||
|
||||
use crate::ast::core::*;
|
||||
|
||||
impl fmt::Display for Method {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
|
|
@ -328,6 +333,7 @@ impl PredicateFuncValue {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::{CookieAttributeName, SourceInfo, Whitespace};
|
||||
use crate::reader::Pos;
|
||||
|
||||
fn whitespace() -> Whitespace {
|
||||
|
|
|
|||
|
|
@ -15,10 +15,17 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use std::fmt::Display;
|
||||
|
||||
use crate::ast::*;
|
||||
use crate::ast::{
|
||||
Assert, Base64, Body, BooleanOption, Bytes, Capture, CertificateAttributeName, Comment, Cookie,
|
||||
CookieAttribute, CookiePath, CountOption, DurationOption, Entry, EntryOption, File, FileParam,
|
||||
FileValue, Filter, FilterValue, GraphQl, GraphQlVariables, Hex, HurlFile, JsonValue, KeyValue,
|
||||
LineTerminator, Method, MultilineString, MultilineStringKind, MultipartParam, NaturalOption,
|
||||
OptionKind, Placeholder, Predicate, PredicateFunc, PredicateFuncValue, PredicateValue, Query,
|
||||
QueryValue, Regex, RegexValue, Request, Response, Section, SectionValue, Status, Template,
|
||||
TemplateElement, VariableDefinition, VariableValue, Version, Whitespace,
|
||||
};
|
||||
use crate::typing::Count;
|
||||
use std::fmt::Display;
|
||||
|
||||
/// Returns an HTML string of the Hurl file `hurl_file`.
|
||||
///
|
||||
|
|
@ -945,6 +952,7 @@ fn pop_str(string: &mut String, suffix: &str) {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::{JsonObjectElement, SourceInfo, Text};
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -15,13 +15,12 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::ast::Bytes;
|
||||
use crate::combinator::choice;
|
||||
use crate::parser::json::parse as parse_json;
|
||||
use crate::parser::multiline::multiline_string;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::string::backtick_template;
|
||||
use crate::parser::{xml, ParseResult};
|
||||
use crate::parser::{primitives, xml, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
|
||||
pub fn bytes(reader: &mut Reader) -> ParseResult<Bytes> {
|
||||
|
|
@ -54,15 +53,15 @@ fn json_bytes(reader: &mut Reader) -> ParseResult<Bytes> {
|
|||
}
|
||||
|
||||
fn file_bytes(reader: &mut Reader) -> ParseResult<Bytes> {
|
||||
file(reader).map(Bytes::File)
|
||||
primitives::file(reader).map(Bytes::File)
|
||||
}
|
||||
|
||||
fn base64_bytes(reader: &mut Reader) -> ParseResult<Bytes> {
|
||||
base64(reader).map(Bytes::Base64)
|
||||
primitives::base64(reader).map(Bytes::Base64)
|
||||
}
|
||||
|
||||
fn hex_bytes(reader: &mut Reader) -> ParseResult<Bytes> {
|
||||
hex(reader).map(Bytes::Hex)
|
||||
primitives::hex(reader).map(Bytes::Hex)
|
||||
}
|
||||
|
||||
pub fn multiline_string_bytes(reader: &mut Reader) -> ParseResult<Bytes> {
|
||||
|
|
@ -77,6 +76,7 @@ fn string_bytes(reader: &mut Reader) -> ParseResult<Bytes> {
|
|||
mod tests {
|
||||
use super::super::error::*;
|
||||
use super::*;
|
||||
use crate::ast::{JsonListElement, JsonValue, SourceInfo, Template, TemplateElement};
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -15,12 +15,10 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::ast::{CookieAttribute, CookieAttributeName, CookiePath};
|
||||
use crate::combinator::optional;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::string::*;
|
||||
use crate::parser::ParseResult;
|
||||
use crate::parser::primitives::{literal, try_literal, zero_or_more_spaces};
|
||||
use crate::parser::{string, ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
|
||||
pub fn cookiepath(reader: &mut Reader) -> ParseResult<CookiePath> {
|
||||
|
|
@ -30,7 +28,7 @@ pub fn cookiepath(reader: &mut Reader) -> ParseResult<CookiePath> {
|
|||
// relative tho the main reader.
|
||||
let s = reader.read_while(|c| c != '[');
|
||||
let mut template_reader = Reader::with_pos(s.as_str(), start);
|
||||
let name = unquoted_template(&mut template_reader)?;
|
||||
let name = string::unquoted_template(&mut template_reader)?;
|
||||
let attribute = optional(cookiepath_attribute, reader)?;
|
||||
Ok(CookiePath { name, attribute })
|
||||
}
|
||||
|
|
@ -71,7 +69,9 @@ fn cookiepath_attribute_name(reader: &mut Reader) -> ParseResult<CookieAttribute
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::SourceInfo;
|
||||
use crate::ast::{
|
||||
Expr, ExprKind, Placeholder, SourceInfo, Template, TemplateElement, Variable, Whitespace,
|
||||
};
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -15,10 +15,8 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::number::natural;
|
||||
use crate::parser::ParseResult;
|
||||
use crate::parser::{ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
use crate::typing::{Duration, DurationUnit};
|
||||
use std::str::FromStr;
|
||||
|
|
|
|||
|
|
@ -15,10 +15,9 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::function;
|
||||
use crate::ast::{Expr, ExprKind, SourceInfo, Variable};
|
||||
use crate::parser::ParseResult;
|
||||
use crate::parser::{function, ParseError, ParseErrorKind};
|
||||
use crate::reader::Reader;
|
||||
|
||||
/// Parse an expression
|
||||
|
|
|
|||
|
|
@ -15,10 +15,9 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::ast::{SourceInfo, Template, TemplateElement};
|
||||
use crate::parser::primitives::try_literal;
|
||||
use crate::parser::{string, ParseResult};
|
||||
use crate::parser::{string, ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
|
||||
use super::placeholder;
|
||||
|
|
@ -149,6 +148,7 @@ fn filename_escaped_char(reader: &mut Reader) -> ParseResult<char> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::{Expr, ExprKind, Placeholder, Variable, Whitespace};
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -15,10 +15,9 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::ast::{SourceInfo, Template, TemplateElement};
|
||||
use crate::parser::primitives::try_literal;
|
||||
use crate::parser::{string, ParseResult};
|
||||
use crate::parser::{string, ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
|
||||
use super::placeholder;
|
||||
|
|
|
|||
|
|
@ -15,9 +15,8 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::ParseResult;
|
||||
use crate::ast::Function;
|
||||
use crate::parser::{ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
|
||||
/// Parse a function
|
||||
|
|
|
|||
|
|
@ -17,10 +17,9 @@
|
|||
*/
|
||||
use crate::ast::{JsonListElement, JsonObjectElement, JsonValue, SourceInfo, Template};
|
||||
use crate::combinator::{choice, non_recover, ParseError as ParseErrorTrait};
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::template::*;
|
||||
use crate::parser::ParseResult;
|
||||
use crate::parser::primitives::{boolean, hex_digit, literal, try_literal};
|
||||
use crate::parser::template::EncodedString;
|
||||
use crate::parser::{templatize, JsonErrorVariant, ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::{Pos, Reader};
|
||||
|
||||
use super::placeholder;
|
||||
|
|
|
|||
|
|
@ -15,10 +15,9 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::{string, ParseResult};
|
||||
use crate::ast::{SourceInfo, Template, TemplateElement};
|
||||
use crate::parser::primitives::try_literal;
|
||||
use crate::parser::{string, ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
|
||||
use super::placeholder;
|
||||
|
|
|
|||
|
|
@ -15,10 +15,13 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::ast::{
|
||||
GraphQl, GraphQlVariables, MultilineString, MultilineStringAttribute, MultilineStringKind,
|
||||
SourceInfo, Template, Text, Whitespace,
|
||||
};
|
||||
use crate::combinator::{choice, optional, zero_or_more};
|
||||
use crate::parser::json::object_value;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::primitives::{literal, newline, try_literal, zero_or_more_spaces};
|
||||
use crate::parser::string::escape_char;
|
||||
use crate::parser::{template, ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
|
|
@ -266,6 +269,7 @@ fn multiline_string_value(reader: &mut Reader, escape: bool) -> ParseResult<Temp
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::ast::{JsonObjectElement, JsonValue, TemplateElement};
|
||||
use crate::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -15,10 +15,9 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::ast::{Float, Number};
|
||||
use crate::parser::primitives::try_literal;
|
||||
use crate::parser::ParseResult;
|
||||
use crate::parser::{ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
|
||||
pub fn natural(reader: &mut Reader) -> ParseResult<u64> {
|
||||
|
|
|
|||
|
|
@ -15,14 +15,19 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::ast::{
|
||||
is_variable_reserved, BooleanOption, CountOption, DurationOption, EntryOption, NaturalOption,
|
||||
OptionKind, SourceInfo, VariableDefinition, VariableValue,
|
||||
};
|
||||
use crate::combinator::{choice, non_recover};
|
||||
use crate::parser::duration::duration;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::number::{integer, natural, number};
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::string::*;
|
||||
use crate::parser::{filename, filename_password, ParseResult};
|
||||
use crate::parser::primitives::{
|
||||
boolean, line_terminator, literal, null, optional_line_terminators, try_literal,
|
||||
zero_or_more_spaces,
|
||||
};
|
||||
use crate::parser::string::{quoted_template, unquoted_template};
|
||||
use crate::parser::{filename, filename_password, ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
use crate::typing::Count;
|
||||
|
||||
|
|
@ -434,6 +439,7 @@ fn variable_value(reader: &mut Reader) -> ParseResult<VariableValue> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::{LineTerminator, Number, Template, TemplateElement, Whitespace};
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -16,18 +16,22 @@
|
|||
*
|
||||
*/
|
||||
use crate::ast::VersionValue::VersionAny;
|
||||
use crate::ast::*;
|
||||
use crate::ast::{
|
||||
Body, Entry, HurlFile, Method, Request, Response, SourceInfo, Status, StatusValue, Version,
|
||||
VersionValue,
|
||||
};
|
||||
use crate::combinator::{optional, zero_or_more};
|
||||
use crate::parser::bytes::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::bytes::bytes;
|
||||
use crate::parser::number::natural;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::sections::*;
|
||||
use crate::parser::ParseResult;
|
||||
use crate::parser::primitives::{
|
||||
eof, key_value, line_terminator, one_or_more_spaces, optional_line_terminators, try_literal,
|
||||
zero_or_more_spaces,
|
||||
};
|
||||
use crate::parser::sections::{request_sections, response_sections};
|
||||
use crate::parser::string::unquoted_template;
|
||||
use crate::parser::{ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
|
||||
use super::string::unquoted_template;
|
||||
|
||||
pub fn hurl_file(reader: &mut Reader) -> ParseResult<HurlFile> {
|
||||
let entries = zero_or_more(entry, reader)?;
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
|
|
@ -195,6 +199,10 @@ fn body(reader: &mut Reader) -> ParseResult<Body> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::{
|
||||
Bytes, Comment, JsonListElement, JsonValue, LineTerminator, MultilineString,
|
||||
MultilineStringKind, Template, TemplateElement, Text, Whitespace,
|
||||
};
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
|
|
@ -485,17 +493,11 @@ mod tests {
|
|||
#[test]
|
||||
fn test_version() {
|
||||
let mut reader = Reader::new("HTTP 200");
|
||||
assert_eq!(
|
||||
version(&mut reader).unwrap().value,
|
||||
VersionValue::VersionAny
|
||||
);
|
||||
assert_eq!(version(&mut reader).unwrap().value, VersionAny);
|
||||
assert_eq!(reader.cursor().index, 4);
|
||||
|
||||
let mut reader = Reader::new("HTTP\t200");
|
||||
assert_eq!(
|
||||
version(&mut reader).unwrap().value,
|
||||
VersionValue::VersionAny
|
||||
);
|
||||
assert_eq!(version(&mut reader).unwrap().value, VersionAny);
|
||||
assert_eq!(reader.cursor().index, 4);
|
||||
|
||||
let mut reader = Reader::new("HTTP/1.1 200");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
use super::{expr, ParseResult};
|
||||
use crate::ast::Placeholder;
|
||||
use crate::parser::primitives::{literal, try_literal, zero_or_more_spaces};
|
||||
/*
|
||||
* Hurl (https://hurl.dev)
|
||||
* Copyright (C) 2024 Orange
|
||||
|
|
@ -16,8 +18,6 @@ use super::{expr, ParseResult};
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::reader::Reader;
|
||||
|
||||
/// Parse a placeholder {{ expr }}
|
||||
|
|
@ -37,6 +37,7 @@ pub fn parse(reader: &mut Reader) -> ParseResult<Placeholder> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::{Expr, ExprKind, SourceInfo, Variable, Whitespace};
|
||||
use crate::{parser::ParseErrorKind, reader::Pos};
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -15,12 +15,15 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::ast::{
|
||||
Predicate, PredicateFunc, PredicateFuncValue, PredicateValue, SourceInfo, Whitespace,
|
||||
};
|
||||
use crate::combinator::choice;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::predicate_value::predicate_value;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::ParseResult;
|
||||
use crate::parser::primitives::{
|
||||
one_or_more_spaces, try_literal, try_literals, zero_or_more_spaces,
|
||||
};
|
||||
use crate::parser::{ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
|
||||
pub fn predicate(reader: &mut Reader) -> ParseResult<Predicate> {
|
||||
|
|
@ -382,6 +385,9 @@ fn is_number_predicate(reader: &mut Reader) -> ParseResult<PredicateFuncValue> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::{
|
||||
Expr, ExprKind, Float, Number, Placeholder, Template, TemplateElement, Variable,
|
||||
};
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::ast::PredicateValue;
|
||||
use crate::combinator::choice;
|
||||
use crate::parser::multiline::multiline_string;
|
||||
use crate::parser::number::number;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::string::*;
|
||||
use crate::parser::primitives::{base64, boolean, file, hex, null, regex};
|
||||
use crate::parser::string::{backtick_template, quoted_template};
|
||||
use crate::parser::{ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
|
||||
|
|
@ -88,8 +88,8 @@ pub fn predicate_value(reader: &mut Reader) -> ParseResult<PredicateValue> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use super::*;
|
||||
use crate::ast::{Float, Number};
|
||||
use crate::parser::ParseErrorKind;
|
||||
use crate::reader::Pos;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,12 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::ast::{
|
||||
Base64, Comment, File, Hex, KeyValue, LineTerminator, Regex, SourceInfo, Whitespace,
|
||||
};
|
||||
use crate::combinator::{one_or_more, optional, recover, zero_or_more};
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::string::*;
|
||||
use crate::parser::{base64, filename, key_string, ParseResult};
|
||||
use crate::parser::string::unquoted_template;
|
||||
use crate::parser::{base64, filename, key_string, ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
|
||||
pub fn space(reader: &mut Reader) -> ParseResult<Whitespace> {
|
||||
|
|
@ -69,7 +70,6 @@ pub fn zero_or_more_spaces(reader: &mut Reader) -> ParseResult<Whitespace> {
|
|||
}
|
||||
|
||||
pub fn line_terminator(reader: &mut Reader) -> ParseResult<LineTerminator> {
|
||||
// let start = p.state.clone();
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
let comment = optional(comment, reader)?;
|
||||
let nl = if reader.is_eof() {
|
||||
|
|
@ -440,6 +440,7 @@ pub fn hex_digit(reader: &mut Reader) -> ParseResult<u32> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::{Expr, ExprKind, Placeholder, Template, TemplateElement, Variable};
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
|
|
@ -745,7 +746,7 @@ mod tests {
|
|||
assert!(error.recoverable);
|
||||
assert_eq!(reader.cursor().index, 5); // does not reset cursor
|
||||
|
||||
let mut reader = Reader::new("GET http://google.fr");
|
||||
let mut reader = Reader::new("GET ®http://google.fr");
|
||||
let error = key_value(&mut reader).err().unwrap();
|
||||
assert_eq!(error.pos, Pos { line: 1, column: 5 });
|
||||
assert!(error.recoverable);
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::ast::{CertificateAttributeName, Query, QueryValue, RegexValue, SourceInfo};
|
||||
use crate::combinator::{choice, ParseError as ParseErrorTrait};
|
||||
use crate::parser::cookiepath::cookiepath;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::string::*;
|
||||
use crate::parser::primitives::{literal, one_or_more_spaces, regex, try_literal};
|
||||
use crate::parser::string::{quoted_oneline_string, quoted_template};
|
||||
use crate::parser::{ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::{Pos, Reader};
|
||||
|
||||
|
|
@ -213,6 +213,10 @@ fn certificate_field(reader: &mut Reader) -> ParseResult<CertificateAttributeNam
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::{
|
||||
CookieAttribute, CookieAttributeName, CookiePath, Filter, FilterValue, Template,
|
||||
TemplateElement, Whitespace,
|
||||
};
|
||||
use crate::parser::filter::filters;
|
||||
use crate::reader::Pos;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,15 +15,20 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::ast::{
|
||||
Assert, Capture, Cookie, FileParam, FileValue, MultipartParam, Section, SectionValue,
|
||||
SourceInfo, Whitespace,
|
||||
};
|
||||
use crate::combinator::{optional, recover, zero_or_more};
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::filter::filters;
|
||||
use crate::parser::predicate::predicate;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::primitives::{
|
||||
key_value, line_terminator, literal, one_or_more_spaces, optional_line_terminators,
|
||||
try_literal, zero_or_more_spaces,
|
||||
};
|
||||
use crate::parser::query::query;
|
||||
use crate::parser::string::*;
|
||||
use crate::parser::{filename, key_string, option, ParseResult};
|
||||
use crate::parser::string::unquoted_template;
|
||||
use crate::parser::{filename, key_string, option, ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::{Pos, Reader};
|
||||
|
||||
pub fn request_sections(reader: &mut Reader) -> ParseResult<Vec<Section>> {
|
||||
|
|
@ -323,6 +328,10 @@ fn assert(reader: &mut Reader) -> ParseResult<Assert> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::{
|
||||
KeyValue, LineTerminator, Number, Predicate, PredicateFunc, PredicateFuncValue,
|
||||
PredicateValue, Query, QueryValue, Template, TemplateElement,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_section_name() {
|
||||
|
|
|
|||
|
|
@ -15,11 +15,10 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::ast::{SourceInfo, Template};
|
||||
use crate::combinator::one_or_more;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::{template, ParseResult};
|
||||
use crate::parser::primitives::{hex_digit, literal, try_literal};
|
||||
use crate::parser::{template, ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
|
||||
/// Steps:
|
||||
|
|
@ -241,10 +240,10 @@ fn hex_value(reader: &mut Reader) -> ParseResult<u32> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::time::SystemTime;
|
||||
|
||||
use super::*;
|
||||
use crate::ast::{Expr, ExprKind, Placeholder, TemplateElement, Variable, Whitespace};
|
||||
use crate::reader::Pos;
|
||||
use std::time::SystemTime;
|
||||
|
||||
#[test]
|
||||
fn test_unquoted_template_empty() {
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ use libxml::bindings::{
|
|||
xmlChar, xmlCreatePushParserCtxt, xmlFreeParserCtxt, xmlParseChunk, xmlSAXHandlerPtr,
|
||||
};
|
||||
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::ParseResult;
|
||||
use crate::parser::{ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
|
||||
/// Parses a text buffer until a valid XML has been found.
|
||||
|
|
|
|||
|
|
@ -15,13 +15,19 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::format::serialize_json::JValue;
|
||||
use base64::engine::general_purpose;
|
||||
use base64::Engine;
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::ast::{
|
||||
Assert, Base64, Body, BooleanOption, Bytes, Capture, CertificateAttributeName, Comment, Cookie,
|
||||
CountOption, DurationOption, Entry, EntryOption, File, FileParam, Filter, FilterValue, Header,
|
||||
Hex, HurlFile, JsonListElement, JsonValue, KeyValue, MultilineString, MultilineStringKind,
|
||||
MultipartParam, NaturalOption, OptionKind, Placeholder, Predicate, PredicateFuncValue,
|
||||
PredicateValue, Query, QueryValue, Regex, RegexValue, Request, Response, StatusValue,
|
||||
VersionValue,
|
||||
};
|
||||
use hurl_core::typing::{Count, Duration};
|
||||
|
||||
use super::serialize_json::*;
|
||||
|
||||
pub fn format(hurl_file: &HurlFile) -> String {
|
||||
hurl_file.to_json().format()
|
||||
}
|
||||
|
|
@ -805,6 +811,10 @@ impl ToJson for NaturalOption {
|
|||
}
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use hurl_core::ast::{
|
||||
LineTerminator, Method, Number, PredicateFunc, SourceInfo, Status, Template,
|
||||
TemplateElement, Version, Whitespace,
|
||||
};
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::ast::HurlFile;
|
||||
use hurl_core::text::{Format, Style, StyledString};
|
||||
|
||||
use crate::format::token::*;
|
||||
use crate::format::{Token, Tokenizable};
|
||||
|
||||
pub fn format(hurl_file: &HurlFile, color: bool) -> String {
|
||||
let mut buffer = String::new();
|
||||
|
|
|
|||
|
|
@ -15,7 +15,17 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::ast::{
|
||||
Assert, Base64, Body, BooleanOption, Bytes, Capture, CertificateAttributeName, Comment, Cookie,
|
||||
CookieAttribute, CookiePath, CountOption, DurationOption, EncodedString, Entry, EntryOption,
|
||||
Expr, ExprKind, File, FileParam, FileValue, Filter, FilterValue, Function, GraphQl,
|
||||
GraphQlVariables, Hex, HurlFile, JsonListElement, JsonObjectElement, JsonValue, KeyValue,
|
||||
LineTerminator, Method, MultilineString, MultilineStringAttribute, MultilineStringKind,
|
||||
MultipartParam, NaturalOption, OptionKind, Placeholder, Predicate, PredicateFunc,
|
||||
PredicateFuncValue, PredicateValue, Query, QueryValue, Regex, RegexValue, Request, Response,
|
||||
Section, SectionValue, Status, StatusValue, Template, TemplateElement, Text, Variable,
|
||||
VariableDefinition, VariableValue, Version, Whitespace,
|
||||
};
|
||||
use hurl_core::typing::{Count, Duration};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
|
|
|
|||
|
|
@ -16,7 +16,14 @@
|
|||
*
|
||||
*/
|
||||
use crate::linter::{LinterError, LinterErrorKind};
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::ast::{
|
||||
Assert, Base64, Body, Bytes, Capture, Comment, Cookie, CookieAttribute, CookieAttributeName,
|
||||
CookiePath, DurationOption, Entry, EntryOption, File, FileParam, Filter, FilterValue, GraphQl,
|
||||
Hex, HurlFile, KeyValue, LineTerminator, MultilineString, MultilineStringAttribute,
|
||||
MultilineStringKind, MultipartParam, OptionKind, Predicate, PredicateFunc, PredicateFuncValue,
|
||||
PredicateValue, Query, QueryValue, RegexValue, Request, Response, Section, SectionValue,
|
||||
SourceInfo, Template, Text, VariableDefinition, Whitespace,
|
||||
};
|
||||
use hurl_core::reader::Pos;
|
||||
use hurl_core::typing::{Duration, DurationUnit};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue