mirror of
https://github.com/ivre/masscanned.git
synced 2025-10-02 06:38:21 +00:00
Move HTTP tests into a module
This commit is contained in:
parent
dfb4707577
commit
c116c7bfdb
1 changed files with 117 additions and 112 deletions
|
@ -267,8 +267,12 @@ WWW-Authenticate: Basic realm=\"Access to admin page\"
|
|||
Some(repl_data)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_http_verb() {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_http_verb() {
|
||||
/* all at once */
|
||||
for verb in HTTP_VERBS.iter() {
|
||||
let mut pstate = ProtocolState::new();
|
||||
|
@ -333,10 +337,10 @@ fn test_http_verb() {
|
|||
assert!(pstate.state == HTTP_STATE_FAIL);
|
||||
assert!(pstate.smack_state == UNANCHORED_STATE);
|
||||
assert!(pstate.smack_id == NO_MATCH);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_http_request_line() {
|
||||
#[test]
|
||||
fn test_http_request_line() {
|
||||
let mut pstate = ProtocolState::new();
|
||||
let data = "GET /index.php HTTP/1.1\r\n".as_bytes();
|
||||
for i in 0..data.len() {
|
||||
|
@ -357,10 +361,10 @@ fn test_http_request_line() {
|
|||
assert!(pstate.state == HTTP_STATE_FIELD_START);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_http_request_field() {
|
||||
#[test]
|
||||
fn test_http_request_field() {
|
||||
let mut pstate = ProtocolState::new();
|
||||
let req = "POST /index.php HTTP/2.0\r\n".as_bytes();
|
||||
http_parse(&mut pstate, req);
|
||||
|
@ -374,10 +378,10 @@ fn test_http_request_field() {
|
|||
let value = b": 0\r\n";
|
||||
http_parse(&mut pstate, value);
|
||||
assert!(pstate.state == HTTP_STATE_FIELD_START);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_http_request_no_field() {
|
||||
#[test]
|
||||
fn test_http_request_no_field() {
|
||||
let mut pstate = ProtocolState::new();
|
||||
let req = "POST /index.php HTTP/2.0\r\n".as_bytes();
|
||||
http_parse(&mut pstate, req);
|
||||
|
@ -385,4 +389,5 @@ fn test_http_request_no_field() {
|
|||
let crlf = "\r\n".as_bytes();
|
||||
http_parse(&mut pstate, crlf);
|
||||
assert!(pstate.state == HTTP_STATE_CONTENT);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue