Files
overleaf-cep/services/web/test/unit/src/Email/SpamSafeTests.js
Eric Mc Sween 2603597150 Merge pull request #2221 from overleaf/em-ownership-transfer-emails
Project ownership transfer emails

GitOrigin-RevId: 3d33147c18e2d652976b3dac7453c0407c81314e
2019-10-15 13:30:10 +00:00

77 lines
2.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const path = require('path')
const modulePath = path.join(
__dirname,
'../../../../app/src/Features/Email/SpamSafe'
)
const SpamSafe = require(modulePath)
const { expect } = require('chai')
describe('SpamSafe', function() {
it('should reject spammy names', function() {
expect(SpamSafe.isSafeUserName('Charline Wałęsa')).to.equal(true)
expect(
SpamSafe.isSafeUserName(
"hey come buy this product im selling it's really good for you and it'll make your latex 10x guaranteed"
)
).to.equal(false)
expect(SpamSafe.isSafeUserName('隆太郎 宮本')).to.equal(true)
expect(SpamSafe.isSafeUserName('Visit haxx0red.com')).to.equal(false)
expect(
SpamSafe.isSafeUserName(
'加美汝VXhihi661金沙2001005com the first deposit will be _100%_'
)
).to.equal(false)
expect(
SpamSafe.isSafeProjectName(
'Neural Networks: good for your health and will solve all your problems'
)
).to.equal(false)
expect(
SpamSafe.isSafeProjectName(
'An analysis of the questions of the universe!'
)
).to.equal(true)
expect(SpamSafe.isSafeProjectName("A'p'o's't'r'o'p'h'e gallore")).to.equal(
true
)
expect(
SpamSafe.isSafeProjectName(
'come buy this => http://www.dopeproduct.com/search/?q=user123'
)
).to.equal(false)
expect(
SpamSafe.isSafeEmail('realistic-email+1@domain.sub-hyphen.com')
).to.equal(true)
expect(SpamSafe.isSafeEmail('notquiteRight@evil$.com')).to.equal(false)
expect(SpamSafe.safeUserName('Tammy Weinstįen', 'A User')).to.equal(
'Tammy Weinstįen'
)
expect(SpamSafe.safeUserName('haxx0red.com', 'A User')).to.equal('A User')
expect(SpamSafe.safeUserName('What$ Upp', 'A User')).to.equal('A User')
expect(SpamSafe.safeProjectName('Math-ematics!', 'A Project')).to.equal(
'Math-ematics!'
)
expect(
SpamSafe.safeProjectName(
`A Very long title for a very long book that will never be read${'a'.repeat(
250
)}`,
'A Project'
)
).to.equal('A Project')
expect(
SpamSafe.safeEmail('safe-ëmail@domain.com', 'A collaborator')
).to.equal('safe-ëmail@domain.com')
expect(
SpamSafe.safeEmail('Բարեւ@another.domain', 'A collaborator')
).to.equal('Բարեւ@another.domain')
expect(
SpamSafe.safeEmail(`me+${'a'.repeat(40)}@googoole.con`, 'A collaborator')
).to.equal('A collaborator')
expect(
SpamSafe.safeEmail('sendME$$$@iAmAprince.com', 'A collaborator')
).to.equal('A collaborator')
})
})