diff options
author | Allan Wang <me@allanwang.ca> | 2017-12-26 03:37:32 -0500 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-12-26 03:39:28 -0500 |
commit | 1769dbcef9786b847ffeaebdf6ecced45da9222c (patch) | |
tree | 50f543469607b608c0b62ca8a63c6a65325802b9 /app/src/test/kotlin/com/pitchedapps/frost/facebook/FbRegexTest.kt | |
parent | 8080d43dbd9a6863fadb86594b179d0919d6215b (diff) | |
download | frost-1769dbcef9786b847ffeaebdf6ecced45da9222c.tar.gz frost-1769dbcef9786b847ffeaebdf6ecced45da9222c.tar.bz2 frost-1769dbcef9786b847ffeaebdf6ecced45da9222c.zip |
Enhancement/fb requests (#575)v1.7.2
* Update lambdas to references
* Simplify regex and parsers
* Fix some parsing and add more tests
* Improve message parser and tests
* Simplify parser
* Shorten interfaces
* Push rem
* Create notification parser
* Clean up notification service
* Clean up notification service
* Add safe cookie fallback
* Fix cookie reference
* Make parsers only hold cookie string
* Clean up cookie references
* Fix up login and event theme
* Update changelog
Remove workspace backup
Diffstat (limited to 'app/src/test/kotlin/com/pitchedapps/frost/facebook/FbRegexTest.kt')
-rw-r--r-- | app/src/test/kotlin/com/pitchedapps/frost/facebook/FbRegexTest.kt | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbRegexTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbRegexTest.kt new file mode 100644 index 00000000..a21bcb13 --- /dev/null +++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbRegexTest.kt @@ -0,0 +1,41 @@ +package com.pitchedapps.frost.facebook + +import org.apache.commons.text.StringEscapeUtils +import org.junit.Test +import kotlin.test.assertEquals + +/** + * Created by Allan Wang on 24/12/17. + */ +class FbRegexTest { + @Test + fun userIdRegex() { + val id = 12349876L + val cookie = "wd=1366x615; c_user=$id; act=1234%2F12; m_pixel_ratio=1; presence=hello; x-referer=asdfasdf" + assertEquals(id, FB_USER_MATCHER.find(cookie)[1]?.toLong()) + } + + @Test + fun fbDtsgRegex() { + val fb_dtsg = "readme" + val input = "data-sigil=\"mbasic_inline_feed_composer\">\u003Cinput type=\"hidden\" name=\"fb_dtsg\" value=\"$fb_dtsg\" autocomplete=\"off\" \\/>\u003Cinput type=\"hidden\" name=\"privacyx\" value=\"12345\"" + assertEquals(fb_dtsg, FB_DTSG_MATCHER.find(input)[1]) + } + + @Test + fun ppRegex() { + val img = "https\\3a //scontent-yyz1-1.xx.fbcdn.net/v/asdf1234.jpg?efg\\3d 333\\26 oh\\3d 77\\26 oe\\3d 444" + val ppStyle = "background:#d8dce6 url('$img') no-repeat center;background-size:100% 100%;-webkit-background-size:100% 100%;width:58px;height:58px;" + assertEquals(StringEscapeUtils.unescapeCsv(img), StringEscapeUtils.unescapeCsv(FB_CSS_URL_MATCHER.find(ppStyle)[1])) + } + + @Test + fun msgNotifIdRegex() { + val id = 1273491646093428L + val data = "threadlist_row_other_user_fbid_thread_fbid_$id" + assertEquals(id, FB_MESSAGE_NOTIF_ID_MATCHER.find(data)[1]?.toLong(), "thread_fbid mismatch") + val userData = "threadlist_row_other_user_fbid_${id}thread_fbid_" + assertEquals(id, FB_MESSAGE_NOTIF_ID_MATCHER.find(userData)[1]?.toLong(), "user_fbid mismatch") + + } +}
\ No newline at end of file |