-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
585d736
commit 10bec56
Showing
4 changed files
with
124 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
mod common; | ||
|
||
#[cfg(test)] | ||
mod github | ||
{ | ||
use axum::http::{HeaderMap, HeaderValue}; | ||
use busser::integrations::github::is_push; | ||
use reqwest::StatusCode; | ||
|
||
#[tokio::test] | ||
async fn test_is_push() | ||
{ | ||
let headers = HeaderMap::new(); | ||
assert_eq!(is_push(&headers).await, StatusCode::CONTINUE); | ||
|
||
let mut headers = HeaderMap::new(); | ||
headers.insert("user-agent", HeaderValue::from_str("not_github").unwrap()); | ||
assert_eq!(is_push(&headers).await, StatusCode::CONTINUE); | ||
|
||
let mut headers = HeaderMap::new(); | ||
headers.insert("user-agent", HeaderValue::from_str("GitHub-Hookshot").unwrap()); | ||
assert_eq!(is_push(&headers).await, StatusCode::BAD_REQUEST); | ||
|
||
let mut headers = HeaderMap::new(); | ||
headers.insert("user-agent", HeaderValue::from_str("GitHub-Hookshot").unwrap()); | ||
headers.insert("x-github-event", HeaderValue::from_str("not_a_push").unwrap()); | ||
assert_eq!(is_push(&headers).await, StatusCode::CONTINUE); | ||
|
||
let mut headers = HeaderMap::new(); | ||
headers.insert("user-agent", HeaderValue::from_str("GitHub-Hookshot").unwrap()); | ||
headers.insert("x-github-event", HeaderValue::from_str("push").unwrap()); | ||
assert_eq!(is_push(&headers).await, StatusCode::OK); | ||
} | ||
} |