knock 2.1 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f6b742633bb744818397b30805125c4cd594ab7
4
- data.tar.gz: 1e00ad45596924b74c9b8db53e6c900f9f1e28ea
3
+ metadata.gz: 87269abf24c04590c0cfffd1739a46d65e6c1b64
4
+ data.tar.gz: 311bbb8d16129abe1c1a7bc3f38ea203caed5513
5
5
  SHA512:
6
- metadata.gz: c7dbf7a5aab3ffe4c5ae6d76d65d98fd1ea2d1df4722ff4ea5ecc8af1305e2e88199607bc7d2ea5b80841b258b2710f89e66c2cab385aff89c5f083ab87fdfd8
7
- data.tar.gz: 47f947712ccf9bf8488982fd48175ccffbe4023876952574323c580f55c4c9b75108f26beb525fa22a59cd4a1145d2c31eeecece69a4fb8ca53b652be1861c0b
6
+ metadata.gz: 4b6f661d6d8d56c3f324edf2d0a408502903191693cb4348fa3db3c2a9f469910b5cca705d8dd77947faea9503d2ff9fc9c3e81c6bdce62c7ed6eec7a63eb83a
7
+ data.tar.gz: 5c18461c6303d19111b9ac0b88be2ec50d85a74b091b97a6890809ef06b6c03f202a612ef604d97af64ab3b15bc10e072ce7c32db735eab95d0b873f1e527131
@@ -24,8 +24,10 @@ module Knock::Authenticable
24
24
  end
25
25
 
26
26
  def authenticate_entity(entity_name)
27
- entity_class = entity_name.camelize.constantize
28
- send(:authenticate_for, entity_class)
27
+ if token
28
+ entity_class = entity_name.camelize.constantize
29
+ send(:authenticate_for, entity_class)
30
+ end
29
31
  end
30
32
 
31
33
  def unauthorized_entity(entity_name)
@@ -1,3 +1,3 @@
1
1
  module Knock
2
- VERSION = "2.1"
2
+ VERSION = "2.1.1"
3
3
  end
@@ -0,0 +1,7 @@
1
+ class GuestProtectedController < ApplicationController
2
+ before_action :authenticate_guest
3
+
4
+ def index
5
+ head :ok
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class Guest
2
+ def self.from_token_payload _payload
3
+ # This is to simulate the use of `find_or_create`
4
+ # on an AR model, regardless of the payload content
5
+ new
6
+ end
7
+ end
@@ -2,13 +2,12 @@ Rails.application.routes.draw do
2
2
  post 'admin_token' => 'admin_token#create'
3
3
  post 'vendor_token' => 'vendor_token#create'
4
4
 
5
- resources :protected_resources
6
5
  resource :current_user
7
6
 
8
7
  resources :admin_protected
9
8
  resources :composite_name_entity_protected
10
- resources :vendor_protected
11
9
  resources :custom_unauthorized_entity
12
-
13
- mount Knock::Engine => "/knock"
10
+ resources :guest_protected
11
+ resources :protected_resources
12
+ resources :vendor_protected
14
13
  end
Binary file
@@ -1,68 +1,106 @@
1
-  (9.4ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
2
-  (8.3ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1
+  (6.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
2
+  (7.3ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
4
4
  Migrating to CreateUsers (20150713101607)
5
-  (0.1ms) begin transaction
6
-  (0.3ms) 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)
7
- SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20150713101607"]]
8
-  (2.8ms) commit transaction
5
+  (0.0ms) begin transaction
6
+  (0.4ms) 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)
7
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20150713101607"]]
8
+  (1.9ms) commit transaction
9
9
  Migrating to CreateAdmins (20160519075733)
10
-  (0.1ms) begin transaction
11
-  (0.5ms) 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)
10
+  (0.0ms) begin transaction
11
+  (0.3ms) 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)
12
12
  SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160519075733"]]
13
-  (1.8ms) commit transaction
13
+  (2.5ms) commit transaction
14
14
  Migrating to CreateVendors (20160522051816)
15
15
   (0.0ms) begin transaction
16
-  (0.3ms) 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)
16
+  (0.2ms) 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)
17
17
  SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160522051816"]]
18
-  (1.8ms) commit transaction
18
+  (2.0ms) commit transaction
19
19
  Migrating to CreateCompositeNameEntities (20160522181712)
20
-  (0.1ms) begin transaction
21
-  (0.3ms) 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)
22
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160522181712"]]
23
-  (2.3ms) commit transaction
20
+  (0.0ms) begin transaction
21
+  (0.2ms) 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)
22
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160522181712"]]
23
+  (2.7ms) commit transaction
24
24
  ActiveRecord::InternalMetadata Load (0.2ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", :environment], ["LIMIT", 1]]
25
25
   (0.1ms) begin transaction
26
- SQL (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "test"], ["created_at", 2017-01-30 22:34:49 UTC], ["updated_at", 2017-01-30 22:34:49 UTC]]
27
-  (1.8ms) commit transaction
28
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
26
+ SQL (0.2ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "test"], ["created_at", 2017-02-11 01:43:35 UTC], ["updated_at", 2017-02-11 01:43:35 UTC]]
27
+  (3.5ms) commit transaction
28
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
29
29
  ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
30
30
   (0.1ms) begin transaction
31
31
  Fixture Delete (0.2ms) DELETE FROM "admins"
32
- Fixture Insert (0.1ms) INSERT INTO "admins" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('admin.one@example.net', '$2a$04$uGcHf5gTXrtrXz1xNbc88uMiqAUyTAMkqCg3AMOPwb37YgaGPpztW', '2017-01-30 22:34:52.452212', '2017-01-30 22:34:52.452212', 980190962)
32
+ Fixture Insert (0.1ms) INSERT INTO "admins" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('admin.one@example.net', '$2a$04$Nor8ivXEVNclpP5BNzprY.cyr/.soQk41N.9EX1z7nxTw4IqCK4aS', '2017-02-11 01:43:38.576086', '2017-02-11 01:43:38.576086', 980190962)
33
33
  Fixture Delete (0.1ms) DELETE FROM "composite_name_entities"
34
- 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$mlaZf/ZocmFG87hoVWWSy.Hw1aeUZ5xSfMMmLgBO1/MUy/fDpCCsq', '2017-01-30 22:34:52.456448', '2017-01-30 22:34:52.456448', 980190962)
34
+ 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$bKDuvz4vfQV08qZvnaFZzeoWpjq8gbI0gTlInF.wgZkQMTg7NHqpm', '2017-02-11 01:43:38.580323', '2017-02-11 01:43:38.580323', 980190962)
35
35
  Fixture Delete (0.1ms) DELETE FROM "users"
36
- Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('one@example.net', '$2a$04$0Jv.z4yGtMFYyJDYru5w/.JOz.6Ci65bNXMshFDvLfKAHtHNPGw2m', '2017-01-30 22:34:52.458379', '2017-01-30 22:34:52.458379', 980190962)
37
- Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$qWsslRiKaNJhhCtTua6xxO209ux7nwrExgUfpZCpq8pKgvcfSkRiq', '2017-01-30 22:34:52.458379', '2017-01-30 22:34:52.458379', 298486374)
36
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('one@example.net', '$2a$04$mlvt9hqVLvETsjjb8x3cPOww72bh9MPvsvS.ST3BNdqxTzIxz8QE.', '2017-02-11 01:43:38.582199', '2017-02-11 01:43:38.582199', 980190962)
37
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$WqkWvVjZgddSv.hUWVZoo.6W1zKPoA0iAS3kACxjReu1OVIx4rkfq', '2017-02-11 01:43:38.582199', '2017-02-11 01:43:38.582199', 298486374)
38
38
  Fixture Delete (0.1ms) DELETE FROM "vendors"
39
- Fixture Insert (0.1ms) INSERT INTO "vendors" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('vendor.one@example.net', '$2a$04$yUH8XfsOno528ZxohlDlVe04eESr6mhDfFCjIoJnja2fWi2bzB9aa', '2017-01-30 22:34:52.460595', '2017-01-30 22:34:52.460595', 980190962)
40
-  (129.5ms) commit transaction
39
+ Fixture Insert (0.1ms) INSERT INTO "vendors" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('vendor.one@example.net', '$2a$04$y51Z3Dfd60qGMg5YQyTPmOGhYcP5aBFtyO2lsPnXh5AJrbXqS7PuK', '2017-02-11 01:43:38.584398', '2017-02-11 01:43:38.584398', 980190962)
40
+  (2.3ms) commit transaction
41
41
   (0.1ms) begin transaction
42
- -----------------------------------------------------------------------------
43
- VendorProtectedControllerTest: test_has_a_current_vendor_after_authentication
44
- -----------------------------------------------------------------------------
45
- Vendor Load (0.3ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
46
- Processing by VendorProtectedController#index as HTML
47
- Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
48
- Completed 200 OK in 3ms (ActiveRecord: 0.1ms)
42
+ ------------------------------------------------------------------------
43
+ VendorTokenControllerTest: test_responds_with_404_if_user_does_not_exist
44
+ ------------------------------------------------------------------------
45
+ Vendor Load (0.4ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
46
+ Processing by VendorTokenController#create as HTML
47
+ Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
48
+ Vendor Load (0.3ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."email" = ? LIMIT ? [["email", "wrong@example.net"], ["LIMIT", 1]]
49
+ Completed 404 Not Found in 4ms (ActiveRecord: 0.3ms)
49
50
   (0.1ms) rollback transaction
50
51
   (0.1ms) begin transaction
51
- --------------------------------------------------------------------------
52
- VendorProtectedControllerTest: test_responds_with_success_if_authenticated
53
- --------------------------------------------------------------------------
52
+ -------------------------------------------------
53
+ VendorTokenControllerTest: test_responds_with_201
54
+ -------------------------------------------------
54
55
  Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
55
- Processing by VendorProtectedController#index as HTML
56
+ Processing by VendorTokenController#create as HTML
57
+ Parameters: {"auth"=>{"email"=>"vendor.one@example.net", "password"=>"[FILTERED]"}}
58
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."email" = ? LIMIT ? [["email", "vendor.one@example.net"], ["LIMIT", 1]]
59
+ Completed 201 Created in 6ms (Views: 0.4ms | ActiveRecord: 0.1ms)
60
+  (0.1ms) rollback transaction
61
+  (0.1ms) begin transaction
62
+ ------------------------------------------------------------------------
63
+ VendorTokenControllerTest: test_responds_with_404_if_password_is_invalid
64
+ ------------------------------------------------------------------------
56
65
  Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
57
- Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
66
+ Processing by VendorTokenController#create as HTML
67
+ Parameters: {"auth"=>{"email"=>"vendor.one@example.net", "password"=>"[FILTERED]"}}
68
+ Vendor Load (0.2ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."email" = ? LIMIT ? [["email", "vendor.one@example.net"], ["LIMIT", 1]]
69
+ Completed 404 Not Found in 3ms (ActiveRecord: 0.2ms)
58
70
   (0.1ms) rollback transaction
59
71
   (0.1ms) begin transaction
60
- -------------------------------------------------------------------------------
61
- VendorProtectedControllerTest: test_responds_with_unauthorized_to_invalid_token
62
- -------------------------------------------------------------------------------
63
- Processing by VendorProtectedController#index as HTML
64
- Filter chain halted as :authenticate_vendor rendered or redirected
65
- Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
72
+ --------------------------------------------------------------------
73
+ CustomUnauthorizedEntityControllerTest: test_responds_with_not_found
74
+ --------------------------------------------------------------------
75
+ Processing by CustomUnauthorizedEntityController#index as HTML
76
+ Filter chain halted as :authenticate_user rendered or redirected
77
+ Completed 404 Not Found in 1ms (ActiveRecord: 0.0ms)
78
+  (0.1ms) rollback transaction
79
+  (0.1ms) begin transaction
80
+ -------------------------------------------------------------------------------------
81
+ CustomUnauthorizedEntityControllerTest: test_responds_with_not_found_to_invalid_token
82
+ -------------------------------------------------------------------------------------
83
+ Processing by CustomUnauthorizedEntityController#index as HTML
84
+ Filter chain halted as :authenticate_user rendered or redirected
85
+ Completed 404 Not Found in 1ms (ActiveRecord: 0.0ms)
86
+  (0.1ms) rollback transaction
87
+  (0.1ms) begin transaction
88
+ --------------------------------------------------------------------------------------
89
+ CustomUnauthorizedEntityControllerTest: test_responds_with_not_found_to_invalid_entity
90
+ --------------------------------------------------------------------------------------
91
+ Processing by CustomUnauthorizedEntityController#index as HTML
92
+ User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 0], ["LIMIT", 1]]
93
+ Filter chain halted as :authenticate_user rendered or redirected
94
+ Completed 404 Not Found in 3ms (ActiveRecord: 0.3ms)
95
+  (0.1ms) rollback transaction
96
+  (0.1ms) begin transaction
97
+ -----------------------------------------------------------------------------------
98
+ CustomUnauthorizedEntityControllerTest: test_responds_with_success_if_authenticated
99
+ -----------------------------------------------------------------------------------
100
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
101
+ Processing by CustomUnauthorizedEntityController#index as HTML
102
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
103
+ Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
66
104
   (0.1ms) rollback transaction
67
105
   (0.1ms) begin transaction
68
106
  -----------------------------------------------------------------------------
@@ -70,7 +108,7 @@ VendorProtectedControllerTest: test_raises_method_missing_error_appropriately
70
108
  -----------------------------------------------------------------------------
71
109
  Processing by VendorProtectedController#show as HTML
72
110
  Parameters: {"id"=>"1"}
73
- Completed 500 Internal Server Error in 10ms (ActiveRecord: 0.0ms)
111
+ Completed 500 Internal Server Error in 11ms (ActiveRecord: 0.0ms)
74
112
   (0.1ms) rollback transaction
75
113
   (0.1ms) begin transaction
76
114
  --------------------------------------------------------------------------------
@@ -79,77 +117,105 @@ VendorProtectedControllerTest: test_responds_with_unauthorized_to_invalid_entity
79
117
  Processing by VendorProtectedController#index as HTML
80
118
  Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 0], ["LIMIT", 1]]
81
119
  Filter chain halted as :authenticate_vendor rendered or redirected
82
- Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
120
+ Completed 401 Unauthorized in 8ms (ActiveRecord: 0.1ms)
121
+  (0.1ms) rollback transaction
122
+  (0.1ms) begin transaction
123
+ -------------------------------------------------------------------------------
124
+ VendorProtectedControllerTest: test_responds_with_unauthorized_to_invalid_token
125
+ -------------------------------------------------------------------------------
126
+ Processing by VendorProtectedController#index as HTML
127
+ Filter chain halted as :authenticate_vendor rendered or redirected
128
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
129
+  (0.1ms) rollback transaction
130
+  (0.0ms) begin transaction
131
+ -----------------------------------------------------------------------------
132
+ VendorProtectedControllerTest: test_has_a_current_vendor_after_authentication
133
+ -----------------------------------------------------------------------------
134
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
135
+ Processing by VendorProtectedController#index as HTML
136
+ Vendor Load (0.0ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
137
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
138
+  (0.1ms) rollback transaction
139
+  (0.0ms) begin transaction
140
+ --------------------------------------------------------------------------
141
+ VendorProtectedControllerTest: test_responds_with_success_if_authenticated
142
+ --------------------------------------------------------------------------
143
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
144
+ Processing by VendorProtectedController#index as HTML
145
+ Vendor Load (0.0ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
146
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
83
147
   (0.1ms) rollback transaction
84
148
   (0.0ms) begin transaction
85
149
  --------------------------------------------------------------
86
150
  VendorProtectedControllerTest: test_responds_with_unauthorized
87
151
  --------------------------------------------------------------
88
152
  Processing by VendorProtectedController#index as HTML
89
- Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", nil], ["LIMIT", 1]]
90
153
  Filter chain halted as :authenticate_vendor rendered or redirected
91
- Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
154
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
92
155
   (0.1ms) rollback transaction
93
156
   (0.1ms) begin transaction
94
- ---------------------------------------------------------------------------------------------
95
- CompositeNameEntityProtectedControllerTest: test_responds_with_unauthorized_to_invalid_entity
96
- ---------------------------------------------------------------------------------------------
97
- Processing by CompositeNameEntityProtectedController#index as HTML
98
- CompositeNameEntity Load (0.2ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 0], ["LIMIT", 1]]
99
- Filter chain halted as :authenticate_composite_name_entity rendered or redirected
100
- Completed 401 Unauthorized in 2ms (ActiveRecord: 0.2ms)
157
+ -------------------------------------------------------------
158
+ AdminProtectedControllerTest: test_responds_with_unauthorized
159
+ -------------------------------------------------------------
160
+ Processing by AdminProtectedController#index as HTML
161
+ Filter chain halted as :authenticate_admin rendered or redirected
162
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
101
163
   (0.1ms) rollback transaction
102
-  (0.1ms) begin transaction
103
- ---------------------------------------------------------------------------------------------------------
104
- CompositeNameEntityProtectedControllerTest: test_has_a_current_composite_name_entity_after_authentication
105
- ---------------------------------------------------------------------------------------------------------
106
- CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
107
- Processing by CompositeNameEntityProtectedController#index as HTML
108
- CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
109
- Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
164
+  (0.0ms) begin transaction
165
+ -------------------------------------------------------------------------------
166
+ AdminProtectedControllerTest: test_responds_with_unauthorized_to_invalid_entity
167
+ -------------------------------------------------------------------------------
168
+ Processing by AdminProtectedController#index as HTML
169
+ Admin Load (0.2ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 0], ["LIMIT", 1]]
170
+ Filter chain halted as :authenticate_admin rendered or redirected
171
+ Completed 401 Unauthorized in 2ms (ActiveRecord: 0.2ms)
110
172
   (0.1ms) rollback transaction
111
-  (0.1ms) begin transaction
173
+  (0.0ms) begin transaction
174
+ ------------------------------------------------------------------------------
175
+ AdminProtectedControllerTest: test_responds_with_unauthorized_to_invalid_token
176
+ ------------------------------------------------------------------------------
177
+ Processing by AdminProtectedController#index as HTML
178
+ Filter chain halted as :authenticate_admin rendered or redirected
179
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
180
+  (0.0ms) rollback transaction
181
+  (0.0ms) begin transaction
112
182
  ---------------------------------------------------------------------------
113
- CompositeNameEntityProtectedControllerTest: test_responds_with_unauthorized
183
+ AdminProtectedControllerTest: test_has_a_current_admin_after_authentication
114
184
  ---------------------------------------------------------------------------
115
- Processing by CompositeNameEntityProtectedController#index as HTML
116
- CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", nil], ["LIMIT", 1]]
117
- Filter chain halted as :authenticate_composite_name_entity rendered or redirected
118
- Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
119
-  (0.1ms) rollback transaction
120
-  (0.1ms) begin transaction
121
- --------------------------------------------------------------------------------------------
122
- CompositeNameEntityProtectedControllerTest: test_responds_with_unauthorized_to_invalid_token
123
- --------------------------------------------------------------------------------------------
124
- Processing by CompositeNameEntityProtectedController#index as HTML
125
- Filter chain halted as :authenticate_composite_name_entity rendered or redirected
126
- Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
185
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
186
+ Processing by AdminProtectedController#index as HTML
187
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
188
+ Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
127
189
   (0.1ms) rollback transaction
128
190
   (0.0ms) begin transaction
129
- ---------------------------------------------------------------------------------------
130
- CompositeNameEntityProtectedControllerTest: test_responds_with_success_if_authenticated
131
- ---------------------------------------------------------------------------------------
132
- CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
133
- Processing by CompositeNameEntityProtectedController#index as HTML
134
- CompositeNameEntity Load (0.0ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
191
+ -------------------------------------------------------------------------
192
+ AdminProtectedControllerTest: test_responds_with_success_if_authenticated
193
+ -------------------------------------------------------------------------
194
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
195
+ Processing by AdminProtectedController#index as HTML
196
+ Admin Load (0.0ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
135
197
  Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
136
198
   (0.1ms) rollback transaction
137
199
   (0.1ms) begin transaction
138
- ------------------------------------------------------------------------
139
- TokenControllerGeneratorTest: test_assert_all_files_are_properly_created
140
- ------------------------------------------------------------------------
141
-  (0.1ms) rollback transaction
142
-  (0.1ms) begin transaction
143
200
  ------------------------------------------------------------------------------
144
201
  ProtectedResourcesControllerTest: test_responds_with_success_with_token_in_url
145
202
  ------------------------------------------------------------------------------
146
- User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
203
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
147
204
  Processing by ProtectedResourcesController#index as HTML
148
- Parameters: {"token"=>"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0ODU5MDIwOTIsInN1YiI6OTgwMTkwOTYyfQ.mXZ2Kj1BABftUQzk82aoUWpwAFYYdbU3FC38X7zYgIQ"}
205
+ Parameters: {"token"=>"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0ODY4NjM4MTgsInN1YiI6OTgwMTkwOTYyfQ.fD4eDhHzI9v5ED7-7ASNDYGEZ4XXKTKS7IxKwf1SyV4"}
206
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
207
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
208
+  (0.1ms) rollback transaction
209
+  (0.0ms) begin transaction
210
+ ------------------------------------------------------------------------------
211
+ ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
212
+ ------------------------------------------------------------------------------
149
213
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
150
- Completed 200 OK in 2ms (ActiveRecord: 0.1ms)
214
+ Processing by ProtectedResourcesController#index as HTML
215
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
216
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
151
217
   (0.1ms) rollback transaction
152
-  (0.1ms) begin transaction
218
+  (0.0ms) begin transaction
153
219
  ---------------------------------------------------------------------------------------
154
220
  ProtectedResourcesControllerTest: test_responds_with_success_with_valid_token_in_header
155
221
  ---------------------------------------------------------------------------------------
@@ -157,42 +223,31 @@ ProtectedResourcesControllerTest: test_responds_with_success_with_valid_token_in
157
223
  Processing by ProtectedResourcesController#index as HTML
158
224
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
159
225
  Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
160
-  (0.1ms) rollback transaction
161
-  (0.1ms) begin transaction
162
- -----------------------------------------------------------------
163
- ProtectedResourcesControllerTest: test_responds_with_unauthorized
164
- -----------------------------------------------------------------
165
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
166
- Processing by ProtectedResourcesController#index as HTML
167
- User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", nil], ["LIMIT", 1]]
168
- Filter chain halted as :authenticate_user rendered or redirected
169
- Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)
170
226
   (0.1ms) rollback transaction
171
227
   (0.0ms) begin transaction
172
228
  -------------------------------------------------------------------------------------
173
229
  ProtectedResourcesControllerTest: test_accepts_any_prefix_in_the_authorization_header
174
230
  -------------------------------------------------------------------------------------
175
231
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
176
- Processing by ProtectedResourcesController#index as HTML
177
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
178
- Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
179
-  (0.1ms) rollback transaction
180
-  (0.1ms) begin transaction
181
- ------------------------------------------------------------------------------
182
- ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
183
- ------------------------------------------------------------------------------
184
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
185
232
  Processing by ProtectedResourcesController#index as HTML
186
233
  User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
187
234
  Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
188
235
   (0.1ms) rollback transaction
189
236
   (0.0ms) begin transaction
190
- -------------------------------------------------------------------------------------------
191
- ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_url
192
- -------------------------------------------------------------------------------------------
237
+ -----------------------------------------------------------------
238
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized
239
+ -----------------------------------------------------------------
240
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
241
+ Processing by ProtectedResourcesController#index as HTML
242
+ Filter chain halted as :authenticate_user rendered or redirected
243
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
244
+  (0.1ms) rollback transaction
245
+  (0.1ms) begin transaction
246
+ ----------------------------------------------------------------------------------------------
247
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_header
248
+ ----------------------------------------------------------------------------------------------
193
249
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
194
250
  Processing by ProtectedResourcesController#index as HTML
195
- Parameters: {"token"=>"invalid"}
196
251
  Filter chain halted as :authenticate_user rendered or redirected
197
252
  Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
198
253
   (0.1ms) rollback transaction
@@ -206,43 +261,19 @@ Processing by ProtectedResourcesController#index as HTML
206
261
  Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
207
262
   (0.1ms) rollback transaction
208
263
   (0.0ms) begin transaction
209
- ----------------------------------------------------------------------------------------------
210
- ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_header
211
- ----------------------------------------------------------------------------------------------
264
+ -------------------------------------------------------------------------------------------
265
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_url
266
+ -------------------------------------------------------------------------------------------
212
267
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
213
268
  Processing by ProtectedResourcesController#index as HTML
269
+ Parameters: {"token"=>"invalid"}
214
270
  Filter chain halted as :authenticate_user rendered or redirected
215
271
  Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
216
272
   (0.1ms) rollback transaction
217
273
   (0.1ms) begin transaction
218
- -------------------------------------------------
219
- VendorTokenControllerTest: test_responds_with_201
220
- -------------------------------------------------
221
- Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
222
- Processing by VendorTokenController#create as HTML
223
- Parameters: {"auth"=>{"email"=>"vendor.one@example.net", "password"=>"[FILTERED]"}}
224
- Vendor Load (0.2ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."email" = ? LIMIT ? [["email", "vendor.one@example.net"], ["LIMIT", 1]]
225
- Completed 201 Created in 4ms (Views: 0.3ms | ActiveRecord: 0.2ms)
226
-  (0.1ms) rollback transaction
227
-  (0.1ms) begin transaction
228
274
  ------------------------------------------------------------------------
229
- VendorTokenControllerTest: test_responds_with_404_if_password_is_invalid
230
- ------------------------------------------------------------------------
231
- Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
232
- Processing by VendorTokenController#create as HTML
233
- Parameters: {"auth"=>{"email"=>"vendor.one@example.net", "password"=>"[FILTERED]"}}
234
- Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."email" = ? LIMIT ? [["email", "vendor.one@example.net"], ["LIMIT", 1]]
235
- Completed 404 Not Found in 2ms (ActiveRecord: 0.1ms)
236
-  (0.1ms) rollback transaction
237
-  (0.1ms) begin transaction
238
- ------------------------------------------------------------------------
239
- VendorTokenControllerTest: test_responds_with_404_if_user_does_not_exist
275
+ TokenControllerGeneratorTest: test_assert_all_files_are_properly_created
240
276
  ------------------------------------------------------------------------
241
- Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
242
- Processing by VendorTokenController#create as HTML
243
- Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
244
- Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."email" = ? LIMIT ? [["email", "wrong@example.net"], ["LIMIT", 1]]
245
- Completed 404 Not Found in 1ms (ActiveRecord: 0.1ms)
246
277
   (0.1ms) rollback transaction
247
278
   (0.1ms) begin transaction
248
279
  ------------------------------------------------
@@ -251,10 +282,10 @@ AdminTokenControllerTest: test_responds_with_201
251
282
  Admin Load (0.2ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
252
283
  Processing by AdminTokenController#create as HTML
253
284
  Parameters: {"auth"=>{"email"=>"admin.one@example.net", "password"=>"[FILTERED]"}}
254
- Admin Load (0.2ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = ? LIMIT ? [["email", "admin.one@example.net"], ["LIMIT", 1]]
255
- Completed 201 Created in 3ms (Views: 0.3ms | ActiveRecord: 0.2ms)
285
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = ? LIMIT ? [["email", "admin.one@example.net"], ["LIMIT", 1]]
286
+ Completed 201 Created in 3ms (Views: 0.2ms | ActiveRecord: 0.1ms)
256
287
   (0.1ms) rollback transaction
257
-  (0.1ms) begin transaction
288
+  (0.0ms) begin transaction
258
289
  -----------------------------------------------------------------------
259
290
  AdminTokenControllerTest: test_responds_with_404_if_password_is_invalid
260
291
  -----------------------------------------------------------------------
@@ -264,146 +295,83 @@ Processing by AdminTokenController#create as HTML
264
295
  Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = ? LIMIT ? [["email", "admin.one@example.net"], ["LIMIT", 1]]
265
296
  Completed 404 Not Found in 2ms (ActiveRecord: 0.1ms)
266
297
   (0.1ms) rollback transaction
267
-  (0.1ms) begin transaction
298
+  (0.0ms) begin transaction
268
299
  -----------------------------------------------------------------------
269
300
  AdminTokenControllerTest: test_responds_with_404_if_user_does_not_exist
270
301
  -----------------------------------------------------------------------
271
302
  Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
272
303
  Processing by AdminTokenController#create as HTML
273
304
  Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
274
- Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = ? LIMIT ? [["email", "wrong@example.net"], ["LIMIT", 1]]
275
- Completed 404 Not Found in 0ms (ActiveRecord: 0.1ms)
305
+ Admin Load (0.0ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = ? LIMIT ? [["email", "wrong@example.net"], ["LIMIT", 1]]
306
+ Completed 404 Not Found in 0ms (ActiveRecord: 0.0ms)
276
307
   (0.1ms) rollback transaction
277
308
   (0.1ms) begin transaction
278
- -----------------------------------------------------
279
- CurrentUsersControllerTest: test_responds_with_200_#2
280
- -----------------------------------------------------
281
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
282
- Processing by CurrentUsersController#show as HTML
283
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
309
+ ---------------------------------------------------------------------------------------
310
+ CompositeNameEntityProtectedControllerTest: test_responds_with_success_if_authenticated
311
+ ---------------------------------------------------------------------------------------
312
+ CompositeNameEntity Load (0.2ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
313
+ Processing by CompositeNameEntityProtectedController#index as HTML
314
+ CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
284
315
  Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
285
316
   (0.1ms) rollback transaction
286
317
   (0.1ms) begin transaction
287
- --------------------------------------------------
288
- CurrentUsersControllerTest: test_responds_with_200
289
- --------------------------------------------------
290
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
291
- Processing by CurrentUsersController#show as HTML
292
- User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
293
- Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
294
-  (0.1ms) rollback transaction
295
-  (0.1ms) begin transaction
296
- ---------------------------------------------------------------------------
297
- CurrentUsersControllerTest: test_responds_with_404_if_user_is_not_logged_in
298
- ---------------------------------------------------------------------------
299
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
300
- Processing by CurrentUsersController#show as HTML
301
- User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", nil], ["LIMIT", 1]]
302
- Completed 404 Not Found in 1ms (ActiveRecord: 0.0ms)
303
-  (0.1ms) rollback transaction
304
-  (0.1ms) begin transaction
305
- ----------------------------------------------------------------
306
- InstallGeneratorTest: test_Assert_all_files_are_properly_created
307
- ----------------------------------------------------------------
308
-  (0.1ms) rollback transaction
309
-  (0.1ms) begin transaction
310
- --------------------------------------------------------------------
311
- CustomUnauthorizedEntityControllerTest: test_responds_with_not_found
312
- --------------------------------------------------------------------
313
- Processing by CustomUnauthorizedEntityController#index as HTML
314
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", nil], ["LIMIT", 1]]
315
- Filter chain halted as :authenticate_user rendered or redirected
316
- Completed 404 Not Found in 1ms (ActiveRecord: 0.1ms)
317
-  (0.1ms) rollback transaction
318
-  (0.1ms) begin transaction
319
- --------------------------------------------------------------------------------------
320
- CustomUnauthorizedEntityControllerTest: test_responds_with_not_found_to_invalid_entity
321
- --------------------------------------------------------------------------------------
322
- Processing by CustomUnauthorizedEntityController#index as HTML
323
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 0], ["LIMIT", 1]]
324
- Filter chain halted as :authenticate_user rendered or redirected
325
- Completed 404 Not Found in 1ms (ActiveRecord: 0.1ms)
318
+ ---------------------------------------------------------------------------------------------
319
+ CompositeNameEntityProtectedControllerTest: test_responds_with_unauthorized_to_invalid_entity
320
+ ---------------------------------------------------------------------------------------------
321
+ Processing by CompositeNameEntityProtectedController#index as HTML
322
+ CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 0], ["LIMIT", 1]]
323
+ Filter chain halted as :authenticate_composite_name_entity rendered or redirected
324
+ Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
326
325
   (0.1ms) rollback transaction
327
326
   (0.0ms) begin transaction
328
- -------------------------------------------------------------------------------------
329
- CustomUnauthorizedEntityControllerTest: test_responds_with_not_found_to_invalid_token
330
- -------------------------------------------------------------------------------------
331
- Processing by CustomUnauthorizedEntityController#index as HTML
332
- Filter chain halted as :authenticate_user rendered or redirected
333
- Completed 404 Not Found in 0ms (ActiveRecord: 0.0ms)
334
-  (0.1ms) rollback transaction
327
+ --------------------------------------------------------------------------------------------
328
+ CompositeNameEntityProtectedControllerTest: test_responds_with_unauthorized_to_invalid_token
329
+ --------------------------------------------------------------------------------------------
330
+ Processing by CompositeNameEntityProtectedController#index as HTML
331
+ Filter chain halted as :authenticate_composite_name_entity rendered or redirected
332
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
333
+  (0.0ms) rollback transaction
335
334
   (0.1ms) begin transaction
336
- -----------------------------------------------------------------------------------
337
- CustomUnauthorizedEntityControllerTest: test_responds_with_success_if_authenticated
338
- -----------------------------------------------------------------------------------
339
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
340
- Processing by CustomUnauthorizedEntityController#index as HTML
341
- User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
335
+ ---------------------------------------------------------------------------------------------------------
336
+ CompositeNameEntityProtectedControllerTest: test_has_a_current_composite_name_entity_after_authentication
337
+ ---------------------------------------------------------------------------------------------------------
338
+ CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
339
+ Processing by CompositeNameEntityProtectedController#index as HTML
340
+ CompositeNameEntity Load (0.0ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
342
341
  Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
343
342
   (0.1ms) rollback transaction
344
-  (0.1ms) begin transaction
345
- ------------------------------------------------------------------------------
346
- AdminProtectedControllerTest: test_responds_with_unauthorized_to_invalid_token
347
- ------------------------------------------------------------------------------
348
- Processing by AdminProtectedController#index as HTML
349
- Filter chain halted as :authenticate_admin rendered or redirected
350
- Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)
343
+  (0.0ms) begin transaction
344
+ ---------------------------------------------------------------------------
345
+ CompositeNameEntityProtectedControllerTest: test_responds_with_unauthorized
346
+ ---------------------------------------------------------------------------
347
+ Processing by CompositeNameEntityProtectedController#index as HTML
348
+ Filter chain halted as :authenticate_composite_name_entity rendered or redirected
349
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
351
350
   (0.1ms) rollback transaction
352
351
   (0.1ms) begin transaction
353
- -------------------------------------------------------------------------
354
- AdminProtectedControllerTest: test_responds_with_success_if_authenticated
355
- -------------------------------------------------------------------------
356
- Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
357
- Processing by AdminProtectedController#index as HTML
358
- Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
359
- Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
352
+ ----------------------------------------------------
353
+ Knock::AuthTokenTest: test_decode_RSA_encoded_tokens
354
+ ----------------------------------------------------
360
355
   (0.1ms) rollback transaction
361
356
   (0.1ms) begin transaction
362
- -------------------------------------------------------------
363
- AdminProtectedControllerTest: test_responds_with_unauthorized
364
- -------------------------------------------------------------
365
- Processing by AdminProtectedController#index as HTML
366
- Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", nil], ["LIMIT", 1]]
367
- Filter chain halted as :authenticate_admin rendered or redirected
368
- Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
369
-  (0.1ms) rollback transaction
370
-  (0.0ms) begin transaction
371
- -------------------------------------------------------------------------------
372
- AdminProtectedControllerTest: test_responds_with_unauthorized_to_invalid_entity
373
- -------------------------------------------------------------------------------
374
- Processing by AdminProtectedController#index as HTML
375
- Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 0], ["LIMIT", 1]]
376
- Filter chain halted as :authenticate_admin rendered or redirected
377
- Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
378
-  (0.1ms) rollback transaction
379
-  (0.0ms) begin transaction
380
- ---------------------------------------------------------------------------
381
- AdminProtectedControllerTest: test_has_a_current_admin_after_authentication
382
- ---------------------------------------------------------------------------
383
- Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
384
- Processing by AdminProtectedController#index as HTML
385
- Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
386
- Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
357
+ ------------------------------------------------------------------------------------------
358
+ Knock::AuthTokenTest: test_does_not_validate_aud_when_verify_options[:verify_aud]_is_false
359
+ ------------------------------------------------------------------------------------------
387
360
   (0.1ms) rollback transaction
388
361
   (0.1ms) begin transaction
389
- --------------------------------------------------------------------------------
390
- Knock::AuthTokenTest: test_validate_aud_when_verify_options[:verify_aud]_is_true
391
- --------------------------------------------------------------------------------
362
+ ---------------------------------------------------------------
363
+ Knock::AuthTokenTest: test_validate_expiration_claim_by_default
364
+ ---------------------------------------------------------------
392
365
   (0.1ms) rollback transaction
393
-  (0.0ms) begin transaction
394
- -------------------------------------------------------------------------
395
- Knock::AuthTokenTest: test_verify_audience_when_token_audience_is_present
396
- -------------------------------------------------------------------------
397
-  (0.0ms) rollback transaction
398
366
   (0.1ms) begin transaction
399
367
  --------------------------------------------------------------------------------------------------------
400
368
  Knock::AuthTokenTest: test_does_not_validate_expiration_when_verify_options[:verify_expiration]_is_false
401
369
  --------------------------------------------------------------------------------------------------------
402
370
   (0.1ms) rollback transaction
403
-  (0.0ms) begin transaction
404
- ----------------------------------------------------
405
- Knock::AuthTokenTest: test_decode_RSA_encoded_tokens
406
- ----------------------------------------------------
371
+  (0.1ms) begin transaction
372
+ --------------------------------------------------------------------------------
373
+ Knock::AuthTokenTest: test_validate_aud_when_verify_options[:verify_aud]_is_true
374
+ --------------------------------------------------------------------------------
407
375
   (0.1ms) rollback transaction
408
376
   (0.1ms) begin transaction
409
377
  ----------------------------------------------------------------------------------------------
@@ -411,26 +379,26 @@ Knock::AuthTokenTest: test_validate_expiration_when_verify_options[:verify_expir
411
379
  ----------------------------------------------------------------------------------------------
412
380
   (0.1ms) rollback transaction
413
381
   (0.1ms) begin transaction
414
- ------------------------------------------------------------
415
- Knock::AuthTokenTest: test_Knock::AuthToken_has_all_payloads
416
- ------------------------------------------------------------
417
-  (0.1ms) rollback transaction
418
-  (0.1ms) begin transaction
419
- ------------------------------------------------------------------------------------------
420
- Knock::AuthTokenTest: test_does_not_validate_aud_when_verify_options[:verify_aud]_is_false
421
- ------------------------------------------------------------------------------------------
422
-  (0.1ms) rollback transaction
423
-  (0.0ms) begin transaction
424
382
  -------------------------------------------
425
383
  Knock::AuthTokenTest: test_verify_algorithm
426
384
  -------------------------------------------
427
385
   (0.1ms) rollback transaction
428
386
   (0.0ms) begin transaction
387
+ -------------------------------------------------------------------------
388
+ Knock::AuthTokenTest: test_verify_audience_when_token_audience_is_present
389
+ -------------------------------------------------------------------------
390
+  (0.1ms) rollback transaction
391
+  (0.0ms) begin transaction
429
392
  ---------------------------------------------------------------------------------------
430
393
  Knock::AuthTokenTest: test_does_not_validate_expiration_claim_with_a_nil_token_lifetime
431
394
  ---------------------------------------------------------------------------------------
432
395
   (0.1ms) rollback transaction
433
396
   (0.1ms) begin transaction
397
+ ------------------------------------------------------------
398
+ Knock::AuthTokenTest: test_Knock::AuthToken_has_all_payloads
399
+ ------------------------------------------------------------
400
+  (0.1ms) rollback transaction
401
+  (0.0ms) begin transaction
434
402
  -------------------------------------------------
435
403
  Knock::AuthTokenTest: test_encode_tokens_with_RSA
436
404
  -------------------------------------------------
@@ -441,12 +409,54 @@ Knock::AuthTokenTest: test_is_serializable
441
409
  ------------------------------------------
442
410
   (0.1ms) rollback transaction
443
411
   (0.1ms) begin transaction
444
- ---------------------------------------------------------------
445
- Knock::AuthTokenTest: test_validate_expiration_claim_by_default
446
- ---------------------------------------------------------------
447
-  (0.1ms) rollback transaction
448
-  (0.1ms) begin transaction
449
412
  ---------------------------------------
450
413
  KnockTest: test_setup_block_yields_self
451
414
  ---------------------------------------
415
+  (0.0ms) rollback transaction
416
+  (0.1ms) begin transaction
417
+ -----------------------------------------------------
418
+ CurrentUsersControllerTest: test_responds_with_200_#2
419
+ -----------------------------------------------------
420
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
421
+ Processing by CurrentUsersController#show as HTML
422
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
423
+ Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
424
+  (0.1ms) rollback transaction
425
+  (0.1ms) begin transaction
426
+ ---------------------------------------------------------------------------
427
+ CurrentUsersControllerTest: test_responds_with_404_if_user_is_not_logged_in
428
+ ---------------------------------------------------------------------------
429
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
430
+ Processing by CurrentUsersController#show as HTML
431
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", nil], ["LIMIT", 1]]
432
+ Completed 404 Not Found in 1ms (ActiveRecord: 0.1ms)
433
+  (0.1ms) rollback transaction
434
+  (0.1ms) begin transaction
435
+ --------------------------------------------------
436
+ CurrentUsersControllerTest: test_responds_with_200
437
+ --------------------------------------------------
438
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
439
+ Processing by CurrentUsersController#show as HTML
440
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
441
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
442
+  (0.1ms) rollback transaction
443
+  (0.1ms) begin transaction
444
+ ----------------------------------------------------------------
445
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
446
+ ----------------------------------------------------------------
447
+  (0.1ms) rollback transaction
448
+  (0.1ms) begin transaction
449
+ ---------------------------------------------------------------------------------------
450
+ GuestProtectedControllerTest: test_responds_with_unauthorized_when_no_token_is_provided
451
+ ---------------------------------------------------------------------------------------
452
+ Processing by GuestProtectedController#index as HTML
453
+ Filter chain halted as :authenticate_guest rendered or redirected
454
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
455
+  (0.1ms) rollback transaction
456
+  (0.1ms) begin transaction
457
+ -----------------------------------------------------------------------------------------
458
+ GuestProtectedControllerTest: test_responds_with_success_with_a_valid_token_in_the_header
459
+ -----------------------------------------------------------------------------------------
460
+ Processing by GuestProtectedController#index as HTML
461
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
452
462
   (0.1ms) rollback transaction
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+
3
+ class GuestProtectedControllerTest < ActionController::TestCase
4
+ def setup
5
+ @token = Knock::AuthToken.new(payload: { sub: "1" }).token
6
+ end
7
+
8
+ def authenticate token: @token
9
+ @request.env['HTTP_AUTHORIZATION'] = "Bearer #{token}"
10
+ end
11
+
12
+ test "responds with unauthorized when no token is provided" do
13
+ get :index
14
+ assert_response :unauthorized
15
+ end
16
+
17
+ test "responds with success with a valid token in the header" do
18
+ authenticate
19
+ get :index
20
+ assert_response :success
21
+ end
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knock
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.1'
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud MESUREUR
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-01-30 00:00:00.000000000 Z
12
+ date: 2017-02-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -113,12 +113,14 @@ files:
113
113
  - test/dummy/app/controllers/composite_name_entity_protected_controller.rb
114
114
  - test/dummy/app/controllers/current_users_controller.rb
115
115
  - test/dummy/app/controllers/custom_unauthorized_entity_controller.rb
116
+ - test/dummy/app/controllers/guest_protected_controller.rb
116
117
  - test/dummy/app/controllers/protected_resources_controller.rb
117
118
  - test/dummy/app/controllers/vendor_protected_controller.rb
118
119
  - test/dummy/app/controllers/vendor_token_controller.rb
119
120
  - test/dummy/app/helpers/application_helper.rb
120
121
  - test/dummy/app/models/admin.rb
121
122
  - test/dummy/app/models/composite_name_entity.rb
123
+ - test/dummy/app/models/guest.rb
122
124
  - test/dummy/app/models/user.rb
123
125
  - test/dummy/app/models/vendor.rb
124
126
  - test/dummy/app/views/layouts/application.html.erb
@@ -162,6 +164,7 @@ files:
162
164
  - test/dummy/test/controllers/composite_name_entity_protected_controller_test.rb
163
165
  - test/dummy/test/controllers/current_users_controller_test.rb
164
166
  - test/dummy/test/controllers/custom_unauthorized_entity_controller_test.rb
167
+ - test/dummy/test/controllers/guest_protected_controller_test.rb
165
168
  - test/dummy/test/controllers/protected_resources_controller_test.rb
166
169
  - test/dummy/test/controllers/vendor_protected_controller_test.rb
167
170
  - test/dummy/test/controllers/vendor_token_controller_test.rb
@@ -214,12 +217,14 @@ test_files:
214
217
  - test/dummy/app/controllers/composite_name_entity_protected_controller.rb
215
218
  - test/dummy/app/controllers/current_users_controller.rb
216
219
  - test/dummy/app/controllers/custom_unauthorized_entity_controller.rb
220
+ - test/dummy/app/controllers/guest_protected_controller.rb
217
221
  - test/dummy/app/controllers/protected_resources_controller.rb
218
222
  - test/dummy/app/controllers/vendor_protected_controller.rb
219
223
  - test/dummy/app/controllers/vendor_token_controller.rb
220
224
  - test/dummy/app/helpers/application_helper.rb
221
225
  - test/dummy/app/models/admin.rb
222
226
  - test/dummy/app/models/composite_name_entity.rb
227
+ - test/dummy/app/models/guest.rb
223
228
  - test/dummy/app/models/user.rb
224
229
  - test/dummy/app/models/vendor.rb
225
230
  - test/dummy/app/views/layouts/application.html.erb
@@ -263,6 +268,7 @@ test_files:
263
268
  - test/dummy/test/controllers/composite_name_entity_protected_controller_test.rb
264
269
  - test/dummy/test/controllers/current_users_controller_test.rb
265
270
  - test/dummy/test/controllers/custom_unauthorized_entity_controller_test.rb
271
+ - test/dummy/test/controllers/guest_protected_controller_test.rb
266
272
  - test/dummy/test/controllers/protected_resources_controller_test.rb
267
273
  - test/dummy/test/controllers/vendor_protected_controller_test.rb
268
274
  - test/dummy/test/controllers/vendor_token_controller_test.rb