fix(validation): relax the sendgrid API key validation regex (#55) r=@vbudhram,@vladikoff

This commit is contained in:
Phil Booth 2018-06-05 20:45:09 +01:00 коммит произвёл Vlad Filippov
Родитель 66f5d5c049
Коммит 008f119137
2 изменённых файлов: 4 добавлений и 10 удалений

Просмотреть файл

@ -21,7 +21,7 @@ lazy_static! {
static ref PROVIDER_FORMAT: Regex = Regex::new("^(?:mock|sendgrid|ses|smtp)$").unwrap();
static ref SENDER_NAME_FORMAT: Regex =
Regex::new("^[A-Za-z0-9-]+(?: [A-Za-z0-9-]+)*$").unwrap();
static ref SENDGRID_API_KEY_FORMAT: Regex = Regex::new("^[A-Za-z0-9._]{69}$").unwrap();
static ref SENDGRID_API_KEY_FORMAT: Regex = Regex::new("^[A-Za-z0-9._-]+$").unwrap();
static ref SQS_URL_FORMAT: Regex =
Regex::new("^https://sqs\\.[a-z0-9-]+\\.amazonaws\\.com/[0-9]+/[A-Za-z0-9-]+$").unwrap();
}

Просмотреть файл

@ -149,23 +149,17 @@ fn invalid_sender_name() {
#[test]
fn sendgrid_api_key() {
assert!(validate::sendgrid_api_key(
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._12345"
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._-"
));
}
#[test]
fn invalid_sendgrid_api_key() {
assert!(!validate::sendgrid_api_key(
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._12345 "
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._- "
));
assert!(!validate::sendgrid_api_key(
" 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._12345"
));
assert!(!validate::sendgrid_api_key(
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._1234"
));
assert!(!validate::sendgrid_api_key(
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._123456"
" 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._-"
));
}