autumn 3.1.8

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.
Files changed (111) hide show
  1. data/AUTHORS +11 -0
  2. data/CHANGELOG +567 -0
  3. data/MANIFEST +110 -0
  4. data/README +1114 -0
  5. data/README.textile +1153 -0
  6. data/Rakefile +75 -0
  7. data/autumn.gemspec +44 -0
  8. data/bin/autumn +11 -0
  9. data/lib/autumn.rb +8 -0
  10. data/lib/autumn/authentication.rb +238 -0
  11. data/lib/autumn/channel_leaf.rb +107 -0
  12. data/lib/autumn/coder.rb +166 -0
  13. data/lib/autumn/console_boot.rb +10 -0
  14. data/lib/autumn/ctcp.rb +250 -0
  15. data/lib/autumn/daemon.rb +207 -0
  16. data/lib/autumn/datamapper_hacks.rb +290 -0
  17. data/lib/autumn/foliater.rb +231 -0
  18. data/lib/autumn/formatting.rb +236 -0
  19. data/lib/autumn/generator.rb +231 -0
  20. data/lib/autumn/genesis.rb +190 -0
  21. data/lib/autumn/inheritable_attributes.rb +162 -0
  22. data/lib/autumn/leaf.rb +738 -0
  23. data/lib/autumn/log_facade.rb +49 -0
  24. data/lib/autumn/misc.rb +87 -0
  25. data/lib/autumn/resources/daemons/Anothernet.yml +3 -0
  26. data/lib/autumn/resources/daemons/AustHex.yml +29 -0
  27. data/lib/autumn/resources/daemons/Bahamut.yml +67 -0
  28. data/lib/autumn/resources/daemons/Dancer.yml +3 -0
  29. data/lib/autumn/resources/daemons/GameSurge.yml +3 -0
  30. data/lib/autumn/resources/daemons/IRCnet.yml +3 -0
  31. data/lib/autumn/resources/daemons/Ithildin.yml +7 -0
  32. data/lib/autumn/resources/daemons/KineIRCd.yml +56 -0
  33. data/lib/autumn/resources/daemons/PTlink.yml +6 -0
  34. data/lib/autumn/resources/daemons/QuakeNet.yml +20 -0
  35. data/lib/autumn/resources/daemons/RFC1459.yml +158 -0
  36. data/lib/autumn/resources/daemons/RFC2811.yml +16 -0
  37. data/lib/autumn/resources/daemons/RFC2812.yml +36 -0
  38. data/lib/autumn/resources/daemons/RatBox.yml +25 -0
  39. data/lib/autumn/resources/daemons/Ultimate.yml +24 -0
  40. data/lib/autumn/resources/daemons/Undernet.yml +6 -0
  41. data/lib/autumn/resources/daemons/Unreal.yml +110 -0
  42. data/lib/autumn/resources/daemons/_Other.yml +7 -0
  43. data/lib/autumn/resources/daemons/aircd.yml +33 -0
  44. data/lib/autumn/resources/daemons/bdq-ircd.yml +3 -0
  45. data/lib/autumn/resources/daemons/hybrid.yml +38 -0
  46. data/lib/autumn/resources/daemons/ircu.yml +67 -0
  47. data/lib/autumn/resources/daemons/tr-ircd.yml +8 -0
  48. data/lib/autumn/script.rb +74 -0
  49. data/lib/autumn/speciator.rb +165 -0
  50. data/lib/autumn/stem.rb +919 -0
  51. data/lib/autumn/stem_facade.rb +176 -0
  52. data/lib/autumn/tool/bin.rb +301 -0
  53. data/lib/autumn/tool/create.rb +48 -0
  54. data/lib/autumn/tool/project_creator.rb +110 -0
  55. data/lib/autumn/version.rb +3 -0
  56. data/lib/skel/Rakefile +163 -0
  57. data/lib/skel/config/global.yml +2 -0
  58. data/lib/skel/config/seasons/testing/database.yml +4 -0
  59. data/lib/skel/config/seasons/testing/leaves.yml +9 -0
  60. data/lib/skel/config/seasons/testing/season.yml +2 -0
  61. data/lib/skel/config/seasons/testing/stems.yml +10 -0
  62. data/lib/skel/leaves/administrator/README +20 -0
  63. data/lib/skel/leaves/administrator/controller.rb +67 -0
  64. data/lib/skel/leaves/administrator/views/autumn.txt.erb +1 -0
  65. data/lib/skel/leaves/administrator/views/reload.txt.erb +11 -0
  66. data/lib/skel/leaves/insulter/README +17 -0
  67. data/lib/skel/leaves/insulter/controller.rb +65 -0
  68. data/lib/skel/leaves/insulter/views/about.txt.erb +1 -0
  69. data/lib/skel/leaves/insulter/views/help.txt.erb +1 -0
  70. data/lib/skel/leaves/insulter/views/insult.txt.erb +1 -0
  71. data/lib/skel/leaves/scorekeeper/README +34 -0
  72. data/lib/skel/leaves/scorekeeper/config.yml +2 -0
  73. data/lib/skel/leaves/scorekeeper/controller.rb +104 -0
  74. data/lib/skel/leaves/scorekeeper/helpers/general.rb +64 -0
  75. data/lib/skel/leaves/scorekeeper/models/channel.rb +12 -0
  76. data/lib/skel/leaves/scorekeeper/models/person.rb +14 -0
  77. data/lib/skel/leaves/scorekeeper/models/pseudonym.rb +11 -0
  78. data/lib/skel/leaves/scorekeeper/models/score.rb +14 -0
  79. data/lib/skel/leaves/scorekeeper/tasks/stats.rake +17 -0
  80. data/lib/skel/leaves/scorekeeper/views/about.txt.erb +1 -0
  81. data/lib/skel/leaves/scorekeeper/views/change.txt.erb +5 -0
  82. data/lib/skel/leaves/scorekeeper/views/history.txt.erb +11 -0
  83. data/lib/skel/leaves/scorekeeper/views/points.txt.erb +5 -0
  84. data/lib/skel/leaves/scorekeeper/views/usage.txt.erb +1 -0
  85. data/lib/skel/log/README +1 -0
  86. data/lib/skel/script/console +28 -0
  87. data/lib/skel/script/destroy +48 -0
  88. data/lib/skel/script/generate +48 -0
  89. data/lib/skel/shared/README +1 -0
  90. data/lib/skel/tmp/README +1 -0
  91. data/spec/authentication_spec.rb +328 -0
  92. data/spec/channel_leaf_spec.rb +142 -0
  93. data/spec/coder_spec.rb +146 -0
  94. data/spec/ctcp_spec.rb +222 -0
  95. data/spec/daemon_spec.rb +202 -0
  96. data/spec/datamapper_hacks_spec.rb +164 -0
  97. data/tasks/authors.rake +30 -0
  98. data/tasks/changelog.rake +18 -0
  99. data/tasks/copyright.rake +21 -0
  100. data/tasks/doc.rake +7 -0
  101. data/tasks/gem.rake +23 -0
  102. data/tasks/gem_installer.rake +76 -0
  103. data/tasks/install_dependencies.rake +6 -0
  104. data/tasks/manifest.rake +4 -0
  105. data/tasks/rcov.rake +23 -0
  106. data/tasks/release.rake +52 -0
  107. data/tasks/reversion.rake +8 -0
  108. data/tasks/setup.rake +24 -0
  109. data/tasks/spec.rake +7 -0
  110. data/tasks/yard.rake +4 -0
  111. metadata +188 -0
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # == Synopsis
4
+ #
5
+ # Destroys the files for leaves, seasons, and other objects of the Autumn
6
+ # framework.
7
+ #
8
+ # == Usage
9
+ #
10
+ # script/destroy <options> <object> <name>
11
+ #
12
+ # <object>:: The object type to destroy. Valid types are "leaf" and "season".
13
+ # <name>:: The name of the object to destroy. For example, you can call
14
+ # "script/destroy leaf Scorekeeper" to remove a leaf named Scorekeeper.
15
+ #
16
+ # == Options
17
+ #
18
+ # --help, -h:: Displays this usage information.
19
+ # --vcs, -c:: Remove any created files or directories from the project's version
20
+ # control system. (Autodetects CVS and Subversion.)
21
+
22
+ require 'libs/script'
23
+
24
+ opts = GetoptLong.new(
25
+ [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
26
+ [ '--vcs', '-c', GetoptLong::NO_ARGUMENT ]
27
+ )
28
+
29
+ script = Autumn::Script.new
30
+
31
+ begin
32
+ opts.each do |opt, arg|
33
+ case opt
34
+ when '--help' then RDoc::usage
35
+ when '--vcs' then script.use_vcs
36
+ end
37
+ end
38
+ rescue GetoptLong::InvalidOption
39
+ RDoc::usage
40
+ exit 0
41
+ end
42
+
43
+ exit(0) unless script.parse_argv(ARGV)
44
+
45
+ case script.object
46
+ when 'leaf' then script.call_generator(:unleaf)
47
+ when 'season' then script.call_generator(:unseason)
48
+ end
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # == Synopsis
4
+ #
5
+ # Generates template files for leaves, seasons, and other Autumn objects.
6
+ #
7
+ # == Usage
8
+ #
9
+ # script/generate <options> <template> <name>
10
+ #
11
+ # <template>:: The template to create. Valid templates are "leaf" and "season".
12
+ # <name>:: The name to give the created template. For example, you can call
13
+ # "script/generate leaf Scorekeeper" to create a leaf named
14
+ # Scorekeeper.
15
+ #
16
+ # == Options
17
+ #
18
+ # --help, -h:: Displays this usage information.
19
+ # --vcs, -c:: Add any created files or directories to the project's version
20
+ # control system. (Autodetects CVS and Subversion.)
21
+
22
+ require 'libs/script'
23
+
24
+ opts = GetoptLong.new(
25
+ [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
26
+ [ '--vcs', '-c', GetoptLong::NO_ARGUMENT ]
27
+ )
28
+
29
+ script = Autumn::Script.new
30
+
31
+ begin
32
+ opts.each do |opt, arg|
33
+ case opt
34
+ when '--help' then RDoc::usage
35
+ when '--vcs' then script.use_vcs
36
+ end
37
+ end
38
+ rescue GetoptLong::InvalidOption
39
+ RDoc::usage
40
+ exit 0
41
+ end
42
+
43
+ exit(0) unless script.parse_argv(ARGV)
44
+
45
+ case script.object
46
+ when 'leaf' then script.call_generator(:leaf)
47
+ when 'season' then script.call_generator(:season)
48
+ end
@@ -0,0 +1 @@
1
+ shared library files or helpers belong here
@@ -0,0 +1 @@
1
+ temporary files belong here
@@ -0,0 +1,328 @@
1
+ require 'set'
2
+ require 'rubygems'
3
+ require 'facets/string'
4
+
5
+ require 'autumn/authentication'
6
+
7
+ describe Autumn::Authentication::Base do
8
+ it "should raise an exception when initialized" do
9
+ lambda { Autumn::Authentication::Base.new }.should raise_error
10
+ end
11
+
12
+ it "should implement a default unauthorized method" do
13
+ Autumn::Authentication::Base.instance_methods.should include('unauthorized')
14
+ end
15
+ end
16
+
17
+ describe Autumn::Authentication::Op do
18
+ before :each do
19
+ @sender_hash = { :nick => 'Nick', :user => 'User', :host => 'example.com' }
20
+ @stem = Object.new
21
+ end
22
+
23
+ it "should be a subclass of Autumn::Authentication::Base" do
24
+ Autumn::Authentication::Op.ancestors.should include(Autumn::Authentication::Base)
25
+ end
26
+
27
+ describe "with the default options" do
28
+ before :each do
29
+ @auth = Autumn::Authentication::Op.new
30
+ end
31
+
32
+ it "should not authenticate unvoiced channel members" do
33
+ @stem.stub!(:privilege).and_return(:unvoiced)
34
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_false
35
+ end
36
+
37
+ it "should not authenticate voiced channel members" do
38
+ @stem.stub!(:privilege).and_return(:voiced)
39
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_false
40
+ end
41
+
42
+ it "should not authenticate half-ops" do
43
+ @stem.stub!(:privilege).and_return(:halfop)
44
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_false
45
+ end
46
+
47
+ it "should authenticate ops" do
48
+ @stem.stub!(:privilege).and_return(:op)
49
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_true
50
+ end
51
+
52
+ it "should authenticate admins" do
53
+ @stem.stub!(:privilege).and_return(:admin)
54
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_true
55
+ end
56
+
57
+ it "should authenticate owners" do
58
+ @stem.stub!(:privilege).and_return(:channel_owner)
59
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_true
60
+ end
61
+ end
62
+
63
+ describe "with custom options" do
64
+ before :each do
65
+ @auth = Autumn::Authentication::Op.new :privileges => [ :unvoiced, :op ]
66
+ end
67
+
68
+ it "should authenticate unvoiced channel members" do
69
+ @stem.stub!(:privilege).and_return(:unvoiced)
70
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_true
71
+ end
72
+
73
+ it "should not authenticate voiced channel members" do
74
+ @stem.stub!(:privilege).and_return(:voiced)
75
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_false
76
+ end
77
+
78
+ it "should authenticate ops" do
79
+ @stem.stub!(:privilege).and_return(:op)
80
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_true
81
+ end
82
+
83
+ it "should not authenticate admins" do
84
+ @stem.stub!(:privilege).and_return(:admin)
85
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_false
86
+ end
87
+ end
88
+ end
89
+
90
+ describe Autumn::Authentication::Nick do
91
+ it "should raise an exception when initialized with no nicks" do
92
+ lambda { Autumn::Authentication::Nick.new }.should raise_error
93
+ end
94
+
95
+ it "should not raise an exception when initialized with a nick" do
96
+ lambda { Autumn::Authentication::Nick.new :nick => 'Nick' }.should_not raise_error
97
+ end
98
+
99
+ it "should not raise an exception when initialized with an array of nicks" do
100
+ lambda { Autumn::Authentication::Nick.new :nicks => [ 'Nick1', 'Nick2' ] }.should_not raise_error
101
+ end
102
+
103
+ describe "initialized with a single nick" do
104
+ before :each do
105
+ @auth = Autumn::Authentication::Nick.new(:nick => 'Nick2')
106
+ end
107
+
108
+ it "should authenticate an authorized nick" do
109
+ @auth.authenticate(nil, nil, { :nick => 'Nick2' }, nil).should be_true
110
+ end
111
+
112
+ it "should not authenticate an unauthorized nick" do
113
+ @auth.authenticate(nil, nil, { :nick => 'Nick3' }, nil).should be_false
114
+ end
115
+ end
116
+
117
+ describe "initialized with multiple nicks" do
118
+ before :each do
119
+ @auth = Autumn::Authentication::Nick.new(:nicks => [ 'Nick1', 'Nick2' ])
120
+ end
121
+
122
+ it "should authenticate an authorized nick" do
123
+ @auth.authenticate(nil, nil, { :nick => 'Nick2' }, nil).should be_true
124
+ end
125
+
126
+ it "should not authenticate an unauthorized nick" do
127
+ @auth.authenticate(nil, nil, { :nick => 'Nick3' }, nil).should be_false
128
+ end
129
+ end
130
+ end
131
+
132
+ describe Autumn::Authentication::Hostname do
133
+ it "should raise an exception when initialized with no hosts" do
134
+ lambda { Autumn::Authentication::Hostname.new }.should raise_error
135
+ end
136
+
137
+ it "should not raise an exception when initialized with a host" do
138
+ lambda { Autumn::Authentication::Hostname.new :host => 'host1.com' }.should_not raise_error
139
+ end
140
+
141
+ it "should not raise an exception when initialized with an array of hosts" do
142
+ lambda { Autumn::Authentication::Hostname.new :hosts => [ 'host1.com', 'host2.com' ] }.should_not raise_error
143
+ end
144
+
145
+ describe "with the default hostmask" do
146
+ describe "initialized with a single host" do
147
+ before :each do
148
+ @auth = Autumn::Authentication::Hostname.new(:host => 'ca.host1.com')
149
+ end
150
+
151
+ it "should authenticate an authorized host" do
152
+ @auth.authenticate(nil, nil, { :host => 'wsd1.ca.host1.com' }, nil).should be_true
153
+ end
154
+
155
+ it "should not authenticate an unauthorized host" do
156
+ @auth.authenticate(nil, nil, { :host => 'unauthorized' }, nil).should be_false
157
+ end
158
+ end
159
+
160
+ describe "initialized with multiple hosts" do
161
+ before :each do
162
+ @auth = Autumn::Authentication::Hostname.new(:hosts => [ 'host1.com', 'ca.host2.com' ])
163
+ end
164
+
165
+ it "should authenticate an authorized host" do
166
+ @auth.authenticate(nil, nil, { :host => 'wsd1.ca.host2.com' }, nil).should be_true
167
+ end
168
+
169
+ it "should not authenticate an unauthorized host" do
170
+ @auth.authenticate(nil, nil, { :host => 'unauthorized' }, nil).should be_false
171
+ end
172
+ end
173
+ end
174
+
175
+ describe "with custom String hostmask" do
176
+ before :each do
177
+ @auth = Autumn::Authentication::Hostname.new(:hosts => [ '1', '2' ], :hostmask => 'host(\d)\.com')
178
+ end
179
+
180
+ it "should authenticate an authorized host" do
181
+ @auth.authenticate(nil, nil, { :host => 'host2.com' }, nil).should be_true
182
+ end
183
+
184
+ it "should not authenticate an unauthorized host" do
185
+ @auth.authenticate(nil, nil, { :host => 'host3.com' }, nil).should be_false
186
+ end
187
+ end
188
+
189
+ describe "with custom Regexp hostmask" do
190
+ before :each do
191
+ @auth = Autumn::Authentication::Hostname.new(:hosts => [ '1', '2' ], :hostmask => /host(\d)\.com/)
192
+ end
193
+
194
+ it "should authenticate an authorized host" do
195
+ @auth.authenticate(nil, nil, { :host => 'host2.com' }, nil).should be_true
196
+ end
197
+
198
+ it "should not authenticate an unauthorized host" do
199
+ @auth.authenticate(nil, nil, { :host => 'host3.com' }, nil).should be_false
200
+ end
201
+ end
202
+
203
+ describe "with custom Proc hostmask" do
204
+ before :each do
205
+ @auth = Autumn::Authentication::Hostname.new(:host => 'com', :hostmask => Proc.new { |h| h.split('.').last })
206
+ end
207
+
208
+ it "should authenticate an authorized host" do
209
+ @auth.authenticate(nil, nil, { :host => 'host.com' }, nil).should be_true
210
+ end
211
+
212
+ it "should not authenticate an unauthorized host" do
213
+ @auth.authenticate(nil, nil, { :host => 'host.net' }, nil).should be_false
214
+ end
215
+ end
216
+ end
217
+
218
+ describe Autumn::Authentication::Password do
219
+ it "should raise an error when initialized without a password" do
220
+ lambda { Autumn::Authentication::Password.new }.should raise_error
221
+ end
222
+
223
+ it "should not raise an error when initialized with a default expire time" do
224
+ lambda { Autumn::Authentication::Password.new :password => 'abc123' }.should_not raise_error
225
+ end
226
+
227
+ describe "initialized with a password and custom expire time" do
228
+ before :each do
229
+ @sender_hash = { :nick => 'Nick' }
230
+ @auth = Autumn::Authentication::Password.new :password => 'abc123', :expire_time => 5
231
+ end
232
+
233
+ it "should not authenticate any nicks" do
234
+ @auth.authenticate(Object.new, '#channel', @sender_hash, nil).should be_false
235
+ end
236
+
237
+ it "should, when given a private message with the correct password, respond with a confirmation" do
238
+ @stem = mock('stem')
239
+ @stem.should_receive(:message).once.with("Your password has been accepted, and you are now authorized.", @sender_hash[:nick])
240
+ @auth.irc_privmsg_event(@stem, @sender_hash, :message => 'abc123', :recipient => 'Bot')
241
+ end
242
+
243
+ it "should not, when given a private message without the correct password, respond with a confirmation" do
244
+ @stem = mock('stem')
245
+ @stem.should_not_receive(:message).with("Your password has been accepted, and you are now authorized.", @sender_hash[:nick])
246
+ @auth.irc_privmsg_event(@stem, @sender_hash, :message => 'abc123x', :recipient => 'Bot')
247
+ end
248
+
249
+ describe "given the correct password" do
250
+ before :each do
251
+ @stem = Object.new
252
+ @stem.stub!(:message).and_return
253
+ @auth.irc_privmsg_event(@stem, @sender_hash, :message => 'abc123', :recipient => 'Bot')
254
+ end
255
+
256
+ it "should authenticate that nick on that stem" do
257
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_true
258
+ end
259
+
260
+ it "should not authenticate that nick on a different stem" do
261
+ @auth.authenticate(Object.new, '#channel', @sender_hash, nil).should be_false
262
+ end
263
+
264
+ it "should not authenticate a different nick" do
265
+ @auth.authenticate(@stem, '#channel', { :nick => 'OtherNick' }, nil).should be_false
266
+ end
267
+
268
+ it "should not authenticate if the owner changes his nick" do
269
+ @auth.irc_nick_event(@stem, @sender_hash, :nick => 'NewNick')
270
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_false
271
+ end
272
+
273
+ it "should not authenticate if someone else takes the nick" do
274
+ @auth.irc_nick_event(@stem, { :nick => 'OldNick' }, { :nick => 'Nick' })
275
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_false
276
+ end
277
+
278
+ it "should authenticate if the owner changes his nick on a different stem" do
279
+ @auth.irc_nick_event(Object.new, @sender_hash, :nick => 'NewNick')
280
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_true
281
+ end
282
+
283
+ it "should authenticate if someone else takes the nick on a different stem" do
284
+ @auth.irc_nick_event(Object.new, { :nick => 'OldNick' }, { :nick => 'Nick' })
285
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_true
286
+ end
287
+
288
+ it "should not authenticate if the nick is kicked" do
289
+ @auth.irc_kick_event(@stem, {}, :nick => 'Nick')
290
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_false
291
+ end
292
+
293
+ it "should authenticate if the nick is kicked on a different stem" do
294
+ @auth.irc_kick_event(Object.new, {}, :nick => 'Nick')
295
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_true
296
+ end
297
+
298
+ it "should not authenticate if the nick quits" do
299
+ @auth.irc_quit_event(@stem, @sender_hash, {})
300
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_false
301
+ end
302
+
303
+ it "should authenticate if the nick quits on a different stem" do
304
+ @auth.irc_quit_event(Object.new, @sender_hash, {})
305
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_true
306
+ end
307
+
308
+ it "should revoke the credential after the expire time has passed" do
309
+ sleep 6
310
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_false
311
+ end
312
+
313
+ it "should reset the expire time if a protected command is run" do
314
+ sleep 4
315
+ @auth.authenticate @stem, '#channel', @sender_hash, nil
316
+ sleep 2
317
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_true
318
+ end
319
+
320
+ it "... and then revoke the credential after the expire time" do
321
+ sleep 4
322
+ @auth.authenticate @stem, '#channel', @sender_hash, nil
323
+ sleep 6
324
+ @auth.authenticate(@stem, '#channel', @sender_hash, nil).should be_false
325
+ end
326
+ end
327
+ end
328
+ end
@@ -0,0 +1,142 @@
1
+ require 'logger'
2
+ require 'set'
3
+
4
+ require 'autumn'
5
+ require 'autumn/genesis'
6
+
7
+ gen = Autumn::Genesis.new
8
+ gen.load_libraries
9
+ gen.load_daemon_info
10
+
11
+ describe Autumn::ChannelLeaf do
12
+ before :all do
13
+ #TODO how do we stub these methods?
14
+ Autumn::Leaf.class_eval do
15
+ def irc_privmsg_event(*args); true; end
16
+ def irc_join_event(*args); true; end
17
+ def irc_part_event(*args); true; end
18
+ def irc_mode_event(*args); true; end
19
+ def irc_topic_event(*args); true; end
20
+ def irc_invite_event(*args); true; end
21
+ def irc_kick_event(*args); true; end
22
+ def irc_notice_event(*args); true; end
23
+ end
24
+ end
25
+
26
+ before :each do
27
+ @logger = Autumn::LogFacade.new Logger.new(STDOUT), 'Leaf', 'Channel Leaf Spec'
28
+ @stem = Autumn::Stem.new('irc.mockserver.com', 'MockStem', { :channels => [ '#listening', '#notlistening' ]})
29
+ Autumn::Foliater.instance.stems['Mock'] = @stem
30
+ @sender_hash = { :nick => 'nick', :host => 'ca.us.host.com', :user => 'user' }
31
+ end
32
+
33
+ describe "with a valid stem" do
34
+ before :each do
35
+ @leaf = Autumn::ChannelLeaf.new :logger => @logger, :channels => { 'Mock' => [ '#listening' ] }
36
+ end
37
+
38
+ it "should not raise an exception on startup" do
39
+ lambda { @leaf.will_start_up }.should_not raise_error(RuntimeError, "Unknown stem MockStem")
40
+ end
41
+
42
+ describe "that has started up" do
43
+ before :each do
44
+ @leaf.will_start_up
45
+ end
46
+
47
+ it "should notice PRIVMSGs on channels it is listening to" do
48
+ @leaf.irc_privmsg_event(@stem, @sender_hash, { :channel => '#listening', :message => 'message' }).should equal(true)
49
+ end
50
+
51
+ it "should not notice PRIVMSGs on channels it is not listening to" do
52
+ @leaf.irc_privmsg_event(@stem, @sender_hash, { :channel => '#notlistening', :message => 'message' }).should_not equal(true)
53
+ end
54
+
55
+ it "should notice PRIVMSGs to itself" do
56
+ @leaf.irc_privmsg_event(@stem, @sender_hash, { :recipient => 'MockStem', :message => 'message' }).should equal(true)
57
+ end
58
+
59
+ it "should notice JOINs on channels it is listening to" do
60
+ @leaf.irc_join_event(@stem, @sender_hash, { :channel => '#listening' }).should equal(true)
61
+ end
62
+
63
+ it "should not notice JOINs on channels it is not listening to" do
64
+ @leaf.irc_join_event(@stem, @sender_hash, { :channel => '#notlistening' }).should_not equal(true)
65
+ end
66
+
67
+ it "should notice PARTs on channels it is listening to" do
68
+ @leaf.irc_part_event(@stem, @sender_hash, { :channel => '#listening' }).should equal(true)
69
+ end
70
+
71
+ it "should not notice PARTs on channels it is not listening to" do
72
+ @leaf.irc_part_event(@stem, @sender_hash, { :channel => '#notlistening' }).should_not equal(true)
73
+ end
74
+
75
+ it "should notice MODEs on channels it is listening to" do
76
+ @leaf.irc_mode_event(@stem, @sender_hash, { :channel => '#listening' }).should equal(true)
77
+ end
78
+
79
+ it "should not notice MODEs on channels it is not listening to" do
80
+ @leaf.irc_mode_event(@stem, @sender_hash, { :channel => '#notlistening' }).should_not equal(true)
81
+ end
82
+
83
+ it "should notice MODE changes to iself" do
84
+ @leaf.irc_mode_event(@stem, @sender_hash, { :recipient => 'MockStem', :message => 'message' }).should equal(true)
85
+ end
86
+
87
+ it "should notice TOPICs on channels it is listening to" do
88
+ @leaf.irc_topic_event(@stem, @sender_hash, { :channel => '#listening' }).should equal(true)
89
+ end
90
+
91
+ it "should not notice TOPICs on channels it is not listening to" do
92
+ @leaf.irc_topic_event(@stem, @sender_hash, { :channel => '#notlistening' }).should_not equal(true)
93
+ end
94
+
95
+ it "should notice INVITEs on channels it is listening to" do
96
+ @leaf.irc_invite_event(@stem, @sender_hash, { :channel => '#listening' }).should equal(true)
97
+ end
98
+
99
+ it "should not notice INVITEs on channels it is not listening to" do
100
+ @leaf.irc_invite_event(@stem, @sender_hash, { :channel => '#notlistening' }).should_not equal(true)
101
+ end
102
+
103
+ it "should not notice INVITEs to me to channels I am not listening to" do
104
+ @leaf.irc_invite_event(@stem, @sender_hash, { :recipient => 'MockStem', :channel => '#notlistening' }).should_not equal(true)
105
+ end
106
+
107
+ it "should notice INVITEs to me to channels I am not a part of" do
108
+ @leaf.irc_invite_event(@stem, @sender_hash, { :recipient => 'MockStem', :channel => '#notamember' }).should equal(true)
109
+ end
110
+
111
+ it "should notice KICKs on channels it is listening to" do
112
+ @leaf.irc_kick_event(@stem, @sender_hash, { :channel => '#listening' }).should equal(true)
113
+ end
114
+
115
+ it "should not notice KICKs on channels it is not listening to" do
116
+ @leaf.irc_notice_event(@stem, @sender_hash, { :channel => '#notlistening' }).should_not equal(true)
117
+ end
118
+
119
+ it "should notice NOTICEs on channels it is listening to" do
120
+ @leaf.irc_notice_event(@stem, @sender_hash, { :channel => '#listening' }).should equal(true)
121
+ end
122
+
123
+ it "should not notice NOTICEs on channels it is not listening to" do
124
+ @leaf.irc_notice_event(@stem, @sender_hash, { :channel => '#notlistening' }).should_not equal(true)
125
+ end
126
+
127
+ it "should notice NOTICEs to itself" do
128
+ @leaf.irc_notice_event(@stem, @sender_hash, { :recipient => 'MockStem', :message => 'message' }).should equal(true)
129
+ end
130
+ end
131
+ end
132
+
133
+ describe "with an invalid stem" do
134
+ before :each do
135
+ @leaf = Autumn::ChannelLeaf.new :logger => @logger, :channels => { 'Nonexistent' => [ '#listening' ] }
136
+ end
137
+
138
+ it "should raise an exception on startup" do
139
+ lambda { @leaf.will_start_up }.should raise_error(RuntimeError, "Unknown stem Nonexistent")
140
+ end
141
+ end
142
+ end