ftpmvc 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ftpmvc/application.rb +9 -3
- data/lib/ftpmvc/authenticator/basic.rb +3 -3
- data/lib/ftpmvc/authenticator.rb +2 -1
- data/lib/ftpmvc/driver.rb +1 -1
- data/lib/ftpmvc/version.rb +1 -1
- data/spec/integration/authentication_spec.rb +28 -0
- data/spec/lib/ftpmvc/application_spec.rb +34 -0
- metadata +22 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6d7ed7fa4e8b557a99a8bf78cedd55871cbeaa2
|
4
|
+
data.tar.gz: 235185d4a033567403ac021cc7e2a68b7a7d2447
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9379f74972eb4bca4bbccd5144d0ed62ca32646269d4ec81c055b1e949125342186329653a0fe7d5c6c13c1b4d5834adb89c860622eb0a513fa490c31efb758
|
7
|
+
data.tar.gz: 83709da24052ac97688dcba8698267470828fcd74815d2b4129f763e1107b00a6bf6c27005fb7ab0c9eb05c401af58521947a97139e4182f827c45752a047180
|
data/lib/ftpmvc/application.rb
CHANGED
@@ -17,17 +17,23 @@ module FTPMVC
|
|
17
17
|
instance_eval(&block) if block_given?
|
18
18
|
end
|
19
19
|
|
20
|
-
protected
|
21
|
-
|
22
20
|
def auth
|
23
21
|
@authenticator ||= Authenticator::Promiscuous.new
|
24
22
|
end
|
25
23
|
|
24
|
+
protected
|
25
|
+
|
26
26
|
def filter(filter_class, options={})
|
27
27
|
@filter_chain = filter_class.new(@fs, @filter_chain, options)
|
28
28
|
end
|
29
29
|
|
30
|
-
def authenticator(authenticator)
|
30
|
+
def authenticator(authenticator, options={})
|
31
|
+
if authenticator.kind_of?(Symbol)
|
32
|
+
authenticator = FTPMVC::Authenticator.const_get(authenticator.to_s.camelize)
|
33
|
+
end
|
34
|
+
if authenticator.kind_of?(Class)
|
35
|
+
authenticator = authenticator.new(options)
|
36
|
+
end
|
31
37
|
@authenticator = authenticator
|
32
38
|
end
|
33
39
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module FTPMVC
|
2
2
|
module Authenticator
|
3
|
-
class Basic
|
3
|
+
class Basic < Struct.new(:users)
|
4
4
|
def initialize(options={})
|
5
|
-
|
5
|
+
super options[:users]
|
6
6
|
end
|
7
7
|
|
8
8
|
def authenticate(username, password)
|
9
|
-
|
9
|
+
users[username] == password
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
data/lib/ftpmvc/authenticator.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
require 'ftpmvc/authenticator/promiscuous'
|
2
|
+
require 'ftpmvc/authenticator/basic'
|
data/lib/ftpmvc/driver.rb
CHANGED
data/lib/ftpmvc/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require './spec/spec_helper'
|
2
|
+
|
3
|
+
require 'ftpmvc'
|
4
|
+
|
5
|
+
describe 'Authentication' do
|
6
|
+
let(:app) do
|
7
|
+
FTPMVC::Application.new do
|
8
|
+
authenticator :basic, users: { 'fabio' => 'iS2grails' }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'LOGIN' do
|
13
|
+
context 'when user/password is valid' do
|
14
|
+
it 'authenticates' do
|
15
|
+
with_application(app) do |ftp|
|
16
|
+
expect(ftp.login('fabio', 'iS2grails')).to be true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
context 'when user/password is valid' do
|
21
|
+
it 'does not authenticate' do
|
22
|
+
with_application(app) do |ftp|
|
23
|
+
expect { ftp.login('lucas', 'pwd') }.to raise_error Net::FTPPermError
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -2,6 +2,7 @@ require './spec/spec_helper'
|
|
2
2
|
|
3
3
|
require 'ftpmvc/application'
|
4
4
|
require 'ftpmvc/file'
|
5
|
+
require 'ftpmvc/authenticator/basic'
|
5
6
|
|
6
7
|
describe FTPMVC::Application do
|
7
8
|
describe '#filter' do
|
@@ -38,6 +39,39 @@ describe FTPMVC::Application do
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
42
|
+
describe '#authenticator' do
|
43
|
+
context 'when an instance is given' do
|
44
|
+
let(:application) do
|
45
|
+
FTPMVC::Application.new do
|
46
|
+
authenticator FTPMVC::Authenticator::Basic.new users: {}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
it 'sets auth as that' do
|
50
|
+
expect(application.auth).to be_a_kind_of(FTPMVC::Authenticator::Basic)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
context 'when a symbol is given' do
|
54
|
+
let(:application) do
|
55
|
+
FTPMVC::Application.new do
|
56
|
+
authenticator :basic, users: { 'a' => 'b' }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
it 'initializes a class on FTPMVC::Authenticator with given options' do
|
60
|
+
expect(application.auth).to eq FTPMVC::Authenticator::Basic.new users: { 'a' => 'b' }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
context 'when a class is given' do
|
64
|
+
let(:application) do
|
65
|
+
FTPMVC::Application.new do
|
66
|
+
authenticator FTPMVC::Authenticator::Basic, users: { 'a' => 'b' }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
it 'initializes that class with given options' do
|
70
|
+
expect(application.auth).to eq FTPMVC::Authenticator::Basic.new users: { 'a' => 'b' }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
41
75
|
describe '#authenticate' do
|
42
76
|
let(:custom_authenticator) { double('custom_authenticator') }
|
43
77
|
let(:application) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ftpmvc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- André Aizim Kelmanson
|
@@ -14,98 +14,98 @@ dependencies:
|
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: guard-rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: terminal-notifier-guard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: codeclimate-test-reporter
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: em-ftpd
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: activesupport
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: FTP MVC framework
|
@@ -115,9 +115,9 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
- .gitignore
|
119
|
-
- .rspec
|
120
|
-
- .travis.yml
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".travis.yml"
|
121
121
|
- Gemfile
|
122
122
|
- Guardfile
|
123
123
|
- LICENSE.txt
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/ftpmvc/server.rb
|
144
144
|
- lib/ftpmvc/test_helpers.rb
|
145
145
|
- lib/ftpmvc/version.rb
|
146
|
+
- spec/integration/authentication_spec.rb
|
146
147
|
- spec/integration/operation_spec.rb
|
147
148
|
- spec/lib/ftpmvc/access_filesystem_filter_spec.rb
|
148
149
|
- spec/lib/ftpmvc/application_spec.rb
|
@@ -161,12 +162,12 @@ require_paths:
|
|
161
162
|
- lib
|
162
163
|
required_ruby_version: !ruby/object:Gem::Requirement
|
163
164
|
requirements:
|
164
|
-
- -
|
165
|
+
- - ">="
|
165
166
|
- !ruby/object:Gem::Version
|
166
167
|
version: '0'
|
167
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
169
|
requirements:
|
169
|
-
- -
|
170
|
+
- - ">="
|
170
171
|
- !ruby/object:Gem::Version
|
171
172
|
version: '0'
|
172
173
|
requirements: []
|
@@ -176,6 +177,7 @@ signing_key:
|
|
176
177
|
specification_version: 4
|
177
178
|
summary: FTP MVC framework
|
178
179
|
test_files:
|
180
|
+
- spec/integration/authentication_spec.rb
|
179
181
|
- spec/integration/operation_spec.rb
|
180
182
|
- spec/lib/ftpmvc/access_filesystem_filter_spec.rb
|
181
183
|
- spec/lib/ftpmvc/application_spec.rb
|