authpwn_rails 0.10.12 → 0.11.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.
- data/VERSION +1 -1
- data/authpwn_rails.gemspec +1 -1
- data/lib/authpwn_rails/test_extensions.rb +7 -2
- data/test/http_basic_controller_test.rb +8 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.11.0
|
data/authpwn_rails.gemspec
CHANGED
@@ -58,7 +58,12 @@ module ControllerTestExtensions
|
|
58
58
|
# Tests that need to disable transactional fixures should specify the user's
|
59
59
|
# password.
|
60
60
|
def set_http_basic_user(user, password = nil)
|
61
|
-
|
61
|
+
if user.nil?
|
62
|
+
request.env.delete 'HTTP_AUTHORIZATION'
|
63
|
+
return self
|
64
|
+
end
|
65
|
+
|
66
|
+
if password.nil?
|
62
67
|
password = 'password'
|
63
68
|
credential = Credentials::Password.where(:user_id => user.id).first
|
64
69
|
if credential
|
@@ -78,7 +83,7 @@ module ControllerTestExtensions
|
|
78
83
|
|
79
84
|
request.env['HTTP_AUTHORIZATION'] =
|
80
85
|
"Basic #{::Base64.strict_encode64("#{email}:#{password}")}"
|
81
|
-
|
86
|
+
self
|
82
87
|
end
|
83
88
|
end # module Authpwn::ControllerTestExtensions
|
84
89
|
|
@@ -52,6 +52,14 @@ class HttpBasicControllerTest < ActionController::TestCase
|
|
52
52
|
assert_equal 'No user', response.body
|
53
53
|
end
|
54
54
|
|
55
|
+
test "reset user credentials in header" do
|
56
|
+
set_http_basic_user @user, 'pa55w0rd'
|
57
|
+
set_http_basic_user nil
|
58
|
+
get :show
|
59
|
+
assert_nil assigns(:current_user)
|
60
|
+
assert_equal 'No user', response.body
|
61
|
+
end
|
62
|
+
|
55
63
|
test "mocked user credentials in header" do
|
56
64
|
set_http_basic_user @user
|
57
65
|
get :show
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authpwn_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -278,7 +278,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
278
278
|
version: '0'
|
279
279
|
segments:
|
280
280
|
- 0
|
281
|
-
hash:
|
281
|
+
hash: 903064775847745508
|
282
282
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
283
283
|
none: false
|
284
284
|
requirements:
|