rubyforge 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +37 -15
- data/Manifest.txt +0 -2
- data/README.txt +2 -5
- data/Rakefile +15 -16
- data/bin/rubyforge +20 -35
- data/lib/rubyforge/client.rb +22 -36
- data/lib/rubyforge.rb +79 -181
- data/test/test_rubyforge.rb +136 -197
- data/test/test_rubyforge_client.rb +2 -67
- metadata +17 -8
- data/lib/rubyforge/cookie_manager.rb +0 -60
- data/test/test_rubyforge_cookie_manager.rb +0 -97
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
require 'test/unit' unless defined? $ZENTEST and $ZENTEST
|
|
2
|
-
require 'rubyforge'
|
|
3
|
-
require 'time'
|
|
4
|
-
require 'yaml'
|
|
5
|
-
require 'tempfile'
|
|
6
|
-
|
|
7
|
-
class TestRubyForgeCookieManager < Test::Unit::TestCase
|
|
8
|
-
def setup
|
|
9
|
-
cookie = cookie_string('session_ser', 'zzzzzzzzzzzzzzzzzz')
|
|
10
|
-
@url = URI.parse('http://rubyforge.org/account/login.php')
|
|
11
|
-
@cookie = WEBrick::Cookie.parse_set_cookie(cookie)
|
|
12
|
-
@manager = RubyForge::CookieManager.new
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def test_empty?
|
|
16
|
-
manager = RubyForge::CookieManager.new
|
|
17
|
-
assert(manager.empty?)
|
|
18
|
-
|
|
19
|
-
assert_equal(0, manager[URI.parse('http://rubyforge.org/')].length)
|
|
20
|
-
assert(manager.empty?)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def test_add
|
|
24
|
-
manager = RubyForge::CookieManager.new
|
|
25
|
-
assert(manager.empty?)
|
|
26
|
-
manager.add(@url, @cookie)
|
|
27
|
-
assert(!manager.empty?)
|
|
28
|
-
|
|
29
|
-
cookie = manager[@url][@cookie.name]
|
|
30
|
-
assert cookie
|
|
31
|
-
assert_equal(@cookie.object_id, cookie.object_id)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def test_add_expired_cookie
|
|
35
|
-
cookie = cookie_string('session_ser', 'zzzz',
|
|
36
|
-
:expires => (Time.now - 10).strftime('%A, %d-%b-%Y %H:%M:%S %Z'))
|
|
37
|
-
cookie = WEBrick::Cookie.parse_set_cookie(cookie)
|
|
38
|
-
|
|
39
|
-
manager = RubyForge::CookieManager.new
|
|
40
|
-
assert(manager.empty?)
|
|
41
|
-
manager.add(@url, cookie)
|
|
42
|
-
assert(manager.empty?)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def test_marshal
|
|
46
|
-
@manager.add(@url, @cookie)
|
|
47
|
-
assert(!@manager.empty?)
|
|
48
|
-
m = YAML.load(YAML.dump(@manager))
|
|
49
|
-
assert(!m.empty?)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def test_save!
|
|
53
|
-
tmp = Tempfile.new('cookie_jar')
|
|
54
|
-
@manager.cookies_file = tmp.path
|
|
55
|
-
@manager.add(@url, @cookie)
|
|
56
|
-
@manager.save!
|
|
57
|
-
|
|
58
|
-
@manager = RubyForge::CookieManager.load(tmp.path)
|
|
59
|
-
assert(! @manager.empty?)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def test_load_empty_file
|
|
63
|
-
tmp = Tempfile.new('cookie_jar')
|
|
64
|
-
manager = RubyForge::CookieManager.load(tmp.path)
|
|
65
|
-
assert(manager.empty?)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def test_load_legacy_file
|
|
69
|
-
tmp = Tempfile.new('cookie_jar')
|
|
70
|
-
tmp.write([
|
|
71
|
-
'https://rubyforge.org/account/login.php',
|
|
72
|
-
'session_ser',
|
|
73
|
-
'zzzzzz',
|
|
74
|
-
'123456',
|
|
75
|
-
'.rubyforge.org',
|
|
76
|
-
'/',
|
|
77
|
-
'13'
|
|
78
|
-
].join("\t"))
|
|
79
|
-
manager = RubyForge::CookieManager.load(tmp.path)
|
|
80
|
-
assert(manager.empty?)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def test_cookies_file=
|
|
84
|
-
tmp = Tempfile.new('cookie_jar')
|
|
85
|
-
@manager.cookies_file = tmp.path
|
|
86
|
-
assert(@manager.empty?)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def cookie_string(name, value, options = {})
|
|
90
|
-
options = {
|
|
91
|
-
:expires => (Time.now + 86400).strftime('%A, %d-%b-%Y %H:%M:%S %Z'),
|
|
92
|
-
:path => '/',
|
|
93
|
-
:domain => '.rubyforge.org',
|
|
94
|
-
}.merge(options)
|
|
95
|
-
"#{name}=#{value}; #{options.map { |o| o.join('=') }.join('; ')}"
|
|
96
|
-
end
|
|
97
|
-
end
|