knock 1.4.2 → 1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +8 -8
  2. data/app/controllers/knock/application_controller.rb +1 -1
  3. data/app/controllers/knock/auth_token_controller.rb +32 -7
  4. data/app/model/knock/auth_token.rb +31 -7
  5. data/lib/generators/knock/token_controller_generator.rb +25 -0
  6. data/lib/generators/templates/entity_token_controller.rb.erb +2 -0
  7. data/lib/generators/templates/knock.rb +25 -3
  8. data/lib/knock.rb +7 -0
  9. data/lib/knock/authenticable.rb +45 -6
  10. data/lib/knock/version.rb +1 -1
  11. data/test/controllers/knock/auth_token_controller_test.rb +11 -0
  12. data/test/dummy/app/controllers/admin_protected_controller.rb +7 -0
  13. data/test/dummy/app/controllers/admin_token_controller.rb +2 -0
  14. data/test/dummy/app/controllers/composite_name_entity_protected_controller.rb +7 -0
  15. data/test/dummy/app/controllers/vendor_protected_controller.rb +11 -0
  16. data/test/dummy/app/controllers/vendor_token_controller.rb +2 -0
  17. data/test/dummy/app/models/admin.rb +16 -0
  18. data/test/dummy/app/models/composite_name_entity.rb +3 -0
  19. data/test/dummy/app/models/vendor.rb +3 -0
  20. data/test/dummy/config/initializers/knock.rb +10 -0
  21. data/test/dummy/config/routes.rb +8 -0
  22. data/test/dummy/db/migrate/20160519075733_create_admins.rb +10 -0
  23. data/test/dummy/db/migrate/20160522051816_create_vendors.rb +10 -0
  24. data/test/dummy/db/migrate/20160522181712_create_composite_name_entities.rb +10 -0
  25. data/test/dummy/db/schema.rb +22 -1
  26. data/test/dummy/db/test.sqlite3 +0 -0
  27. data/test/dummy/log/test.log +333 -91
  28. data/test/dummy/test/controllers/admin_protected_controller_test.rb +49 -0
  29. data/test/dummy/test/controllers/admin_token_controller_test.rb +22 -0
  30. data/test/dummy/test/controllers/composite_name_entity_protected_controller_test.rb +49 -0
  31. data/test/dummy/test/controllers/vendor_protected_controller_test.rb +55 -0
  32. data/test/dummy/test/controllers/vendor_token_controller_test.rb +22 -0
  33. data/test/dummy/test/models/admin_test.rb +7 -0
  34. data/test/dummy/test/models/vendor_test.rb +7 -0
  35. data/test/{dummy/test/fixtures/users.yml → fixtures/admins.yml} +1 -5
  36. data/test/fixtures/composite_name_entities.yml +5 -0
  37. data/test/fixtures/vendors.yml +5 -0
  38. data/test/generators/token_controller_generator_test.rb +31 -0
  39. data/test/model/knock/auth_token_test.rb +33 -9
  40. data/test/support/generators_test_helper.rb +9 -0
  41. data/test/test_helper.rb +9 -0
  42. data/test/tmp/app/controllers/admin_token_controller.rb +2 -0
  43. data/test/tmp/app/controllers/admin_user_token_controller.rb +2 -0
  44. data/test/tmp/app/controllers/user_admin_token_controller.rb +2 -0
  45. data/test/tmp/app/controllers/user_token_controller.rb +2 -0
  46. data/test/tmp/config/routes.rb +17 -0
  47. metadata +76 -6
  48. data/test/tmp/config/initializers/knock.rb +0 -86
@@ -0,0 +1,10 @@
1
+ class CreateAdmins < ActiveRecord::Migration
2
+ def change
3
+ create_table :admins do |t|
4
+ t.string :email
5
+ t.string :password_digest
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class CreateVendors < ActiveRecord::Migration
2
+ def change
3
+ create_table :vendors do |t|
4
+ t.string :email
5
+ t.string :password_digest
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class CreateCompositeNameEntities < ActiveRecord::Migration
2
+ def change
3
+ create_table :composite_name_entities do |t|
4
+ t.string :email
5
+ t.string :password_digest
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -11,7 +11,21 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20150713101607) do
14
+ ActiveRecord::Schema.define(version: 20160522181712) do
15
+
16
+ create_table "admins", force: :cascade do |t|
17
+ t.string "email"
18
+ t.string "password_digest"
19
+ t.datetime "created_at", null: false
20
+ t.datetime "updated_at", null: false
21
+ end
22
+
23
+ create_table "composite_name_entities", force: :cascade do |t|
24
+ t.string "email"
25
+ t.string "password_digest"
26
+ t.datetime "created_at", null: false
27
+ t.datetime "updated_at", null: false
28
+ end
15
29
 
16
30
  create_table "users", force: :cascade do |t|
17
31
  t.string "email", null: false
@@ -20,4 +34,11 @@ ActiveRecord::Schema.define(version: 20150713101607) do
20
34
  t.datetime "updated_at", null: false
21
35
  end
22
36
 
37
+ create_table "vendors", force: :cascade do |t|
38
+ t.string "email"
39
+ t.string "password_digest"
40
+ t.datetime "created_at", null: false
41
+ t.datetime "updated_at", null: false
42
+ end
43
+
23
44
  end
Binary file
@@ -1,84 +1,166 @@
1
+  (4.6ms) CREATE TABLE "admins" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar, "password_digest" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
2
+  (1.8ms) CREATE TABLE "composite_name_entities" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar, "password_digest" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
1
3
   (1.9ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar NOT NULL, "password_digest" varchar NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
2
-  (1.7ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
3
-  (0.1ms) select sqlite_version(*)
4
-  (1.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
5
-  (0.1ms) SELECT version FROM "schema_migrations"
6
-  (1.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20150713101607')
7
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
8
-  (0.2ms) begin transaction
9
- Fixture Delete (0.3ms) DELETE FROM "users"
10
- Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('one@example.net', '$2a$04$Ftx/SLqnunNsiEOQGJB7SugvltRumkLLDUxzyJinlzeP2PmuuCd8O', '2016-01-28 23:20:53', '2016-01-28 23:20:53', 980190962)
11
- Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$0R8O7gQYRNgKRiJ/A4J63eCUKwK7iD9emys6U6L5LXs.TedzD6wEq', '2016-01-28 23:20:53', '2016-01-28 23:20:53', 298486374)
12
-  (2.1ms) commit transaction
13
-  (0.1ms) begin transaction
4
+  (1.7ms) CREATE TABLE "vendors" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar, "password_digest" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
5
+  (1.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6
+  (0.1ms) select sqlite_version(*)
7
+  (3.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
8
+  (0.1ms) SELECT version FROM "schema_migrations"
9
+  (1.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20160522181712')
10
+  (1.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20150713101607')
11
+  (1.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20160519075733')
12
+  (1.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20160522051816')
13
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
14
+  (0.1ms) begin transaction
15
+ Fixture Delete (0.2ms) DELETE FROM "admins"
16
+ Fixture Insert (0.1ms) INSERT INTO "admins" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('admin.one@example.net', '$2a$04$A5FrTmvQlWisxRF39Z9ThOxtvxEv3sskQ8Cvu7pMyJOdxKe2.yGQK', '2016-05-29 13:50:27', '2016-05-29 13:50:27', 980190962)
17
+ Fixture Delete (0.1ms) DELETE FROM "composite_name_entities"
18
+ Fixture Insert (0.1ms) INSERT INTO "composite_name_entities" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('composite_name_entity.one@example.net', '$2a$04$btcUJSIV8A1I4v/PGOzg9uwbne073esS6ASsIe.d8w3GoPwv.gali', '2016-05-29 13:50:27', '2016-05-29 13:50:27', 980190962)
19
+ Fixture Delete (0.1ms) DELETE FROM "users"
20
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('one@example.net', '$2a$04$AaJIO4VQSLrEs0Tr4MSc4euqVbJvlKEfWoM7VtwzSIqg3wmlw2bdK', '2016-05-29 13:50:27', '2016-05-29 13:50:27', 980190962)
21
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$g2QbsDNtx7EXGF9oW/HyuOdMaCz9lkRM0dPCuGVVY32MSDkT5syaO', '2016-05-29 13:50:27', '2016-05-29 13:50:27', 298486374)
22
+ Fixture Delete (0.1ms) DELETE FROM "vendors"
23
+ Fixture Insert (0.1ms) INSERT INTO "vendors" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('vendor.one@example.net', '$2a$04$jrsErgp1FpPx4Yoh0AVvFOQW6W3SixzpKgG54MDx4OLhEKl09Xc4W', '2016-05-29 13:50:27', '2016-05-29 13:50:27', 980190962)
24
+  (1.9ms) commit transaction
25
+  (0.0ms) begin transaction
14
26
  -----------------------------------------------------------------------------
15
- Knock::AuthTokenControllerTest: test_responds_with_404_if_user_does_not_exist
27
+ VendorProtectedControllerTest: test_raises_method_missing_error_appropriately
16
28
  -----------------------------------------------------------------------------
17
- Processing by Knock::AuthTokenController#create as HTML
18
- Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
19
- User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "wrong@example.net"]]
20
- Completed 404 Not Found in 7ms (ActiveRecord: 0.3ms)
21
-  (0.1ms) rollback transaction
22
-  (0.1ms) begin transaction
29
+ Processing by VendorProtectedController#show as HTML
30
+ Parameters: {"id"=>"1"}
31
+ Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.0ms)
32
+  (0.1ms) rollback transaction
33
+  (0.0ms) begin transaction
34
+ --------------------------------------------------------------
35
+ VendorProtectedControllerTest: test_responds_with_unauthorized
36
+ --------------------------------------------------------------
37
+ Processing by VendorProtectedController#index as HTML
38
+ Filter chain halted as :authenticate_vendor rendered or redirected
39
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
40
+  (0.1ms) rollback transaction
41
+  (0.1ms) begin transaction
23
42
  -----------------------------------------------------------------------------
24
- Knock::AuthTokenControllerTest: test_responds_with_404_if_password_is_invalid
43
+ VendorProtectedControllerTest: test_has_a_current_vendor_after_authentication
25
44
  -----------------------------------------------------------------------------
26
- User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
27
- Processing by Knock::AuthTokenController#create as HTML
28
- Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
29
- User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
30
- Completed 404 Not Found in 3ms (ActiveRecord: 0.2ms)
45
+ Vendor Load (0.2ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT 1 [["id", 980190962]]
46
+ Processing by VendorProtectedController#index as HTML
47
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT 1 [["id", 980190962]]
48
+ Completed 200 OK in 2ms (ActiveRecord: 0.1ms)
49
+  (0.1ms) rollback transaction
50
+  (0.1ms) begin transaction
51
+ -------------------------------------------------------------------------------
52
+ VendorProtectedControllerTest: test_responds_with_unauthorized_to_invalid_token
53
+ -------------------------------------------------------------------------------
54
+ Processing by VendorProtectedController#index as HTML
55
+ Filter chain halted as :authenticate_vendor rendered or redirected
56
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
57
+  (0.1ms) rollback transaction
58
+  (0.1ms) begin transaction
59
+ --------------------------------------------------------------------------------
60
+ VendorProtectedControllerTest: test_responds_with_unauthorized_to_invalid_entity
61
+ --------------------------------------------------------------------------------
62
+ Processing by VendorProtectedController#index as HTML
63
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT 1 [["id", 0]]
64
+ Filter chain halted as :authenticate_vendor rendered or redirected
65
+ Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
66
+  (0.1ms) rollback transaction
67
+  (0.0ms) begin transaction
68
+ --------------------------------------------------------------------------
69
+ VendorProtectedControllerTest: test_responds_with_success_if_authenticated
70
+ --------------------------------------------------------------------------
71
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT 1 [["id", 980190962]]
72
+ Processing by VendorProtectedController#index as HTML
73
+ Vendor Load (0.0ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT 1 [["id", 980190962]]
74
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
31
75
   (0.1ms) rollback transaction
32
76
   (0.1ms) begin transaction
33
- ------------------------------------------------------
34
- Knock::AuthTokenControllerTest: test_responds_with_201
35
- ------------------------------------------------------
36
- User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
37
- Processing by Knock::AuthTokenController#create as HTML
38
- Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
39
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
40
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
41
- Completed 201 Created in 5ms (Views: 0.3ms | ActiveRecord: 0.2ms)
77
+ --------------------------------------------------------------------------------------------
78
+ CompositeNameEntityProtectedControllerTest: test_responds_with_unauthorized_to_invalid_token
79
+ --------------------------------------------------------------------------------------------
80
+ Processing by CompositeNameEntityProtectedController#index as HTML
81
+ Filter chain halted as :authenticate_composite_name_entity rendered or redirected
82
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
83
+  (0.1ms) rollback transaction
84
+  (0.0ms) begin transaction
85
+ ---------------------------------------------------------------------------------------------
86
+ CompositeNameEntityProtectedControllerTest: test_responds_with_unauthorized_to_invalid_entity
87
+ ---------------------------------------------------------------------------------------------
88
+ Processing by CompositeNameEntityProtectedController#index as HTML
89
+ CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT 1 [["id", 0]]
90
+ Filter chain halted as :authenticate_composite_name_entity rendered or redirected
91
+ Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
42
92
   (0.1ms) rollback transaction
43
-  (0.1ms) begin transaction
44
- -------------------------------------------------------------------------------------
45
- ProtectedResourcesControllerTest: test_accepts_any_prefix_in_the_authorization_header
46
- -------------------------------------------------------------------------------------
47
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
48
- Processing by ProtectedResourcesController#index as HTML
49
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
93
+  (0.0ms) begin transaction
94
+ ---------------------------------------------------------------------------------------------------------
95
+ CompositeNameEntityProtectedControllerTest: test_has_a_current_composite_name_entity_after_authentication
96
+ ---------------------------------------------------------------------------------------------------------
97
+ CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT 1 [["id", 980190962]]
98
+ Processing by CompositeNameEntityProtectedController#index as HTML
99
+ CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT 1 [["id", 980190962]]
50
100
  Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
101
+  (0.1ms) rollback transaction
102
+  (0.0ms) begin transaction
103
+ ---------------------------------------------------------------------------------------
104
+ CompositeNameEntityProtectedControllerTest: test_responds_with_success_if_authenticated
105
+ ---------------------------------------------------------------------------------------
106
+ CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT 1 [["id", 980190962]]
107
+ Processing by CompositeNameEntityProtectedController#index as HTML
108
+ CompositeNameEntity Load (0.0ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT 1 [["id", 980190962]]
109
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
110
+  (0.1ms) rollback transaction
111
+  (0.0ms) begin transaction
112
+ ---------------------------------------------------------------------------
113
+ CompositeNameEntityProtectedControllerTest: test_responds_with_unauthorized
114
+ ---------------------------------------------------------------------------
115
+ Processing by CompositeNameEntityProtectedController#index as HTML
116
+ Filter chain halted as :authenticate_composite_name_entity rendered or redirected
117
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
51
118
   (0.1ms) rollback transaction
52
119
   (0.1ms) begin transaction
53
- ------------------------------------------------------------------------------
54
- ProtectedResourcesControllerTest: test_responds_with_success_with_token_in_url
55
- ------------------------------------------------------------------------------
56
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
57
- Processing by ProtectedResourcesController#index as HTML
58
- Parameters: {"token"=>"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NTQxMDk2NTMsImF1ZCI6ZmFsc2UsInN1YiI6OTgwMTkwOTYyfQ.d4fLV6Mmra4gxopgyHq0c_vz9GVe8Jzku38Waw3jOgM"}
59
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
60
- Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
120
+ -------------------------------------------------------------------------
121
+ Knock::AuthTokenTest: test_verify_audience_when_token_audience_is_present
122
+ -------------------------------------------------------------------------
123
+  (0.0ms) rollback transaction
124
+  (0.0ms) begin transaction
125
+ ---------------------------------------------------------------
126
+ Knock::AuthTokenTest: test_validate_expiration_claim_by_default
127
+ ---------------------------------------------------------------
61
128
   (0.1ms) rollback transaction
62
129
   (0.1ms) begin transaction
63
- ------------------------------------------------------------------------------
64
- ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
65
- ------------------------------------------------------------------------------
66
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
67
- Processing by ProtectedResourcesController#index as HTML
68
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
69
- Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
130
+ ----------------------------------------------------
131
+ Knock::AuthTokenTest: test_decode_RSA_encoded_tokens
132
+ ----------------------------------------------------
70
133
   (0.1ms) rollback transaction
71
134
   (0.1ms) begin transaction
72
- -------------------------------------------------------------------------------------------
73
- ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_url
74
- -------------------------------------------------------------------------------------------
75
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
135
+ ---------------------------------------------------------------------------------------
136
+ Knock::AuthTokenTest: test_does_not_validate_expiration_claim_with_a_nil_token_lifetime
137
+ ---------------------------------------------------------------------------------------
138
+  (0.1ms) rollback transaction
139
+  (0.0ms) begin transaction
140
+ -------------------------------------------------
141
+ Knock::AuthTokenTest: test_encode_tokens_with_RSA
142
+ -------------------------------------------------
143
+  (0.1ms) rollback transaction
144
+  (0.1ms) begin transaction
145
+ -------------------------------------------
146
+ Knock::AuthTokenTest: test_verify_algorithm
147
+ -------------------------------------------
148
+  (0.1ms) rollback transaction
149
+  (0.0ms) begin transaction
150
+ ------------------------------------------
151
+ Knock::AuthTokenTest: test_is_serializable
152
+ ------------------------------------------
153
+  (0.0ms) rollback transaction
154
+  (0.1ms) begin transaction
155
+ ----------------------------------------------------------------------------------------------
156
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_header
157
+ ----------------------------------------------------------------------------------------------
158
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
76
159
  Processing by ProtectedResourcesController#index as HTML
77
- Parameters: {"token"=>"invalid"}
78
160
  Filter chain halted as :authenticate rendered or redirected
79
161
  Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
80
162
   (0.1ms) rollback transaction
81
-  (0.1ms) begin transaction
163
+  (0.0ms) begin transaction
82
164
  ----------------------------------------------------------------------------------
83
165
  ProtectedResourcesControllerTest: test_accepts_authorization_header_without_prefix
84
166
  ----------------------------------------------------------------------------------
@@ -88,15 +170,26 @@ Processing by ProtectedResourcesController#index as HTML
88
170
  Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
89
171
   (0.1ms) rollback transaction
90
172
   (0.1ms) begin transaction
91
- ----------------------------------------------------------------------------------------------
92
- ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_header
93
- ----------------------------------------------------------------------------------------------
173
+ -------------------------------------------------------------------------------------------
174
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_url
175
+ -------------------------------------------------------------------------------------------
94
176
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
95
177
  Processing by ProtectedResourcesController#index as HTML
178
+ Parameters: {"token"=>"invalid"}
96
179
  Filter chain halted as :authenticate rendered or redirected
97
180
  Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
98
181
   (0.1ms) rollback transaction
99
-  (0.1ms) begin transaction
182
+  (0.0ms) begin transaction
183
+ ------------------------------------------------------------------------------
184
+ ProtectedResourcesControllerTest: test_responds_with_success_with_token_in_url
185
+ ------------------------------------------------------------------------------
186
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
187
+ Processing by ProtectedResourcesController#index as HTML
188
+ Parameters: {"token"=>"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NjQ2MTYyMjcsInN1YiI6OTgwMTkwOTYyfQ.ZioYbBATphHQTR5V7AbQ3XE9C-Y2AwSlJwIbFeMJAxA"}
189
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
190
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
191
+  (0.1ms) rollback transaction
192
+  (0.0ms) begin transaction
100
193
  -----------------------------------------------------------------
101
194
  ProtectedResourcesControllerTest: test_responds_with_unauthorized
102
195
  -----------------------------------------------------------------
@@ -105,19 +198,32 @@ Processing by ProtectedResourcesController#index as HTML
105
198
  Filter chain halted as :authenticate rendered or redirected
106
199
  Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
107
200
   (0.1ms) rollback transaction
108
-  (0.1ms) begin transaction
109
- ---------------------------------------------------------------------------------------
110
- ProtectedResourcesControllerTest: test_responds_with_success_with_valid_token_in_header
111
- ---------------------------------------------------------------------------------------
201
+  (0.0ms) begin transaction
202
+ -------------------------------------------------------------------------------------
203
+ ProtectedResourcesControllerTest: test_accepts_any_prefix_in_the_authorization_header
204
+ -------------------------------------------------------------------------------------
112
205
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
113
206
  Processing by ProtectedResourcesController#index as HTML
114
207
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
115
208
  Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
116
209
   (0.1ms) rollback transaction
117
-  (0.1ms) begin transaction
118
- ----------------------------------------------------------------
119
- InstallGeneratorTest: test_Assert_all_files_are_properly_created
120
- ----------------------------------------------------------------
210
+  (0.0ms) begin transaction
211
+ ------------------------------------------------------------------------------
212
+ ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
213
+ ------------------------------------------------------------------------------
214
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
215
+ Processing by ProtectedResourcesController#index as HTML
216
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
217
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
218
+  (0.1ms) rollback transaction
219
+  (0.0ms) begin transaction
220
+ ---------------------------------------------------------------------------------------
221
+ ProtectedResourcesControllerTest: test_responds_with_success_with_valid_token_in_header
222
+ ---------------------------------------------------------------------------------------
223
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
224
+ Processing by ProtectedResourcesController#index as HTML
225
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
226
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
121
227
   (0.1ms) rollback transaction
122
228
   (0.1ms) begin transaction
123
229
  --------------------------------------------------
@@ -128,7 +234,7 @@ Processing by CurrentUsersController#show as HTML
128
234
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
129
235
  Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
130
236
   (0.1ms) rollback transaction
131
-  (0.1ms) begin transaction
237
+  (0.0ms) begin transaction
132
238
  ---------------------------------------------------------------------------
133
239
  CurrentUsersControllerTest: test_responds_with_404_if_user_is_not_logged_in
134
240
  ---------------------------------------------------------------------------
@@ -137,28 +243,164 @@ Processing by CurrentUsersController#show as HTML
137
243
  Completed 404 Not Found in 0ms (ActiveRecord: 0.0ms)
138
244
   (0.1ms) rollback transaction
139
245
   (0.1ms) begin transaction
140
- -------------------------------------------------------------------------
141
- Knock::AuthTokenTest: test_verify_audience_when_token_audience_is_present
142
- -------------------------------------------------------------------------
246
+ ----------------------------------------------------------------
247
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
248
+ ----------------------------------------------------------------
143
249
   (0.1ms) rollback transaction
144
250
   (0.1ms) begin transaction
251
+ ---------------------------------------
252
+ KnockTest: test_setup_block_yields_self
253
+ ---------------------------------------
254
+  (0.0ms) rollback transaction
255
+  (0.1ms) begin transaction
256
+ ------------------------------------------------------------------------
257
+ VendorTokenControllerTest: test_responds_with_404_if_user_does_not_exist
258
+ ------------------------------------------------------------------------
259
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT 1 [["id", 980190962]]
260
+ Processing by VendorTokenController#create as HTML
261
+ Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
262
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."email" = ? LIMIT 1 [["email", "wrong@example.net"]]
263
+ Completed 404 Not Found in 1ms (ActiveRecord: 0.1ms)
264
+  (0.1ms) rollback transaction
265
+  (0.0ms) begin transaction
266
+ ------------------------------------------------------------------------
267
+ VendorTokenControllerTest: test_responds_with_404_if_password_is_invalid
268
+ ------------------------------------------------------------------------
269
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT 1 [["id", 980190962]]
270
+ Processing by VendorTokenController#create as HTML
271
+ Parameters: {"auth"=>{"email"=>"vendor.one@example.net", "password"=>"[FILTERED]"}}
272
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."email" = ? LIMIT 1 [["email", "vendor.one@example.net"]]
273
+ Completed 404 Not Found in 2ms (ActiveRecord: 0.1ms)
274
+  (0.1ms) rollback transaction
275
+  (0.0ms) begin transaction
145
276
  -------------------------------------------------
146
- Knock::AuthTokenTest: test_encode_tokens_with_RSA
277
+ VendorTokenControllerTest: test_responds_with_201
147
278
  -------------------------------------------------
279
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT 1 [["id", 980190962]]
280
+ Processing by VendorTokenController#create as HTML
281
+ Parameters: {"auth"=>{"email"=>"vendor.one@example.net", "password"=>"[FILTERED]"}}
282
+ Vendor Load (0.0ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."email" = ? LIMIT 1 [["email", "vendor.one@example.net"]]
283
+ Completed 201 Created in 2ms (Views: 0.2ms | ActiveRecord: 0.0ms)
148
284
   (0.1ms) rollback transaction
149
285
   (0.1ms) begin transaction
150
- -------------------------------------------
151
- Knock::AuthTokenTest: test_verify_algorithm
152
- -------------------------------------------
153
-  (0.1ms) rollback transaction
154
-  (0.1ms) begin transaction
155
- ----------------------------------------------------
156
- Knock::AuthTokenTest: test_decode_RSA_encoded_tokens
157
- ----------------------------------------------------
158
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
286
+ -------------------------------------------------------------------------------
287
+ AdminProtectedControllerTest: test_responds_with_unauthorized_to_invalid_entity
288
+ -------------------------------------------------------------------------------
289
+ Processing by AdminProtectedController#index as HTML
290
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT 1 [["id", 0]]
291
+ Filter chain halted as :authenticate_admin rendered or redirected
292
+ Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
293
+  (0.1ms) rollback transaction
294
+  (0.0ms) begin transaction
295
+ -------------------------------------------------------------------------
296
+ AdminProtectedControllerTest: test_responds_with_success_if_authenticated
297
+ -------------------------------------------------------------------------
298
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT 1 [["id", 980190962]]
299
+ Processing by AdminProtectedController#index as HTML
300
+ Admin Load (0.0ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT 1 [["id", 980190962]]
301
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
302
+  (0.1ms) rollback transaction
303
+  (0.0ms) begin transaction
304
+ ------------------------------------------------------------------------------
305
+ AdminProtectedControllerTest: test_responds_with_unauthorized_to_invalid_token
306
+ ------------------------------------------------------------------------------
307
+ Processing by AdminProtectedController#index as HTML
308
+ Filter chain halted as :authenticate_admin rendered or redirected
309
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
159
310
   (0.1ms) rollback transaction
160
311
   (0.1ms) begin transaction
161
- ---------------------------------------
162
- KnockTest: test_setup_block_yields_self
163
- ---------------------------------------
312
+ -------------------------------------------------------------
313
+ AdminProtectedControllerTest: test_responds_with_unauthorized
314
+ -------------------------------------------------------------
315
+ Processing by AdminProtectedController#index as HTML
316
+ Filter chain halted as :authenticate_admin rendered or redirected
317
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
318
+  (0.1ms) rollback transaction
319
+  (0.0ms) begin transaction
320
+ ---------------------------------------------------------------------------
321
+ AdminProtectedControllerTest: test_has_a_current_admin_after_authentication
322
+ ---------------------------------------------------------------------------
323
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT 1 [["id", 980190962]]
324
+ Processing by AdminProtectedController#index as HTML
325
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT 1 [["id", 980190962]]
326
+ Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
327
+  (0.1ms) rollback transaction
328
+  (0.1ms) begin transaction
329
+ ------------------------------------------------
330
+ AdminTokenControllerTest: test_responds_with_201
331
+ ------------------------------------------------
332
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT 1 [["id", 980190962]]
333
+ Processing by AdminTokenController#create as HTML
334
+ Parameters: {"auth"=>{"email"=>"admin.one@example.net", "password"=>"[FILTERED]"}}
335
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = ? LIMIT 1 [["email", "admin.one@example.net"]]
336
+ Completed 201 Created in 3ms (Views: 0.2ms | ActiveRecord: 0.1ms)
337
+  (0.1ms) rollback transaction
338
+  (0.0ms) begin transaction
339
+ -----------------------------------------------------------------------
340
+ AdminTokenControllerTest: test_responds_with_404_if_password_is_invalid
341
+ -----------------------------------------------------------------------
342
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT 1 [["id", 980190962]]
343
+ Processing by AdminTokenController#create as HTML
344
+ Parameters: {"auth"=>{"email"=>"admin.one@example.net", "password"=>"[FILTERED]"}}
345
+ Admin Load (0.0ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = ? LIMIT 1 [["email", "admin.one@example.net"]]
346
+ Completed 404 Not Found in 2ms (ActiveRecord: 0.0ms)
347
+  (0.1ms) rollback transaction
348
+  (0.0ms) begin transaction
349
+ -----------------------------------------------------------------------
350
+ AdminTokenControllerTest: test_responds_with_404_if_user_does_not_exist
351
+ -----------------------------------------------------------------------
352
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT 1 [["id", 980190962]]
353
+ Processing by AdminTokenController#create as HTML
354
+ Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
355
+ Admin Load (0.0ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = ? LIMIT 1 [["email", "wrong@example.net"]]
356
+ Completed 404 Not Found in 0ms (ActiveRecord: 0.0ms)
357
+  (0.1ms) rollback transaction
358
+  (0.1ms) begin transaction
359
+ -----------------------------------------------------------------------------
360
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_password_is_invalid
361
+ -----------------------------------------------------------------------------
362
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
363
+ Processing by Knock::AuthTokenController#create as HTML
364
+ Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
365
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
366
+ Completed 404 Not Found in 2ms (ActiveRecord: 0.1ms)
164
367
   (0.1ms) rollback transaction
368
+  (0.1ms) begin transaction
369
+ ------------------------------------------------------
370
+ Knock::AuthTokenControllerTest: test_responds_with_201
371
+ ------------------------------------------------------
372
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
373
+ Processing by Knock::AuthTokenController#create as HTML
374
+ Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
375
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
376
+ Completed 201 Created in 3ms (Views: 0.2ms | ActiveRecord: 0.1ms)
377
+  (0.1ms) rollback transaction
378
+  (0.0ms) begin transaction
379
+ -----------------------------------------------------------------------------
380
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_user_does_not_exist
381
+ -----------------------------------------------------------------------------
382
+ Processing by Knock::AuthTokenController#create as HTML
383
+ Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
384
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "wrong@example.net"]]
385
+ Completed 404 Not Found in 1ms (ActiveRecord: 0.1ms)
386
+  (0.1ms) rollback transaction
387
+  (0.0ms) begin transaction
388
+ ---------------------------------------------------------------------------
389
+ Knock::AuthTokenControllerTest: test_it's_using_configured_custom_exception
390
+ ---------------------------------------------------------------------------
391
+  (0.1ms) rollback transaction
392
+  (0.0ms) begin transaction
393
+ ------------------------------------------------------------
394
+ Knock::AuthTokenControllerTest: test_response_contains_token
395
+ ------------------------------------------------------------
396
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
397
+ Processing by Knock::AuthTokenController#create as HTML
398
+ Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
399
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
400
+ Completed 201 Created in 2ms (Views: 0.2ms | ActiveRecord: 0.1ms)
401
+  (0.1ms) rollback transaction
402
+  (0.1ms) begin transaction
403
+ ------------------------------------------------------------------------
404
+ TokenControllerGeneratorTest: test_assert_all_files_are_properly_created
405
+ ------------------------------------------------------------------------
406
+  (0.1ms) rollback transaction