sixarm_ruby_sign_in_simple 1.2.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 73bb58254d9bdd0e7ccf36b89889706328a2b124
4
+ data.tar.gz: 4ce50a83a9e6753f94094a7923bb0c2107936a5e
5
+ SHA512:
6
+ metadata.gz: ac66835bad6f63e12206b96cf8a3169c4e8115d8961adb1b1709c0600e0907c11d1483f3fb2e1a7b53a14199dbd2d0ebb5ff9e9ae9bbf8bfcec4b63c2ea0f244
7
+ data.tar.gz: a58462176bbdef4444968d374108957161af1be1d0791b05f8642a2115cfd03cd51a051ef7d692859490c1d8f8aafad1316c2cdfa4f7c4018768200f473c7508
Binary file
Binary file
@@ -0,0 +1,12 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "rake"
3
+ require "rake/testtask"
4
+
5
+ task :default => [:test]
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs.push("lib", "test")
9
+ t.pattern = "test/**/*.rb"
10
+ end
11
+ task :default => [:test]
12
+ task :default => [:test]
@@ -0,0 +1,75 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin rdoc
3
+ Please see README
4
+ =end
5
+
6
+ require "sixarm_ruby_sign_in"
7
+
8
+ module SignInSimple
9
+
10
+ include SignIn
11
+
12
+ ####################################################################
13
+ #
14
+ # Implement interface of SignIn
15
+ #
16
+ ####################################################################
17
+
18
+ def sign_in_attempt(options=nil)
19
+ username=sign_in_username; username and username!='' or sign_in_error_no_username(options)
20
+ password=sign_in_password; password and password!='' or sign_in_error_no_password(options)
21
+ u=User.find_by_username(username)
22
+ u and u.password==password or sign_in_not_found(options)
23
+ self.current_user=u
24
+ end
25
+
26
+ def sign_in_failure(options=nil)
27
+ flash[:warning]=sign_in_failure_message(options)
28
+ end
29
+
30
+
31
+ ####################################################################
32
+ #
33
+ # Helpers
34
+ #
35
+ ####################################################################
36
+
37
+
38
+ def sign_in_failure_message(options=nil)
39
+ "Sorry, your sign in failed." + ($! ? " #{$!}" : '')
40
+ end
41
+
42
+ def sign_in_username(options=nil)
43
+ params[:username]
44
+ end
45
+
46
+ def sign_in_error_no_username(options=nil)
47
+ raise SecurityError, sign_in_error_no_username_message(options)
48
+ end
49
+
50
+ def sign_in_error_no_username_message(options=nil)
51
+ "Please type in your username."
52
+ end
53
+
54
+ def sign_in_password(options=nil)
55
+ params[:password]
56
+ end
57
+
58
+ def sign_in_error_no_password(options=nil)
59
+ raise SecurityError, sign_in_error_no_password_message(options)
60
+ end
61
+
62
+ def sign_in_error_no_password_message(options=nil)
63
+ "Please type in your password."
64
+ end
65
+
66
+ def sign_in_not_found(options=nil)
67
+ raise SecurityError, sign_in_not_found_message(options)
68
+ end
69
+
70
+ def sign_in_not_found_message(options=nil)
71
+ "Sorry, the username/password combination is not registered."
72
+ end
73
+
74
+
75
+ end
@@ -0,0 +1,110 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "minitest/autorun"
3
+ require "simplecov"
4
+ SimpleCov.start
5
+
6
+ require "sixarm_ruby_sign_in_simple"
7
+ require "sixarm_ruby_application_controller_mock"
8
+
9
+ class SignInSimpleTest < Minitest::Test
10
+
11
+ USERNAME='anna'
12
+ PASSWORD='secret'
13
+
14
+ def setup
15
+ @uc=UsersController.new
16
+ end
17
+
18
+ def test_sign_in
19
+ assert_nil(@uc.current_user,'user before sign in')
20
+ @uc.sign_in
21
+ assert_equal(User.singleton,@uc.current_user,'user after sign in')
22
+ end
23
+
24
+ def test_sign_in_success_message
25
+ s=@uc.sign_in_success_message
26
+ assert_kind_of(String,s)
27
+ end
28
+
29
+ def test_sign_in_failure_message
30
+ s=@uc.sign_in_failure_message
31
+ assert_kind_of(String,s)
32
+ end
33
+
34
+ def test_sign_in_error_no_username
35
+ assert_raise SecurityError do
36
+ @uc.sign_in_error_no_username
37
+ end
38
+ end
39
+
40
+ def test_sign_in_error_no_username_message
41
+ s=@uc.sign_in_error_no_username_message
42
+ assert_kind_of(String,s)
43
+ end
44
+
45
+ def test_sign_in_error_no_password
46
+ assert_raise SecurityError do
47
+ @uc.sign_in_error_no_password
48
+ end
49
+ end
50
+
51
+ def test_sign_in_error_no_password_message
52
+ s=@uc.sign_in_error_no_password_message
53
+ assert_kind_of(String,s)
54
+ end
55
+
56
+ def test_sign_in_failure_message
57
+ s=@uc.sign_in_failure_message
58
+ assert_kind_of(String,s)
59
+ end
60
+
61
+ def test_sign_in_not_found
62
+ assert_raise SecurityError do
63
+ @uc.sign_in_not_found
64
+ end
65
+ end
66
+
67
+ def test_sign_in_not_found_message
68
+ s=@uc.sign_in_not_found_message
69
+ assert_kind_of(String,s)
70
+ end
71
+
72
+ end
73
+
74
+
75
+ class UsersController < ApplicationController
76
+
77
+ attr_accessor :current_user
78
+ include SignInSimple
79
+
80
+ def initialize(*ops)
81
+ super(:params=>{:username=>'anne',:password=>'secret'})
82
+ end
83
+
84
+ end
85
+
86
+
87
+ class User
88
+
89
+ def self.find(id)
90
+ pp "User#find(#{id})"
91
+ singleton
92
+ end
93
+
94
+ def self.find_by_username(username)
95
+ singleton
96
+ end
97
+
98
+ def username
99
+ 'anne'
100
+ end
101
+
102
+ def password
103
+ 'secret'
104
+ end
105
+
106
+ def self.singleton
107
+ @@singleton||=User.new
108
+ end
109
+
110
+ end
metadata ADDED
@@ -0,0 +1,222 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sixarm_ruby_sign_in_simple
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ platform: ruby
6
+ authors:
7
+ - SixArm
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIGCTCCA/GgAwIBAgIJAK3igyLv2hNNMA0GCSqGSIb3DQEBBQUAMGAxCzAJBgNV
14
+ BAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhb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:00:00.000000000 Z
48
+ dependencies:
49
+ - !ruby/object:Gem::Dependency
50
+ name: sixarm_ruby_sign_in
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 1.2.0
56
+ - - "<"
57
+ - !ruby/object:Gem::Version
58
+ version: '2'
59
+ type: :runtime
60
+ prerelease: false
61
+ version_requirements: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 1.2.0
66
+ - - "<"
67
+ - !ruby/object:Gem::Version
68
+ version: '2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 5.7.0
76
+ - - "<"
77
+ - !ruby/object:Gem::Version
78
+ version: '6'
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 5.7.0
86
+ - - "<"
87
+ - !ruby/object:Gem::Version
88
+ version: '6'
89
+ - !ruby/object:Gem::Dependency
90
+ name: sixarm_ruby_minitest_extensions
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '='
94
+ - !ruby/object:Gem::Version
95
+ version: 1.0.5
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '='
101
+ - !ruby/object:Gem::Version
102
+ version: 1.0.5
103
+ - !ruby/object:Gem::Dependency
104
+ name: rake
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">"
108
+ - !ruby/object:Gem::Version
109
+ version: 10.4.2
110
+ - - "<"
111
+ - !ruby/object:Gem::Version
112
+ version: '11'
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">"
118
+ - !ruby/object:Gem::Version
119
+ version: 10.4.2
120
+ - - "<"
121
+ - !ruby/object:Gem::Version
122
+ version: '11'
123
+ - !ruby/object:Gem::Dependency
124
+ name: simplecov
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: 0.10.0
130
+ - - "<"
131
+ - !ruby/object:Gem::Version
132
+ version: '2'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: 0.10.0
140
+ - - "<"
141
+ - !ruby/object:Gem::Version
142
+ version: '2'
143
+ - !ruby/object:Gem::Dependency
144
+ name: coveralls
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: 0.8.2
150
+ - - "<"
151
+ - !ruby/object:Gem::Version
152
+ version: '2'
153
+ type: :development
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: 0.8.2
160
+ - - "<"
161
+ - !ruby/object:Gem::Version
162
+ version: '2'
163
+ - !ruby/object:Gem::Dependency
164
+ name: sixarm_ruby_application_controller_mock
165
+ requirement: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: 1.2.7
170
+ - - "<"
171
+ - !ruby/object:Gem::Version
172
+ version: '2'
173
+ type: :development
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: 1.2.7
180
+ - - "<"
181
+ - !ruby/object:Gem::Version
182
+ version: '2'
183
+ description: Sign In methods for a simple sessions in a Rails application
184
+ email: sixarm@sixarm.com
185
+ executables: []
186
+ extensions: []
187
+ extra_rdoc_files: []
188
+ files:
189
+ - Rakefile
190
+ - lib/sixarm_ruby_sign_in_simple.rb
191
+ - test/sixarm_ruby_sign_in_simple_test.rb
192
+ homepage: http://sixarm.com/
193
+ licenses:
194
+ - Apache-2.0
195
+ - Artistic-2.0
196
+ - BSD-3-Clause
197
+ - GPL-3.0
198
+ - MIT
199
+ - MPL-2.0
200
+ metadata: {}
201
+ post_install_message:
202
+ rdoc_options: []
203
+ require_paths:
204
+ - lib
205
+ required_ruby_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ required_rubygems_version: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - ">="
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
215
+ requirements: []
216
+ rubyforge_project:
217
+ rubygems_version: 2.6.12
218
+ signing_key:
219
+ specification_version: 4
220
+ summary: SixArm.com → Ruby → Sign In
221
+ test_files:
222
+ - test/sixarm_ruby_sign_in_simple_test.rb
@@ -0,0 +1,2 @@
1
+ �$}Q���4;1�(����%�_��33�|��sY7C�[�l�?#���BB�%��� ��ؓ �P��UT�m��]0�;�F�XdϢ�JFk���aa)��LyS��
2
+ �z@m�/���1ܒ@y�����4]���׶F�ClS�L�`�Py=��5����V�[bz�"=x��W���qv�L>J2X;��ՄRl�=@e�u9I&���r>�pB0ށ'g J��S-U��2J���q��U��IJ�d�3����A���+��/���9��V����<H�qA!{85���W��b'�;.<#�>f����*���3{Awr�GAạK�=�_�jV��B�m[�ƗM�'���;�9I��}�����ݘ�-����&��&f|qk����i��|r��;����ݣ��`"CˑfBοse�.�r󮽒(0��iKz?W���/�|���+3�;+*޸wo4Ŋ�]�����|���'��[ ��PGD�S��U�y��q�a�<