-
-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
complete support for using cookie file
- Loading branch information
Showing
11 changed files
with
341 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗ | ||
// ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝ | ||
// ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗ | ||
// ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║ | ||
// ██║ ██║ ██║███████║███████║██║██║ ╚████║╚██████╔╝ | ||
// ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝ | ||
|
||
#[cfg(test)] | ||
mod passing { | ||
use monolith::cookies; | ||
|
||
#[test] | ||
fn never_expires() { | ||
let cookie = cookies::Cookie { | ||
domain: String::from("127.0.0.1"), | ||
include_subdomains: true, | ||
path: String::from("/"), | ||
https_only: false, | ||
expires: 0, | ||
name: String::from(""), | ||
value: String::from(""), | ||
}; | ||
|
||
assert!(!cookie.is_expired()); | ||
} | ||
|
||
#[test] | ||
fn expires_long_from_now() { | ||
let cookie = cookies::Cookie { | ||
domain: String::from("127.0.0.1"), | ||
include_subdomains: true, | ||
path: String::from("/"), | ||
https_only: false, | ||
expires: 9999999999, | ||
name: String::from(""), | ||
value: String::from(""), | ||
}; | ||
|
||
assert!(!cookie.is_expired()); | ||
} | ||
} | ||
|
||
// ███████╗ █████╗ ██╗██╗ ██╗███╗ ██╗ ██████╗ | ||
// ██╔════╝██╔══██╗██║██║ ██║████╗ ██║██╔════╝ | ||
// █████╗ ███████║██║██║ ██║██╔██╗ ██║██║ ███╗ | ||
// ██╔══╝ ██╔══██║██║██║ ██║██║╚██╗██║██║ ██║ | ||
// ██║ ██║ ██║██║███████╗██║██║ ╚████║╚██████╔╝ | ||
// ╚═╝ ╚═╝ ╚═╝╚═╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝ | ||
|
||
#[cfg(test)] | ||
mod failing { | ||
use monolith::cookies; | ||
|
||
#[test] | ||
fn expired() { | ||
let cookie = cookies::Cookie { | ||
domain: String::from("127.0.0.1"), | ||
include_subdomains: true, | ||
path: String::from("/"), | ||
https_only: false, | ||
expires: 1, | ||
name: String::from(""), | ||
value: String::from(""), | ||
}; | ||
|
||
assert!(cookie.is_expired()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗ | ||
// ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝ | ||
// ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗ | ||
// ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║ | ||
// ██║ ██║ ██║███████║███████║██║██║ ╚████║╚██████╔╝ | ||
// ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝ | ||
|
||
#[cfg(test)] | ||
mod passing { | ||
use monolith::cookies; | ||
|
||
#[test] | ||
fn secure_url() { | ||
let cookie = cookies::Cookie { | ||
domain: String::from("127.0.0.1"), | ||
include_subdomains: true, | ||
path: String::from("/"), | ||
https_only: true, | ||
expires: 0, | ||
name: String::from(""), | ||
value: String::from(""), | ||
}; | ||
assert!(cookie.matches_url("https://127.0.0.1/something")); | ||
} | ||
|
||
#[test] | ||
fn non_secure_url() { | ||
let cookie = cookies::Cookie { | ||
domain: String::from("127.0.0.1"), | ||
include_subdomains: true, | ||
path: String::from("/"), | ||
https_only: false, | ||
expires: 0, | ||
name: String::from(""), | ||
value: String::from(""), | ||
}; | ||
assert!(cookie.matches_url("http://127.0.0.1/something")); | ||
} | ||
|
||
#[test] | ||
fn subdomain() { | ||
let cookie = cookies::Cookie { | ||
domain: String::from(".somethingsomething.com"), | ||
include_subdomains: true, | ||
path: String::from("/"), | ||
https_only: true, | ||
expires: 0, | ||
name: String::from(""), | ||
value: String::from(""), | ||
}; | ||
assert!(cookie.matches_url("https://cdn.somethingsomething.com/something")); | ||
} | ||
} | ||
|
||
// ███████╗ █████╗ ██╗██╗ ██╗███╗ ██╗ ██████╗ | ||
// ██╔════╝██╔══██╗██║██║ ██║████╗ ██║██╔════╝ | ||
// █████╗ ███████║██║██║ ██║██╔██╗ ██║██║ ███╗ | ||
// ██╔══╝ ██╔══██║██║██║ ██║██║╚██╗██║██║ ██║ | ||
// ██║ ██║ ██║██║███████╗██║██║ ╚████║╚██████╔╝ | ||
// ╚═╝ ╚═╝ ╚═╝╚═╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝ | ||
|
||
#[cfg(test)] | ||
mod failing { | ||
use monolith::cookies; | ||
|
||
#[test] | ||
fn empty_url() { | ||
let cookie = cookies::Cookie { | ||
domain: String::from("127.0.0.1"), | ||
include_subdomains: true, | ||
path: String::from("/"), | ||
https_only: false, | ||
expires: 0, | ||
name: String::from(""), | ||
value: String::from(""), | ||
}; | ||
assert!(!cookie.matches_url("")); | ||
} | ||
|
||
#[test] | ||
fn wrong_hostname() { | ||
let cookie = cookies::Cookie { | ||
domain: String::from("127.0.0.1"), | ||
include_subdomains: true, | ||
path: String::from("/"), | ||
https_only: false, | ||
expires: 0, | ||
name: String::from(""), | ||
value: String::from(""), | ||
}; | ||
assert!(!cookie.matches_url("http://0.0.0.0/")); | ||
} | ||
|
||
#[test] | ||
fn wrong_path() { | ||
let cookie = cookies::Cookie { | ||
domain: String::from("127.0.0.1"), | ||
include_subdomains: false, | ||
path: String::from("/"), | ||
https_only: false, | ||
expires: 0, | ||
name: String::from(""), | ||
value: String::from(""), | ||
}; | ||
assert!(!cookie.matches_url("http://0.0.0.0/path")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod is_expired; | ||
mod matches_url; |
Oops, something went wrong.