bougyman-autumn 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +11 -0
- data/CHANGELOG +511 -0
- data/MANIFEST +109 -0
- data/README +1141 -0
- data/README.textile +1175 -0
- data/Rakefile +75 -0
- data/autumn.gemspec +43 -0
- data/bin/autumn +11 -0
- data/lib/autumn/authentication.rb +238 -0
- data/lib/autumn/channel_leaf.rb +107 -0
- data/lib/autumn/coder.rb +166 -0
- data/lib/autumn/console_boot.rb +10 -0
- data/lib/autumn/ctcp.rb +250 -0
- data/lib/autumn/daemon.rb +207 -0
- data/lib/autumn/datamapper_hacks.rb +290 -0
- data/lib/autumn/foliater.rb +231 -0
- data/lib/autumn/formatting.rb +236 -0
- data/lib/autumn/generator.rb +231 -0
- data/lib/autumn/genesis.rb +190 -0
- data/lib/autumn/inheritable_attributes.rb +162 -0
- data/lib/autumn/leaf.rb +738 -0
- data/lib/autumn/log_facade.rb +49 -0
- data/lib/autumn/misc.rb +87 -0
- data/lib/autumn/resources/daemons/Anothernet.yml +3 -0
- data/lib/autumn/resources/daemons/AustHex.yml +29 -0
- data/lib/autumn/resources/daemons/Bahamut.yml +67 -0
- data/lib/autumn/resources/daemons/Dancer.yml +3 -0
- data/lib/autumn/resources/daemons/GameSurge.yml +3 -0
- data/lib/autumn/resources/daemons/IRCnet.yml +3 -0
- data/lib/autumn/resources/daemons/Ithildin.yml +7 -0
- data/lib/autumn/resources/daemons/KineIRCd.yml +56 -0
- data/lib/autumn/resources/daemons/PTlink.yml +6 -0
- data/lib/autumn/resources/daemons/QuakeNet.yml +20 -0
- data/lib/autumn/resources/daemons/RFC1459.yml +158 -0
- data/lib/autumn/resources/daemons/RFC2811.yml +16 -0
- data/lib/autumn/resources/daemons/RFC2812.yml +36 -0
- data/lib/autumn/resources/daemons/RatBox.yml +25 -0
- data/lib/autumn/resources/daemons/Ultimate.yml +24 -0
- data/lib/autumn/resources/daemons/Undernet.yml +6 -0
- data/lib/autumn/resources/daemons/Unreal.yml +110 -0
- data/lib/autumn/resources/daemons/_Other.yml +7 -0
- data/lib/autumn/resources/daemons/aircd.yml +33 -0
- data/lib/autumn/resources/daemons/bdq-ircd.yml +3 -0
- data/lib/autumn/resources/daemons/hybrid.yml +38 -0
- data/lib/autumn/resources/daemons/ircu.yml +67 -0
- data/lib/autumn/resources/daemons/tr-ircd.yml +8 -0
- data/lib/autumn/script.rb +74 -0
- data/lib/autumn/speciator.rb +165 -0
- data/lib/autumn/stem.rb +919 -0
- data/lib/autumn/stem_facade.rb +176 -0
- data/lib/autumn/tool/bin.rb +302 -0
- data/lib/autumn/tool/create.rb +48 -0
- data/lib/autumn/tool/project_creator.rb +110 -0
- data/lib/autumn/version.rb +3 -0
- data/lib/autumn.rb +6 -0
- data/lib/skel/Rakefile +135 -0
- data/lib/skel/config/global.yml +2 -0
- data/lib/skel/config/seasons/testing/database.yml +4 -0
- data/lib/skel/config/seasons/testing/leaves.yml +9 -0
- data/lib/skel/config/seasons/testing/season.yml +2 -0
- data/lib/skel/config/seasons/testing/stems.yml +10 -0
- data/lib/skel/leaves/administrator/README +20 -0
- data/lib/skel/leaves/administrator/controller.rb +67 -0
- data/lib/skel/leaves/administrator/views/autumn.txt.erb +1 -0
- data/lib/skel/leaves/administrator/views/reload.txt.erb +11 -0
- data/lib/skel/leaves/insulter/README +17 -0
- data/lib/skel/leaves/insulter/controller.rb +65 -0
- data/lib/skel/leaves/insulter/views/about.txt.erb +1 -0
- data/lib/skel/leaves/insulter/views/help.txt.erb +1 -0
- data/lib/skel/leaves/insulter/views/insult.txt.erb +1 -0
- data/lib/skel/leaves/scorekeeper/README +34 -0
- data/lib/skel/leaves/scorekeeper/config.yml +2 -0
- data/lib/skel/leaves/scorekeeper/controller.rb +104 -0
- data/lib/skel/leaves/scorekeeper/helpers/general.rb +64 -0
- data/lib/skel/leaves/scorekeeper/models/channel.rb +12 -0
- data/lib/skel/leaves/scorekeeper/models/person.rb +14 -0
- data/lib/skel/leaves/scorekeeper/models/pseudonym.rb +11 -0
- data/lib/skel/leaves/scorekeeper/models/score.rb +14 -0
- data/lib/skel/leaves/scorekeeper/tasks/stats.rake +17 -0
- data/lib/skel/leaves/scorekeeper/views/about.txt.erb +1 -0
- data/lib/skel/leaves/scorekeeper/views/change.txt.erb +5 -0
- data/lib/skel/leaves/scorekeeper/views/history.txt.erb +11 -0
- data/lib/skel/leaves/scorekeeper/views/points.txt.erb +5 -0
- data/lib/skel/leaves/scorekeeper/views/usage.txt.erb +1 -0
- data/lib/skel/log/README +1 -0
- data/lib/skel/script/console +28 -0
- data/lib/skel/script/destroy +48 -0
- data/lib/skel/script/generate +48 -0
- data/lib/skel/shared/README +1 -0
- data/lib/skel/tmp/README +1 -0
- data/spec/authentication_spec.rb +328 -0
- data/spec/channel_leaf_spec.rb +141 -0
- data/spec/coder_spec.rb +146 -0
- data/spec/ctcp_spec.rb +222 -0
- data/spec/daemon_spec.rb +202 -0
- data/spec/datamapper_hacks_spec.rb +164 -0
- data/tasks/authors.rake +30 -0
- data/tasks/bacon.rake +66 -0
- data/tasks/changelog.rake +18 -0
- data/tasks/copyright.rake +21 -0
- data/tasks/gem.rake +23 -0
- data/tasks/gem_installer.rake +76 -0
- data/tasks/install_dependencies.rake +6 -0
- data/tasks/manifest.rake +4 -0
- data/tasks/rcov.rake +23 -0
- data/tasks/release.rake +52 -0
- data/tasks/reversion.rake +8 -0
- data/tasks/setup.rake +24 -0
- data/tasks/yard.rake +4 -0
- metadata +187 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
<% if var(:no_history) %>
|
2
|
+
<%= var :person %> is not a part of the scoring system.
|
3
|
+
<% elsif var(:no_giver_history) %>
|
4
|
+
<%= var :giver %> has not awarded any points to <%= var(:receiver).name %>.
|
5
|
+
<% elsif var(:scores).empty? %>
|
6
|
+
<%= var(:receiver).name %> has no points history.
|
7
|
+
<% else %>
|
8
|
+
<% var(:scores).each do |score| %>
|
9
|
+
[<%= score.created_at.strftime '%m/%d %I:%M %p' %>] <%= score.giver.name %> <%= score.change > 0 ? 'gave' : 'docked' %> <%= score.receiver.name %> <%= score.change.abs.pluralize('point') %><% if score.note %>: <%= score.note %><% end %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Examples: "!points", "!points Sancho +5", "!points Smith history", "!points Sancho history 2/27/08", "!points Sancho history Smith"
|
data/lib/skel/log/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
logs go in this directory
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Launches an IRb console with the Autumn environment loaded.
|
4
|
+
|
5
|
+
AL_ROOT = File.expand_path("#{File.dirname(__FILE__)}/..")
|
6
|
+
Dir.chdir AL_ROOT
|
7
|
+
|
8
|
+
# Some code below is from Ruby on Rails and copyright (c) David Heinemeier
|
9
|
+
# Hansson.
|
10
|
+
|
11
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
12
|
+
|
13
|
+
require 'optparse'
|
14
|
+
options = { :irb => irb }
|
15
|
+
OptionParser.new do |opt|
|
16
|
+
opt.banner = "Usage: #{File.basename(__FILE__)} [options]"
|
17
|
+
opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |v| options[:irb] = v }
|
18
|
+
opt.parse!(ARGV)
|
19
|
+
end
|
20
|
+
|
21
|
+
libs = " -r irb/completion"
|
22
|
+
libs << " -r autumn"
|
23
|
+
libs << " -r autumn/console_boot"
|
24
|
+
|
25
|
+
require "autumn"
|
26
|
+
ENV["AUTUMN_ROOT"] = AL_ROOT
|
27
|
+
puts "Loading Autumn #{Autumn::Version} in #{AL_ROOT} ..."
|
28
|
+
exec "#{options[:irb]} #{libs}"
|
@@ -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
|
data/lib/skel/tmp/README
ADDED
@@ -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 'libs/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,141 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'set'
|
3
|
+
|
4
|
+
require 'libs/genesis'
|
5
|
+
|
6
|
+
gen = Autumn::Genesis.new
|
7
|
+
gen.load_libraries
|
8
|
+
gen.load_daemon_info
|
9
|
+
|
10
|
+
describe Autumn::ChannelLeaf do
|
11
|
+
before :all do
|
12
|
+
#TODO how do we stub these methods?
|
13
|
+
Autumn::Leaf.class_eval do
|
14
|
+
def irc_privmsg_event(*args); true; end
|
15
|
+
def irc_join_event(*args); true; end
|
16
|
+
def irc_part_event(*args); true; end
|
17
|
+
def irc_mode_event(*args); true; end
|
18
|
+
def irc_topic_event(*args); true; end
|
19
|
+
def irc_invite_event(*args); true; end
|
20
|
+
def irc_kick_event(*args); true; end
|
21
|
+
def irc_notice_event(*args); true; end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
before :each do
|
26
|
+
@logger = Autumn::LogFacade.new Logger.new(STDOUT), 'Leaf', 'Channel Leaf Spec'
|
27
|
+
@stem = Autumn::Stem.new('irc.mockserver.com', 'MockStem', { :channels => [ '#listening', '#notlistening' ]})
|
28
|
+
Autumn::Foliater.instance.stems['Mock'] = @stem
|
29
|
+
@sender_hash = { :nick => 'nick', :host => 'ca.us.host.com', :user => 'user' }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "with a valid stem" do
|
33
|
+
before :each do
|
34
|
+
@leaf = Autumn::ChannelLeaf.new :logger => @logger, :channels => { 'Mock' => [ '#listening' ] }
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should not raise an exception on startup" do
|
38
|
+
lambda { @leaf.will_start_up }.should_not raise_error(RuntimeError, "Unknown stem MockStem")
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "that has started up" do
|
42
|
+
before :each do
|
43
|
+
@leaf.will_start_up
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should notice PRIVMSGs on channels it is listening to" do
|
47
|
+
@leaf.irc_privmsg_event(@stem, @sender_hash, { :channel => '#listening', :message => 'message' }).should equal(true)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should not notice PRIVMSGs on channels it is not listening to" do
|
51
|
+
@leaf.irc_privmsg_event(@stem, @sender_hash, { :channel => '#notlistening', :message => 'message' }).should_not equal(true)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should notice PRIVMSGs to itself" do
|
55
|
+
@leaf.irc_privmsg_event(@stem, @sender_hash, { :recipient => 'MockStem', :message => 'message' }).should equal(true)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should notice JOINs on channels it is listening to" do
|
59
|
+
@leaf.irc_join_event(@stem, @sender_hash, { :channel => '#listening' }).should equal(true)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should not notice JOINs on channels it is not listening to" do
|
63
|
+
@leaf.irc_join_event(@stem, @sender_hash, { :channel => '#notlistening' }).should_not equal(true)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should notice PARTs on channels it is listening to" do
|
67
|
+
@leaf.irc_part_event(@stem, @sender_hash, { :channel => '#listening' }).should equal(true)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should not notice PARTs on channels it is not listening to" do
|
71
|
+
@leaf.irc_part_event(@stem, @sender_hash, { :channel => '#notlistening' }).should_not equal(true)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should notice MODEs on channels it is listening to" do
|
75
|
+
@leaf.irc_mode_event(@stem, @sender_hash, { :channel => '#listening' }).should equal(true)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should not notice MODEs on channels it is not listening to" do
|
79
|
+
@leaf.irc_mode_event(@stem, @sender_hash, { :channel => '#notlistening' }).should_not equal(true)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should notice MODE changes to iself" do
|
83
|
+
@leaf.irc_mode_event(@stem, @sender_hash, { :recipient => 'MockStem', :message => 'message' }).should equal(true)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should notice TOPICs on channels it is listening to" do
|
87
|
+
@leaf.irc_topic_event(@stem, @sender_hash, { :channel => '#listening' }).should equal(true)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should not notice TOPICs on channels it is not listening to" do
|
91
|
+
@leaf.irc_topic_event(@stem, @sender_hash, { :channel => '#notlistening' }).should_not equal(true)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should notice INVITEs on channels it is listening to" do
|
95
|
+
@leaf.irc_invite_event(@stem, @sender_hash, { :channel => '#listening' }).should equal(true)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should not notice INVITEs on channels it is not listening to" do
|
99
|
+
@leaf.irc_invite_event(@stem, @sender_hash, { :channel => '#notlistening' }).should_not equal(true)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should not notice INVITEs to me to channels I am not listening to" do
|
103
|
+
@leaf.irc_invite_event(@stem, @sender_hash, { :recipient => 'MockStem', :channel => '#notlistening' }).should_not equal(true)
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should notice INVITEs to me to channels I am not a part of" do
|
107
|
+
@leaf.irc_invite_event(@stem, @sender_hash, { :recipient => 'MockStem', :channel => '#notamember' }).should equal(true)
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should notice KICKs on channels it is listening to" do
|
111
|
+
@leaf.irc_kick_event(@stem, @sender_hash, { :channel => '#listening' }).should equal(true)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should not notice KICKs on channels it is not listening to" do
|
115
|
+
@leaf.irc_notice_event(@stem, @sender_hash, { :channel => '#notlistening' }).should_not equal(true)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should notice NOTICEs on channels it is listening to" do
|
119
|
+
@leaf.irc_notice_event(@stem, @sender_hash, { :channel => '#listening' }).should equal(true)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should not notice NOTICEs on channels it is not listening to" do
|
123
|
+
@leaf.irc_notice_event(@stem, @sender_hash, { :channel => '#notlistening' }).should_not equal(true)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should notice NOTICEs to itself" do
|
127
|
+
@leaf.irc_notice_event(@stem, @sender_hash, { :recipient => 'MockStem', :message => 'message' }).should equal(true)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "with an invalid stem" do
|
133
|
+
before :each do
|
134
|
+
@leaf = Autumn::ChannelLeaf.new :logger => @logger, :channels => { 'Nonexistent' => [ '#listening' ] }
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should raise an exception on startup" do
|
138
|
+
lambda { @leaf.will_start_up }.should raise_error(RuntimeError, "Unknown stem Nonexistent")
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|