show error on incorrect length chat key
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
e5d3ed7036
commit
0a8fe19418
|
@ -113,6 +113,8 @@ router.get('/browse/:url(*)', handleSite) /* Legacy */
|
|||
|
||||
router.get(/^\/(0[xX]04[0-9a-fA-F]{128})$/, handleChatKey)
|
||||
router.get(/^\/user\/(0[xX]04[0-9a-fA-F]{128})$/, handleChatKey) /* Legacy */
|
||||
router.get(/^\/(0[xX]04[0-9a-fA-F]{1,127})$/, handleError('Incorrect length of chat key'))
|
||||
router.get(/^\/(0[xX]04[0-9a-fA-F]{129,})$/, handleError('Incorrect length of chat key'))
|
||||
|
||||
router.get(/^\/@.*[A-Z]+.*$/, handleError('Upper case ENS names are invalid'))
|
||||
router.get(/^\/@(.+)$/, handleEnsName)
|
||||
|
|
|
@ -16,7 +16,7 @@ const get = (path) => (
|
|||
)
|
||||
|
||||
test('test browser routes', t => {
|
||||
t.test('/b/ens.domains', async t => {
|
||||
t.test('/b/ens.domains - VALID', async t => {
|
||||
const res = await get('/b/ens.domains')
|
||||
t.equal(res.statusCode, 200, 'returns 200')
|
||||
t.ok(res.text.includes(`href="http://${host}/b/ens.domains"`), 'contains link')
|
||||
|
@ -25,14 +25,14 @@ test('test browser routes', t => {
|
|||
})
|
||||
|
||||
test('test user ens routes', t => {
|
||||
t.test('/@jakubgs.eth', async t => {
|
||||
t.test('/@jakubgs.eth - VALID', async t => {
|
||||
const res = await get('/@jakubgs.eth')
|
||||
t.equal(res.statusCode, 200, 'returns 200')
|
||||
t.ok(res.text.includes(`href="http://${host}/@jakubgs.eth"`), 'contains link')
|
||||
t.ok(res.text.includes('Chat and transact with <span>@jakubgs.eth</span> in Status.'), 'contains prompt')
|
||||
})
|
||||
|
||||
t.test('/@jAkuBgs.eth.eth', async t => { /* we don't allow uppercase */
|
||||
t.test('/@jAkuBgs.eth.eth - UPPER CASE', async t => { /* we don't allow uppercase */
|
||||
const res = await get('/@jAkuBgs.eth')
|
||||
t.equal(res.statusCode, 400, 'returns 400')
|
||||
t.ok(res.text.includes('Upper case ENS names are invalid'), 'contains error')
|
||||
|
@ -40,7 +40,7 @@ test('test user ens routes', t => {
|
|||
})
|
||||
|
||||
test('test chat key routes', t => {
|
||||
t.test(`/0x04${chatKey.substr(0,8)}...`, async t => {
|
||||
t.test(`/0x04${chatKey.substr(0,8)}... - VALID`, async t => {
|
||||
const res = await get(`/0x04${chatKey}`)
|
||||
t.equal(res.statusCode, 200, 'returns 200')
|
||||
t.ok(res.text.includes(`href="http://${host}/0x04${chatKey}"`), 'contains link')
|
||||
|
@ -48,24 +48,36 @@ test('test chat key routes', t => {
|
|||
t.ok(res.text.includes(chatName), 'contains chat name')
|
||||
})
|
||||
|
||||
t.test(`/0x04${chatKey.substr(0,8).toUpperCase()}...`, async t => { /* convert upper to lowe case */
|
||||
t.test(`/0x04${chatKey.substr(0,8).toUpperCase()}... - LOWER CASE`, async t => { /* convert upper to lowe case */
|
||||
const res = await get(`/0x04${chatKey.toUpperCase()}`)
|
||||
t.equal(res.statusCode, 200, 'returns 200')
|
||||
t.ok(res.text.includes(`href="http://${host}/0x04${chatKey}"`), 'contains link')
|
||||
t.ok(res.text.includes(`Chat and transact with <span>0x04${chatKey}</span> in Status.`), 'contains prompt')
|
||||
t.ok(res.text.includes(chatName), 'contains chat name')
|
||||
})
|
||||
|
||||
t.test(`/0x04${chatKey.substr(0,8)}...abc - TOO LONG`, async t => { /* error on too long chat key */
|
||||
const res = await get(`/0x04${chatKey}abc`)
|
||||
t.equal(res.statusCode, 400, 'returns 400')
|
||||
t.ok(res.text.includes('Incorrect length of chat key'), 'contains error')
|
||||
})
|
||||
|
||||
t.test(`/0x04${chatKey.substr(0,8)}... - TOO SHORT`, async t => { /* error on too short chat key */
|
||||
const res = await get(`/0x04${chatKey.substr(0,127)}`)
|
||||
t.equal(res.statusCode, 400, 'returns 400')
|
||||
t.ok(res.text.includes('Incorrect length of chat key'), 'contains error')
|
||||
})
|
||||
})
|
||||
|
||||
test('test public channel routes', t => {
|
||||
t.test('/status-test', async t => {
|
||||
t.test('/status-test - VALID', async t => {
|
||||
const res = await get('/status-test')
|
||||
t.equal(res.statusCode, 200, 'returns 200')
|
||||
t.ok(res.text.includes(`href="http://${host}/status-test"`), 'contains link')
|
||||
t.ok(res.text.includes('Join public channel <span>#status-test</span> on Status.'), 'contains prompt')
|
||||
})
|
||||
|
||||
t.test('/staTus-TesT', async t => { /* we don't allow uppercase */
|
||||
t.test('/staTus-TesT - UPPER CASE', async t => { /* we don't allow uppercase */
|
||||
const res = await get('/staTus-TesT')
|
||||
t.equal(res.statusCode, 400, 'returns 400')
|
||||
t.ok(res.text.includes('Upper case channel names are invalid'), 'contains error')
|
||||
|
|
Loading…
Reference in New Issue