]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - test/megaporn_test.rb
f033d5b0aa4e5e62eacc736113db7a651cde0759
[dead/whatever-dl.git] / test / megaporn_test.rb
1 #
2 # Copyright Michael Orlitzky
3 #
4 # http://michael.orlitzky.com/
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # http://www.fsf.org/licensing/licenses/gpl.html
17 #
18
19 require 'test/unit'
20 require 'src/websites/megaporn'
21
22
23 class MegapornTest < Test::Unit::TestCase
24
25 def test_owns_megaporn_urls
26 assert(Megaporn.owns_url?('http://www.megaporn.com/video/?v=E1LROW6E'))
27 end
28
29
30 def test_doesnt_own_infoq_urls
31 assert(!Megaporn.owns_url?('http://www.infoq.com/interviews/jim-weirich-discusses-rake'))
32 end
33
34
35 def test_doesnt_own_redtube_urls
36 assert(!Megaporn.owns_url?('http://www.redtube.com/6807'))
37 assert(!Megaporn.owns_url?('www.redtube.com/6807'))
38 assert(!Megaporn.owns_url?('http://redtube.com/6807'))
39 assert(!Megaporn.owns_url?('redtube.com/6807'))
40 end
41
42
43 def test_doesnt_own_efukt_urls
44 assert(!Megaporn.owns_url?('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.html'))
45 assert(!Megaporn.owns_url?('http://www.efukt.com/2304_The_Dumbest_Porno_Ever_Made.html'))
46 end
47
48
49 def test_decryption
50 mp = Megaporn.new(nil)
51 expected_result = '3de0ae51c90c7b100cc41e899648ac3c'
52 actual_result = mp.send('decrypt', 'becc1abe04b5ab8cb10dc7d29a497958', '49298', '63031')
53 assert_equal(expected_result, actual_result)
54 end
55
56
57 def test_parse_flash_variable
58 mp = Megaporn.new(nil)
59 page_data = nil
60
61 File.open('test/fixtures/megaporn/E1LROW6E.html') do |f|
62 page_data = f.read
63 end
64
65 # Seed
66 expected_result = '71eef99c126511b92b770d654ecd25c8'
67 actual_result = mp.send('parse_flash_variable', page_data, 'un')
68 assert_equal(expected_result, actual_result)
69
70 # key1
71 expected_result = '63233'
72 actual_result = mp.send('parse_flash_variable', page_data, 'k1')
73 assert_equal(expected_result, actual_result)
74
75 # key2
76 expected_result = '185149'
77 actual_result = mp.send('parse_flash_variable', page_data, 'k2')
78 assert_equal(expected_result, actual_result)
79
80 # Host suffix
81 expected_result = '118'
82 actual_result = mp.send('parse_flash_variable', page_data, 's')
83 assert_equal(expected_result, actual_result)
84 end
85
86 end