mirror of
https://github.com/System-End/slack-morphism-rust.git
synced 2026-04-19 22:05:15 +00:00
chore: Missing unit test for SlackEventSignatureVerifier
This commit is contained in:
parent
75e9538e4c
commit
6850cd117b
1 changed files with 19 additions and 0 deletions
|
|
@ -293,4 +293,23 @@ mod test {
|
|||
_ => panic!("unexpected error, {}", err),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_if_ts_validated() {
|
||||
use sha2::Digest;
|
||||
|
||||
let key_str: String = hex::encode(Sha256::digest("test-key"));
|
||||
|
||||
let verifier = SlackEventSignatureVerifier::new(&key_str.into());
|
||||
|
||||
const TEST_BODY: &str = "test-body";
|
||||
|
||||
let test_ts = (chrono::Utc::now().timestamp() - 10 * 60 * 1000).to_string();
|
||||
let hash = verifier.sign(TEST_BODY, &test_ts).unwrap();
|
||||
|
||||
match verifier.verify(&hash, TEST_BODY, &test_ts).unwrap_err() {
|
||||
SlackEventSignatureVerifierError::IncorrectOrExpiredTimestampError(_) => {}
|
||||
e => panic!("unexpected error, {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue