morhekil-ipcauthpipe 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/config.yml CHANGED
@@ -14,6 +14,6 @@ invision:
14
14
 
15
15
  mail:
16
16
  address_format: %s@poker.ru
17
- owner_username: saruman
17
+ owner_uid: 2001
18
18
  owner_gid: 1000
19
19
  home_dir: /tmp/%s
data/ipcauthpipe.gemspec CHANGED
@@ -1,10 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "ipcauthpipe"
3
- s.version = "0.1"
4
- s.date = "2008-09-10"
3
+ s.version = "0.2"
4
+ s.date = "2008-09-18"
5
5
  s.summary = "Implementation of Courier's authpipe protocol over Invision Power Board / Converge."
6
- s.email = "tom@rubyisawesome.com"
7
- s.homepage = "http://github.com/schacon/grit"
8
6
  s.description = "ipcauthpipe gem implements Courier's authpipe protocol to interface Courier POP/IMAP server with Invision Power Board / Converge members database."
9
7
  s.has_rdoc = false
10
8
 
data/lib/ipcauthpipe.rb CHANGED
@@ -26,7 +26,10 @@ module IpcAuthpipe
26
26
 
27
27
  ipc = IpcAuthpipe::Processor.new
28
28
  while (line = IpcAuthpipe::Reader.getline) do
29
- puts ipc.process(line.strip) unless line.strip.empty?
29
+ reply = ipc.process(line.strip) unless line.strip.empty?
30
+ Log::debug "Reply is: #{reply.inspect}"
31
+ STDOUT.puts reply
32
+ STDOUT.flush
30
33
  end
31
34
  end
32
35
 
@@ -52,4 +55,4 @@ module IpcAuthpipe
52
55
 
53
56
  end
54
57
 
55
- end
58
+ end
@@ -19,8 +19,10 @@ module IpcAuthpipe
19
19
  # them up into a hash of parameters ready for further processing
20
20
  def getdata(count)
21
21
  Log.debug "Reading [#{count}] bytes from input stream"
22
- splits = Reader::getbytes(count).strip.split(/\s+/m)
23
- raise ArgumentError, 'Invalid AUTH payload' unless splits.size == 3
22
+ payload = Reader::getbytes(count)
23
+ Log.debug "AUTH payload is #{payload}"
24
+ splits = payload.strip.split(/\s+/m)
25
+ raise ArgumentError, 'Invalid AUTH payload' unless splits.size == 4
24
26
 
25
27
  Log.debug "Analyzing splits [#{splits.inspect}]"
26
28
  auth_method(splits)
@@ -30,11 +32,11 @@ module IpcAuthpipe
30
32
  # of :method, :username and :password for LOGIN authentication and
31
33
  # :method, :challenge and :response for CRAM-style authentications
32
34
  def auth_method(splits)
33
- result = { :method => splits[0].strip.downcase }
35
+ result = { :method => splits[1].strip.downcase }
34
36
  result.merge!(
35
37
  result[:method] == 'login' ?
36
- { :username => splits[1].strip, :password => splits[2].strip } :
37
- { :challenge => splits[1].strip, :response => splits[2].strip }
38
+ { :username => splits[2].strip.split(/\@/)[0], :password => splits[3].strip } :
39
+ { :challenge => splits[2].strip, :response => splits[3].strip }
38
40
  )
39
41
 
40
42
  Log.debug "Converted splits into [#{result.inspect}]"
@@ -74,4 +76,4 @@ module IpcAuthpipe
74
76
  end
75
77
 
76
78
  end
77
- end
79
+ end
data/lib/models/member.rb CHANGED
@@ -15,9 +15,10 @@ class Member < ActiveRecord::Base
15
15
  def to_authpipe
16
16
  IpcAuthpipe::Log.debug "Dumping authpipe string for member data #{inspect}"
17
17
  stringdump = [
18
- "USERNAME=#{IpcAuthpipe::config.mail['owner_username']}",
18
+ "UID=#{IpcAuthpipe::config.mail['owner_uid']}",
19
19
  "GID=#{IpcAuthpipe::config.mail['owner_gid']}",
20
- "HOME=#{IpcAuthpipe::config.mail['home_dir'] % name}",
20
+ "HOME=#{IpcAuthpipe::config.mail['home_dir'] % name}/",
21
+ "MAILDIR=#{IpcAuthpipe::config.mail['home_dir'] % name}/",
21
22
  "ADDRESS=#{IpcAuthpipe::config.mail['address_format'] % name}",
22
23
  "."
23
24
  ].join("\n")+"\n"
@@ -25,4 +26,4 @@ class Member < ActiveRecord::Base
25
26
 
26
27
  stringdump
27
28
  end
28
- end
29
+ end
data/test/config.yml CHANGED
@@ -14,6 +14,6 @@ invision:
14
14
 
15
15
  mail:
16
16
  address_format: %s@poker.ru
17
- owner_username: saruman
17
+ owner_uid: 2000
18
18
  owner_gid: 1000
19
19
  home_dir: /home/vmail/%s
@@ -16,35 +16,35 @@ describe "AUTH handler" do
16
16
  end
17
17
 
18
18
  it "should read given number of bytes from the input stream and pass them onto the analyzer splitted into an array" do
19
- IpcAuthpipe::Reader.should_receive(:getbytes).once.with(23).and_return("login \n vasya \n parol ")
19
+ IpcAuthpipe::Reader.should_receive(:getbytes).once.with(29).and_return("imap \nlogin \n vasya \n parol ")
20
20
  # we're expecting array as an argument for auth_method
21
21
  @auth.should_receive(:auth_method).once.with( duck_type(:is_array) )
22
- @auth.getdata(23)
22
+ @auth.getdata(29)
23
23
  end
24
24
 
25
25
  it "should raise ArgumentError exception on invalid payload" do
26
- IpcAuthpipe::Reader.should_receive(:getbytes).once.with(27).and_return("login \n vasya \n parol \n wtf")
27
- lambda { @auth.getdata(27) }.should raise_error(ArgumentError)
26
+ IpcAuthpipe::Reader.should_receive(:getbytes).once.with(33).and_return("imap \nlogin \n vasya \n parol \n wtf")
27
+ lambda { @auth.getdata(33) }.should raise_error(ArgumentError)
28
28
  end
29
29
 
30
30
  it "should properly handle both CR-delimited and non-CR-delimited payloads" do
31
- @auth.should_receive(:auth_method).twice.with(['login', 'vasya', 'parol'])
31
+ @auth.should_receive(:auth_method).twice.with(['imap', 'login', 'vasya', 'parol'])
32
32
 
33
- IpcAuthpipe::Reader.should_receive(:getbytes).once.with(23).and_return("login \n vasya \n parol ")
34
- @auth.getdata(23)
33
+ IpcAuthpipe::Reader.should_receive(:getbytes).once.with(29).and_return("imap \nlogin \n vasya \n parol ")
34
+ @auth.getdata(29)
35
35
 
36
- IpcAuthpipe::Reader.should_receive(:getbytes).once.with(24).and_return("login \n vasya \n parol \n")
37
- @auth.getdata(24)
36
+ IpcAuthpipe::Reader.should_receive(:getbytes).once.with(30).and_return("imap \nlogin \n vasya \n parol \n")
37
+ @auth.getdata(30)
38
38
  end
39
39
 
40
40
  it "should convert LOGIN's payload into a hash with username and password" do
41
- @auth.auth_method( ['login', 'vasya', 'parol'] ).should == {
41
+ @auth.auth_method( ['imap', 'login', 'vasya', 'parol'] ).should == {
42
42
  :method => 'login', :username => 'vasya', :password => 'parol'
43
43
  }
44
44
  end
45
45
 
46
46
  it "should convert CRAM's payload into a hash with challenge and response" do
47
- @auth.auth_method( ['cram-md5', 'vasya', 'parol'] ).should == {
47
+ @auth.auth_method( ['imap', 'cram-md5', 'vasya', 'parol'] ).should == {
48
48
  :method => 'cram-md5', :challenge => 'vasya', :response => 'parol'
49
49
  }
50
50
  end
@@ -45,9 +45,10 @@ describe 'Member' do
45
45
  )
46
46
 
47
47
  member.to_authpipe.should == [
48
- "USERNAME=#{IpcAuthpipe::config.mail['owner_username']}",
48
+ "UID=#{IpcAuthpipe::config.mail['owner_uid']}",
49
49
  "GID=#{IpcAuthpipe::config.mail['owner_gid']}",
50
- "HOME=/home/vmail/tester",
50
+ "HOME=/home/vmail/tester/",
51
+ "MAILDIR=/home/vmail/tester/",
51
52
  "ADDRESS=tester@poker.ru",
52
53
  "."
53
54
  ].join("\n") + "\n"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morhekil-ipcauthpipe
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: "0.2"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Ivanov
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-10 00:00:00 -07:00
12
+ date: 2008-09-18 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency