Last active
August 29, 2015 13:57
-
-
Save chilts/9676982 to your computer and use it in GitHub Desktop.
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
test( | |
'/account/create with a variety of malformed email addresses', | |
function (t) { | |
var pwd = '123456' | |
// See: http://en.wikipedia.org/wiki/Email_address#Valid_email_addresses | |
var emails = [ | |
'notAnEmailAddress', | |
'\n@example.com', | |
'me@hello world.com', | |
'me@hello+world.com', | |
'me@.example', | |
'me@example.com-', | |
'me@example..com', | |
'me@example-.com', | |
'me@example.-com', | |
'A@b@c@example.com', | |
'a"b(c)d,e:f;g<h>i[j\k]l@example.com', | |
'just"not"right@example.com', | |
'this is"not\allowed@example.com', | |
'this\ still\"not\\allowed@example.com', | |
// 'email@brazil.b', | |
// 'email@letter-and-number-at-end.h1', | |
] | |
emails.forEach(function(email, i) { | |
emails[i] = Client.create(config.publicUrl, email, pwd) | |
.then( | |
t.fail, | |
function (err) { | |
t.equal(err.code, 400, 'http 400 : malformed email is rejected') | |
} | |
) | |
}) | |
return P.all(emails) | |
} | |
) | |
test( | |
'/account/create with a variety of unusual but valid email addresses', | |
function (t) { | |
var pwd = '123456' | |
// See: http://en.wikipedia.org/wiki/Email_address#Valid_email_addresses | |
var emails = [ | |
'a+b+c@example.com', | |
'#!?-@t-e-s-t.c-o-m', | |
String.fromCharCode(1234) + '@example.com', | |
'test@' + String.fromCharCode(5678) + '.com', | |
'a.little.lengthy.but.fine@dept.example.com', | |
'disposable.style.email.with+symbol@example.com', | |
'other.email-with-dash@example.com', | |
// '"simple"@example.com', | |
// '"much.more unusual"@example.com', | |
// '"very.unusual.@.unusual.com"@example.com', | |
// '"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com', | |
'postbox@com', | |
'admin@mailserver1', | |
// ' !#$%&\'*+-/=?^_`{}|~@example.org', | |
// '"()<>[]:,;@\\\"!#$%&\'*+-/=?^_`{}| ~.a"@example.org', | |
// '" "@example.org', | |
'üñîçøðé@example.com', | |
'üñîçøðé@üñîçøðé.com', | |
] | |
emails.forEach(function(email, i) { | |
emails[i] = Client.create(config.publicUrl, email, pwd) | |
.then( | |
function(c) { | |
t.pass('Email ' + email + ' is valid') | |
return c.destroyAccount() | |
}, | |
function (err) { | |
t.fail('Email address ' + email + " should have been allowed, but it wasn't") | |
} | |
) | |
}) | |
return P.all(emails) | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment