challah 1.1.0 → 1.1.1
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.
- checksums.yaml +4 -4
- data/lib/challah/encrypter.rb +1 -1
- data/lib/challah/engine.rb +1 -3
- data/lib/challah/routes.rb +1 -6
- data/lib/challah/test.rb +1 -1
- data/lib/challah/version.rb +2 -2
- data/test/{controller_test.rb → controllers/controller_test.rb} +2 -2
- data/test/{restrictions_controller_test.rb → controllers/restrictions_controller_test.rb} +2 -4
- data/test/{sessions_controller_test.rb → controllers/sessions_controller_test.rb} +2 -2
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/{app/controllers/challah/test → test/dummy/app/controllers}/restrictions_controller.rb +2 -2
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/user.rb +15 -0
- data/test/dummy/app/models/widget.rb +3 -0
- data/test/dummy/app/views/bakery/templates/layouts/sample.erb +1 -0
- data/test/dummy/app/views/bakery/templates/partials/sample.html.haml +1 -0
- data/test/dummy/app/views/bakery/templates/themes/sample.haml +1 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +24 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +30 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/i18n.rb +1 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/db/migrate/20140114212939_create_widgets.rb +32 -0
- data/test/dummy/db/migrate/20140307205735_create_users.challah_engine.rb +34 -0
- data/test/dummy/db/migrate/20140307205736_create_authorizations.challah_engine.rb +21 -0
- data/test/dummy/db/schema.rb +81 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +11547 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/{authorization_test.rb → models/authorization_test.rb} +2 -2
- data/test/{user_test.rb → models/user_test.rb} +2 -2
- data/test/{audit_test.rb → services/audit_test.rb} +2 -2
- data/test/{cookie_store_test.rb → services/cookie_store_test.rb} +2 -2
- data/test/{encrypter_test.rb → services/encrypter_test.rb} +27 -27
- data/test/{plugins_test.rb → services/plugins_test.rb} +2 -2
- data/test/{random_test.rb → services/random_test.rb} +9 -9
- data/test/{routes_test.rb → services/routes_test.rb} +2 -2
- data/test/{session_test.rb → services/session_test.rb} +2 -2
- data/test/{signup_test.rb → services/signup_test.rb} +2 -2
- data/test/{simple_cookie_store_test.rb → services/simple_cookie_store_test.rb} +2 -2
- data/test/support/stubs.rb +88 -0
- data/test/test_helper.rb +47 -0
- metadata +75 -29
- data/test/edge_helper.rb +0 -57
- data/test/helper.rb +0 -148
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/404.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
54
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/422.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The change you wanted was rejected.</h1>
|
54
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/500.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>We're sorry, but something went wrong.</h1>
|
54
|
+
</div>
|
55
|
+
<p>If you are the application owner check the logs for more information.</p>
|
56
|
+
</body>
|
57
|
+
</html>
|
File without changes
|
@@ -1,73 +1,73 @@
|
|
1
|
-
require '
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class TestEncrypter < ActiveSupport::TestCase
|
4
4
|
include Challah
|
5
|
-
|
5
|
+
|
6
6
|
context "The encrypter class" do
|
7
7
|
should "encrypt a string" do
|
8
8
|
assert_not_nil Encrypter.encrypt("testing 123")
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
should "use bcrypt to encrypt a string" do
|
12
12
|
BCrypt::Password.expects(:create).with('testing 123', :cost => 10)
|
13
|
-
|
13
|
+
|
14
14
|
Encrypter.encrypt("testing 123")
|
15
|
-
|
15
|
+
|
16
16
|
BCrypt::Password.unstub(:create)
|
17
|
-
end
|
17
|
+
end
|
18
18
|
|
19
19
|
should "compare two encrypted strings quickly" do
|
20
|
-
pass = Encrypter.encrypt("test A")
|
21
|
-
|
20
|
+
pass = Encrypter.encrypt("test A")
|
21
|
+
|
22
22
|
assert_equal true, Encrypter.compare(pass, "test A")
|
23
23
|
assert_equal false, Encrypter.compare("test A", "test A")
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
context "An encrypter instance" do
|
28
28
|
setup do
|
29
29
|
@enc = Encrypter.new
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
should "encrypt a string" do
|
33
|
-
pass = @enc.encrypt('testing 123')
|
33
|
+
pass = @enc.encrypt('testing 123')
|
34
34
|
assert_not_nil pass
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
should "encrypt a string at a provided cost" do
|
38
38
|
@enc.cost = 5
|
39
|
-
|
39
|
+
|
40
40
|
pass = @enc.encrypt('testing 456')
|
41
|
-
|
41
|
+
|
42
42
|
bpass = BCrypt::Password.new(pass)
|
43
|
-
|
43
|
+
|
44
44
|
assert_equal 5, bpass.cost
|
45
|
-
end
|
46
|
-
|
45
|
+
end
|
46
|
+
|
47
47
|
should "compare a string" do
|
48
|
-
pass = @enc.encrypt("test A")
|
49
|
-
|
48
|
+
pass = @enc.encrypt("test A")
|
49
|
+
|
50
50
|
assert_equal true, @enc.compare(pass, "test A")
|
51
51
|
assert_equal false, @enc.compare("test A", "test A")
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
should "md5 hash a batch of strings" do
|
55
55
|
expected = Digest::MD5.hexdigest("str1|str2|str3")
|
56
56
|
assert_equal expected, @enc.md5('str1', 'str2', 'str3')
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
should "md5 hash a batch of strings with a different join" do
|
60
60
|
@enc.joiner = ' - '
|
61
|
-
expected = Digest::MD5.hexdigest("str1 - str2 - str3")
|
61
|
+
expected = Digest::MD5.hexdigest("str1 - str2 - str3")
|
62
62
|
assert_equal expected, @enc.md5('str1', 'str2', 'str3')
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
should "hash some strings a given number of times" do
|
66
66
|
Digest::SHA512.expects(:hexdigest).times(10)
|
67
|
-
|
67
|
+
|
68
68
|
@enc.hash('hash me')
|
69
|
-
|
69
|
+
|
70
70
|
Digest::SHA512.unstub(:hexdigest)
|
71
|
-
end
|
71
|
+
end
|
72
72
|
end
|
73
|
-
end
|
73
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
require '
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class TestRandom < ActiveSupport::TestCase
|
4
4
|
include Challah
|
5
|
-
|
5
|
+
|
6
6
|
should "be able to provide a random string from ActiveSupport" do
|
7
7
|
result = Random.token(10)
|
8
|
-
|
8
|
+
|
9
9
|
assert_not_nil result
|
10
10
|
assert_equal 10, result.size
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
should "be able to provide a random string without ActiveSupport" do
|
14
|
-
Challah::Random.stubs(:secure_random?).returns(false)
|
14
|
+
Challah::Random.stubs(:secure_random?).returns(false)
|
15
15
|
SecureRandom.expects(:hex).never
|
16
|
-
|
16
|
+
|
17
17
|
result = Challah::Random.token(10)
|
18
|
-
|
18
|
+
|
19
19
|
assert_not_nil result
|
20
20
|
assert_equal 10, result.size
|
21
|
-
end
|
22
|
-
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class RoutesTest < ActionDispatch::IntegrationTest
|
4
4
|
context "The routing engine" do
|
@@ -8,4 +8,4 @@ class RoutesTest < ActionDispatch::IntegrationTest
|
|
8
8
|
assert_routing({ :method => 'post', :path => '/sign-in' }, { :controller => 'sessions', :action => 'create' })
|
9
9
|
end
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class SignupTest < ActiveSupport::TestCase
|
4
4
|
context "A signup instance" do
|
@@ -119,4 +119,4 @@ class SignupTest < ActiveSupport::TestCase
|
|
119
119
|
assert_equal expected_error_fields, signup.errors.messages.keys.sort
|
120
120
|
end
|
121
121
|
end
|
122
|
-
end
|
122
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class SimpleCookieStoreTest < ActiveSupport::TestCase
|
4
4
|
include Challah
|
@@ -119,4 +119,4 @@ class SimpleCookieStoreTest < ActiveSupport::TestCase
|
|
119
119
|
assert_equal [], @request.cookies.keys.sort
|
120
120
|
end
|
121
121
|
end
|
122
|
-
end
|
122
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
class MockController
|
2
|
+
include Challah::Controller
|
3
|
+
|
4
|
+
attr_accessor :request, :session, :params
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
@request = MockRequest.new
|
8
|
+
@session ||= {}
|
9
|
+
@params ||= {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def redirect_to(*args)
|
13
|
+
# do nothing
|
14
|
+
end
|
15
|
+
|
16
|
+
def login_path
|
17
|
+
"/login"
|
18
|
+
end
|
19
|
+
|
20
|
+
def logout_path
|
21
|
+
"/logout"
|
22
|
+
end
|
23
|
+
|
24
|
+
def signin_path
|
25
|
+
"/sign-in"
|
26
|
+
end
|
27
|
+
|
28
|
+
def signout_path
|
29
|
+
"/sign-out"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class MockRequest
|
34
|
+
attr_accessor :cookie_jar, :session_options, :url
|
35
|
+
|
36
|
+
class MockCookieJar < Hash
|
37
|
+
def delete(key, options = {})
|
38
|
+
super(key)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def initialize
|
43
|
+
@cookie_jar = MockCookieJar.new
|
44
|
+
@session_options = { :domain => 'test.dev' }
|
45
|
+
@url = "http://example.com/"
|
46
|
+
end
|
47
|
+
|
48
|
+
def cookies
|
49
|
+
@cookie_jar
|
50
|
+
end
|
51
|
+
|
52
|
+
def cookies=(value)
|
53
|
+
@cookie_jar = value
|
54
|
+
end
|
55
|
+
|
56
|
+
def remote_ip
|
57
|
+
"8.8.8.8"
|
58
|
+
end
|
59
|
+
|
60
|
+
def user_agent
|
61
|
+
"Some Cool Browser"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class FakeProvider
|
66
|
+
def self.save(record)
|
67
|
+
set(record.fake_provider.merge(user_id: record.id))
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.set(options = {})
|
71
|
+
user_id = options.fetch(:user_id)
|
72
|
+
uid = options.fetch(:uid, '')
|
73
|
+
token = options.fetch(:token, '')
|
74
|
+
|
75
|
+
Authorization.set({
|
76
|
+
provider: :fake,
|
77
|
+
user_id: user_id,
|
78
|
+
uid: uid,
|
79
|
+
token: token
|
80
|
+
})
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.valid?(record)
|
84
|
+
record.fake_provider? and record.fake_provider.fetch(:token) == 'me'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
Challah.register_provider :fake, FakeProvider
|