knock 2.0 → 2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YmRmOTA3ZDVjNTA1ZjFiOWYwMmRlYjYwNzkyY2UzNTIzMWFhZGEyNQ==
5
- data.tar.gz: !binary |-
6
- ZGE1ZDRlNjhmMzY5Y2ZjMDc4Y2RkMjJkMGQxMWRkZDQ4NTczYzQ2MQ==
2
+ SHA1:
3
+ metadata.gz: 0f6b742633bb744818397b30805125c4cd594ab7
4
+ data.tar.gz: 1e00ad45596924b74c9b8db53e6c900f9f1e28ea
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZWMxMmY2Y2IxNzZlNzQzYWZmNTUzNzI0ZjZiODBiNGEzMWVlZTNjNTI4Mzdh
10
- NjU5MzgwMDcwMDNiOTI3NWNjZTczZjJlMjYwNjg4NDQxMzJlZDNmY2Y3NTI4
11
- MDRjOGJjZDI5OWRhYzg2Mjg1NzY3MzZhZWQ0NzljMTY4NjI0Mjc=
12
- data.tar.gz: !binary |-
13
- ZWQ2Mjc4OWRiNGIxYjk2MTdiNWQyNWE2OTk5ZjZkMTIyMmI3OWIzMTIyYmIx
14
- NGM0M2UyMDY0OGZiNDc4N2U1NTVhYmQ1MjIyY2I0MWFiYmFhYTEzMWQ0Yzc5
15
- MDgxNTNiN2FiMDg4YmUxNzYwOTI0M2MwM2Y5YzEzNDY5OWYwNjY=
6
+ metadata.gz: c7dbf7a5aab3ffe4c5ae6d76d65d98fd1ea2d1df4722ff4ea5ecc8af1305e2e88199607bc7d2ea5b80841b258b2710f89e66c2cab385aff89c5f083ab87fdfd8
7
+ data.tar.gz: 47f947712ccf9bf8488982fd48175ccffbe4023876952574323c580f55c4c9b75108f26beb525fa22a59cd4a1145d2c31eeecece69a4fb8ca53b652be1861c0b
@@ -37,7 +37,7 @@ module Knock
37
37
  end
38
38
 
39
39
  def entity_name
40
- self.class.name.split('TokenController').first
40
+ self.class.name.scan(/\w+/).last.split('TokenController').first
41
41
  end
42
42
 
43
43
  def auth_params
@@ -5,13 +5,13 @@ module Knock
5
5
  attr_reader :token
6
6
  attr_reader :payload
7
7
 
8
- def initialize payload: {}, token: nil
8
+ def initialize payload: {}, token: nil, verify_options: {}
9
9
  if token.present?
10
- @payload, _ = JWT.decode token, decode_key, true, options
10
+ @payload, _ = JWT.decode token, decode_key, true, options.merge(verify_options)
11
11
  @token = token
12
12
  else
13
- @payload = payload
14
- @token = JWT.encode claims.merge(payload),
13
+ @payload = claims.merge(payload)
14
+ @token = JWT.encode @payload,
15
15
  secret_key,
16
16
  Knock.token_signature_algorithm
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module Knock
2
- VERSION = "2.0"
2
+ VERSION = "2.1"
3
3
  end
Binary file
@@ -1,79 +1,153 @@
1
-  (7.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
2
-  (7.4ms) 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"
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"
4
4
  Migrating to CreateUsers (20150713101607)
5
5
   (0.1ms) begin transaction
6
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
7
  SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20150713101607"]]
8
-  (2.0ms) commit transaction
8
+  (2.8ms) commit transaction
9
9
  Migrating to CreateAdmins (20160519075733)
10
-  (0.0ms) begin transaction
11
-  (0.2ms) 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.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)
12
12
  SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160519075733"]]
13
-  (6.8ms) commit transaction
13
+  (1.8ms) commit transaction
14
14
  Migrating to CreateVendors (20160522051816)
15
15
   (0.0ms) begin transaction
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)
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)
17
17
  SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160522051816"]]
18
-  (6.9ms) commit transaction
18
+  (1.8ms) commit transaction
19
19
  Migrating to CreateCompositeNameEntities (20160522181712)
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
-  (6.8ms) commit transaction
24
- ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", :environment], ["LIMIT", 1]]
25
-  (0.0ms) begin transaction
26
- SQL (0.1ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "test"], ["created_at", 2016-10-23 11:46:54 UTC], ["updated_at", 2016-10-23 11:46:54 UTC]]
27
-  (9.4ms) commit transaction
28
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
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
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
+  (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"
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$L0e6QDD.KUi7.R484p7.CuLHnDQ1237SVHPBXc1TuVkJkK22jpKVS', '2016-10-23 11:46:57.543558', '2016-10-23 11:46:57.543558', 980190962)
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)
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$C3CqIofHrsAY14.9KrzXceL/bYXVODgVNloqhRiYYJek3Pak5ABhW', '2016-10-23 11:46:57.547469', '2016-10-23 11:46:57.547469', 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$mlaZf/ZocmFG87hoVWWSy.Hw1aeUZ5xSfMMmLgBO1/MUy/fDpCCsq', '2017-01-30 22:34:52.456448', '2017-01-30 22:34:52.456448', 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$7Z3pv.bB1PLx4/uSlbmwBe98I/G.MYZT8I0SMEZY.WXHtFiJctThG', '2016-10-23 11:46:57.549261', '2016-10-23 11:46:57.549261', 980190962)
37
- Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$Rdgg23Sm9JHF9v6igZBGbODJ3sF2Q2Isa3AOZa7AeC2X02nu9VZI6', '2016-10-23 11:46:57.549261', '2016-10-23 11:46:57.549261', 298486374)
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)
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$c6LF45dpUDzY4pDnbxipb.DzdalR.IBnD84VgVHmA9w9QG1p6szZy', '2016-10-23 11:46:57.551369', '2016-10-23 11:46:57.551369', 980190962)
40
-  (2.1ms) 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$yUH8XfsOno528ZxohlDlVe04eESr6mhDfFCjIoJnja2fWi2bzB9aa', '2017-01-30 22:34:52.460595', '2017-01-30 22:34:52.460595', 980190962)
40
+  (129.5ms) commit transaction
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)
49
+  (0.1ms) rollback transaction
50
+  (0.1ms) begin transaction
51
+ --------------------------------------------------------------------------
52
+ VendorProtectedControllerTest: test_responds_with_success_if_authenticated
53
+ --------------------------------------------------------------------------
54
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
55
+ Processing by VendorProtectedController#index as HTML
56
+ 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)
58
+  (0.1ms) rollback transaction
59
+  (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)
66
+  (0.1ms) rollback transaction
67
+  (0.1ms) begin transaction
68
+ -----------------------------------------------------------------------------
69
+ VendorProtectedControllerTest: test_raises_method_missing_error_appropriately
70
+ -----------------------------------------------------------------------------
71
+ Processing by VendorProtectedController#show as HTML
72
+ Parameters: {"id"=>"1"}
73
+ Completed 500 Internal Server Error in 10ms (ActiveRecord: 0.0ms)
74
+  (0.1ms) rollback transaction
75
+  (0.1ms) begin transaction
76
+ --------------------------------------------------------------------------------
77
+ VendorProtectedControllerTest: test_responds_with_unauthorized_to_invalid_entity
78
+ --------------------------------------------------------------------------------
79
+ Processing by VendorProtectedController#index as HTML
80
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 0], ["LIMIT", 1]]
81
+ Filter chain halted as :authenticate_vendor rendered or redirected
82
+ Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
83
+  (0.1ms) rollback transaction
41
84
   (0.0ms) begin transaction
42
- ----------------------------------------------------------------------------------
43
- ProtectedResourcesControllerTest: test_accepts_authorization_header_without_prefix
44
- ----------------------------------------------------------------------------------
45
- User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
46
- Processing by ProtectedResourcesController#index as HTML
47
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
48
- Completed 200 OK in 4ms (ActiveRecord: 0.1ms)
85
+ --------------------------------------------------------------
86
+ VendorProtectedControllerTest: test_responds_with_unauthorized
87
+ --------------------------------------------------------------
88
+ Processing by VendorProtectedController#index as HTML
89
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", nil], ["LIMIT", 1]]
90
+ Filter chain halted as :authenticate_vendor rendered or redirected
91
+ Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
49
92
   (0.1ms) rollback transaction
50
93
   (0.1ms) begin transaction
51
- ----------------------------------------------------------------------------------------------
52
- ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_header
53
- ----------------------------------------------------------------------------------------------
54
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
55
- Processing by ProtectedResourcesController#index as HTML
56
- Filter chain halted as :authenticate_user rendered or redirected
57
- Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)
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)
58
101
   (0.1ms) rollback transaction
59
102
   (0.1ms) begin transaction
60
- -------------------------------------------------------------------------------------------
61
- ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_url
62
- -------------------------------------------------------------------------------------------
63
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
64
- Processing by ProtectedResourcesController#index as HTML
65
- Parameters: {"token"=>"invalid"}
66
- Filter chain halted as :authenticate_user rendered or redirected
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)
110
+  (0.1ms) rollback transaction
111
+  (0.1ms) begin transaction
112
+ ---------------------------------------------------------------------------
113
+ CompositeNameEntityProtectedControllerTest: test_responds_with_unauthorized
114
+ ---------------------------------------------------------------------------
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
67
126
  Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
127
+  (0.1ms) rollback transaction
128
+  (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]]
135
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
136
+  (0.1ms) rollback transaction
137
+  (0.1ms) begin transaction
138
+ ------------------------------------------------------------------------
139
+ TokenControllerGeneratorTest: test_assert_all_files_are_properly_created
140
+ ------------------------------------------------------------------------
68
141
   (0.1ms) rollback transaction
69
142
   (0.1ms) begin transaction
70
143
  ------------------------------------------------------------------------------
71
- ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
144
+ ProtectedResourcesControllerTest: test_responds_with_success_with_token_in_url
72
145
  ------------------------------------------------------------------------------
73
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
146
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
74
147
  Processing by ProtectedResourcesController#index as HTML
148
+ Parameters: {"token"=>"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0ODU5MDIwOTIsInN1YiI6OTgwMTkwOTYyfQ.mXZ2Kj1BABftUQzk82aoUWpwAFYYdbU3FC38X7zYgIQ"}
75
149
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
76
- Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
150
+ Completed 200 OK in 2ms (ActiveRecord: 0.1ms)
77
151
   (0.1ms) rollback transaction
78
152
   (0.1ms) begin transaction
79
153
  ---------------------------------------------------------------------------------------
@@ -81,47 +155,64 @@ ProtectedResourcesControllerTest: test_responds_with_success_with_valid_token_in
81
155
  ---------------------------------------------------------------------------------------
82
156
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
83
157
  Processing by ProtectedResourcesController#index as HTML
84
- User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
85
- Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
158
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
159
+ 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)
86
170
   (0.1ms) rollback transaction
87
171
   (0.0ms) begin transaction
88
172
  -------------------------------------------------------------------------------------
89
173
  ProtectedResourcesControllerTest: test_accepts_any_prefix_in_the_authorization_header
90
174
  -------------------------------------------------------------------------------------
91
175
  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]]
92
185
  Processing by ProtectedResourcesController#index as HTML
93
186
  User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
94
187
  Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
95
188
   (0.1ms) rollback transaction
96
-  (0.1ms) begin transaction
97
- -----------------------------------------------------------------
98
- ProtectedResourcesControllerTest: test_responds_with_unauthorized
99
- -----------------------------------------------------------------
189
+  (0.0ms) begin transaction
190
+ -------------------------------------------------------------------------------------------
191
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_url
192
+ -------------------------------------------------------------------------------------------
100
193
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
101
194
  Processing by ProtectedResourcesController#index as HTML
102
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", nil], ["LIMIT", 1]]
195
+ Parameters: {"token"=>"invalid"}
103
196
  Filter chain halted as :authenticate_user rendered or redirected
104
- Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
197
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
105
198
   (0.1ms) rollback transaction
106
199
   (0.1ms) begin transaction
107
- ------------------------------------------------------------------------------
108
- ProtectedResourcesControllerTest: test_responds_with_success_with_token_in_url
109
- ------------------------------------------------------------------------------
200
+ ----------------------------------------------------------------------------------
201
+ ProtectedResourcesControllerTest: test_accepts_authorization_header_without_prefix
202
+ ----------------------------------------------------------------------------------
110
203
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
111
204
  Processing by ProtectedResourcesController#index as HTML
112
- Parameters: {"token"=>"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NzczMDk2MTcsInN1YiI6OTgwMTkwOTYyfQ.Q04ydbtUVZsmqb3dfESRqBJKBfbiomA4XZXFO35kNv8"}
113
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
114
- Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
205
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
206
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
115
207
   (0.1ms) rollback transaction
116
208
   (0.0ms) begin transaction
117
- ------------------------------------------------------------------------
118
- VendorTokenControllerTest: test_responds_with_404_if_user_does_not_exist
119
- ------------------------------------------------------------------------
120
- Vendor Load (0.2ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
121
- Processing by VendorTokenController#create as HTML
122
- Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
123
- Vendor Load (0.3ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."email" = ? LIMIT ? [["email", "wrong@example.net"], ["LIMIT", 1]]
124
- Completed 404 Not Found in 3ms (ActiveRecord: 0.3ms)
209
+ ----------------------------------------------------------------------------------------------
210
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_header
211
+ ----------------------------------------------------------------------------------------------
212
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
213
+ Processing by ProtectedResourcesController#index as HTML
214
+ Filter chain halted as :authenticate_user rendered or redirected
215
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
125
216
   (0.1ms) rollback transaction
126
217
   (0.1ms) begin transaction
127
218
  -------------------------------------------------
@@ -130,8 +221,8 @@ VendorTokenControllerTest: test_responds_with_201
130
221
  Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
131
222
  Processing by VendorTokenController#create as HTML
132
223
  Parameters: {"auth"=>{"email"=>"vendor.one@example.net", "password"=>"[FILTERED]"}}
133
- Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."email" = ? LIMIT ? [["email", "vendor.one@example.net"], ["LIMIT", 1]]
134
- Completed 201 Created in 4ms (Views: 0.4ms | ActiveRecord: 0.1ms)
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)
135
226
   (0.1ms) rollback transaction
136
227
   (0.1ms) begin transaction
137
228
  ------------------------------------------------------------------------
@@ -141,64 +232,29 @@ VendorTokenControllerTest: test_responds_with_404_if_password_is_invalid
141
232
  Processing by VendorTokenController#create as HTML
142
233
  Parameters: {"auth"=>{"email"=>"vendor.one@example.net", "password"=>"[FILTERED]"}}
143
234
  Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."email" = ? LIMIT ? [["email", "vendor.one@example.net"], ["LIMIT", 1]]
144
- Completed 404 Not Found in 3ms (ActiveRecord: 0.1ms)
145
-  (0.1ms) rollback transaction
146
-  (0.1ms) begin transaction
147
- ---------------------------------------------------------------------------------------
148
- Knock::AuthTokenTest: test_does_not_validate_expiration_claim_with_a_nil_token_lifetime
149
- ---------------------------------------------------------------------------------------
150
-  (0.1ms) rollback transaction
151
-  (0.1ms) begin transaction
152
- ---------------------------------------------------------------
153
- Knock::AuthTokenTest: test_validate_expiration_claim_by_default
154
- ---------------------------------------------------------------
155
-  (0.1ms) rollback transaction
156
-  (0.1ms) begin transaction
157
- -------------------------------------------
158
- Knock::AuthTokenTest: test_verify_algorithm
159
- -------------------------------------------
160
-  (0.1ms) rollback transaction
161
-  (0.1ms) begin transaction
162
- ----------------------------------------------------
163
- Knock::AuthTokenTest: test_decode_RSA_encoded_tokens
164
- ----------------------------------------------------
165
-  (0.1ms) rollback transaction
166
-  (0.1ms) begin transaction
167
- -------------------------------------------------
168
- Knock::AuthTokenTest: test_encode_tokens_with_RSA
169
- -------------------------------------------------
235
+ Completed 404 Not Found in 2ms (ActiveRecord: 0.1ms)
170
236
   (0.1ms) rollback transaction
171
237
   (0.1ms) begin transaction
172
- ------------------------------------------
173
- Knock::AuthTokenTest: test_is_serializable
174
- ------------------------------------------
175
-  (0.0ms) rollback transaction
176
-  (0.0ms) begin transaction
177
- -------------------------------------------------------------------------
178
- Knock::AuthTokenTest: test_verify_audience_when_token_audience_is_present
179
- -------------------------------------------------------------------------
180
-  (0.0ms) rollback transaction
181
-  (0.1ms) begin transaction
182
- -----------------------------------------------------------------------
183
- AdminTokenControllerTest: test_responds_with_404_if_user_does_not_exist
184
- -----------------------------------------------------------------------
185
- Admin Load (0.2ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
186
- Processing by AdminTokenController#create as HTML
238
+ ------------------------------------------------------------------------
239
+ VendorTokenControllerTest: test_responds_with_404_if_user_does_not_exist
240
+ ------------------------------------------------------------------------
241
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
242
+ Processing by VendorTokenController#create as HTML
187
243
  Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
188
- Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = ? LIMIT ? [["email", "wrong@example.net"], ["LIMIT", 1]]
244
+ Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."email" = ? LIMIT ? [["email", "wrong@example.net"], ["LIMIT", 1]]
189
245
  Completed 404 Not Found in 1ms (ActiveRecord: 0.1ms)
190
246
   (0.1ms) rollback transaction
191
247
   (0.1ms) begin transaction
192
248
  ------------------------------------------------
193
249
  AdminTokenControllerTest: test_responds_with_201
194
250
  ------------------------------------------------
195
- Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
251
+ Admin Load (0.2ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
196
252
  Processing by AdminTokenController#create as HTML
197
253
  Parameters: {"auth"=>{"email"=>"admin.one@example.net", "password"=>"[FILTERED]"}}
198
- Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = ? LIMIT ? [["email", "admin.one@example.net"], ["LIMIT", 1]]
199
- Completed 201 Created in 3ms (Views: 0.2ms | ActiveRecord: 0.1ms)
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)
200
256
   (0.1ms) rollback transaction
201
-  (0.0ms) begin transaction
257
+  (0.1ms) begin transaction
202
258
  -----------------------------------------------------------------------
203
259
  AdminTokenControllerTest: test_responds_with_404_if_password_is_invalid
204
260
  -----------------------------------------------------------------------
@@ -208,16 +264,17 @@ Processing by AdminTokenController#create as HTML
208
264
  Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = ? LIMIT ? [["email", "admin.one@example.net"], ["LIMIT", 1]]
209
265
  Completed 404 Not Found in 2ms (ActiveRecord: 0.1ms)
210
266
   (0.1ms) rollback transaction
211
-  (0.0ms) begin transaction
212
- --------------------------------------------------
213
- CurrentUsersControllerTest: test_responds_with_200
214
- --------------------------------------------------
215
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
216
- Processing by CurrentUsersController#show as HTML
217
- User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
218
- Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
267
+  (0.1ms) begin transaction
268
+ -----------------------------------------------------------------------
269
+ AdminTokenControllerTest: test_responds_with_404_if_user_does_not_exist
270
+ -----------------------------------------------------------------------
271
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
272
+ Processing by AdminTokenController#create as HTML
273
+ 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)
219
276
   (0.1ms) rollback transaction
220
-  (0.0ms) begin transaction
277
+  (0.1ms) begin transaction
221
278
  -----------------------------------------------------
222
279
  CurrentUsersControllerTest: test_responds_with_200_#2
223
280
  -----------------------------------------------------
@@ -227,6 +284,15 @@ Processing by CurrentUsersController#show as HTML
227
284
  Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
228
285
   (0.1ms) rollback transaction
229
286
   (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
230
296
  ---------------------------------------------------------------------------
231
297
  CurrentUsersControllerTest: test_responds_with_404_if_user_is_not_logged_in
232
298
  ---------------------------------------------------------------------------
@@ -234,58 +300,11 @@ CurrentUsersControllerTest: test_responds_with_404_if_user_is_not_logged_in
234
300
  Processing by CurrentUsersController#show as HTML
235
301
  User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", nil], ["LIMIT", 1]]
236
302
  Completed 404 Not Found in 1ms (ActiveRecord: 0.0ms)
237
-  (0.1ms) rollback transaction
238
-  (0.0ms) begin transaction
239
- -----------------------------------------------------------------------------
240
- VendorProtectedControllerTest: test_raises_method_missing_error_appropriately
241
- -----------------------------------------------------------------------------
242
- Processing by VendorProtectedController#show as HTML
243
- Parameters: {"id"=>"1"}
244
- Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.0ms)
245
-  (0.1ms) rollback transaction
246
-  (0.0ms) begin transaction
247
- -----------------------------------------------------------------------------
248
- VendorProtectedControllerTest: test_has_a_current_vendor_after_authentication
249
- -----------------------------------------------------------------------------
250
- Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
251
- Processing by VendorProtectedController#index as HTML
252
- Vendor Load (0.0ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
253
- Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
254
-  (0.1ms) rollback transaction
255
-  (0.0ms) begin transaction
256
- --------------------------------------------------------------------------------
257
- VendorProtectedControllerTest: test_responds_with_unauthorized_to_invalid_entity
258
- --------------------------------------------------------------------------------
259
- Processing by VendorProtectedController#index as HTML
260
- Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 0], ["LIMIT", 1]]
261
- Filter chain halted as :authenticate_vendor rendered or redirected
262
- Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
263
-  (0.1ms) rollback transaction
264
-  (0.0ms) begin transaction
265
- --------------------------------------------------------------------------
266
- VendorProtectedControllerTest: test_responds_with_success_if_authenticated
267
- --------------------------------------------------------------------------
268
- Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
269
- Processing by VendorProtectedController#index as HTML
270
- Vendor Load (0.0ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
271
- Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
272
-  (0.1ms) rollback transaction
273
-  (0.0ms) begin transaction
274
- --------------------------------------------------------------
275
- VendorProtectedControllerTest: test_responds_with_unauthorized
276
- --------------------------------------------------------------
277
- Processing by VendorProtectedController#index as HTML
278
- Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT ? [["id", nil], ["LIMIT", 1]]
279
- Filter chain halted as :authenticate_vendor rendered or redirected
280
- Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
281
303
   (0.1ms) rollback transaction
282
304
   (0.1ms) begin transaction
283
- -------------------------------------------------------------------------------
284
- VendorProtectedControllerTest: test_responds_with_unauthorized_to_invalid_token
285
- -------------------------------------------------------------------------------
286
- Processing by VendorProtectedController#index as HTML
287
- Filter chain halted as :authenticate_vendor rendered or redirected
288
- Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
305
+ ----------------------------------------------------------------
306
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
307
+ ----------------------------------------------------------------
289
308
   (0.1ms) rollback transaction
290
309
   (0.1ms) begin transaction
291
310
  --------------------------------------------------------------------
@@ -296,7 +315,7 @@ Processing by CustomUnauthorizedEntityController#index as HTML
296
315
  Filter chain halted as :authenticate_user rendered or redirected
297
316
  Completed 404 Not Found in 1ms (ActiveRecord: 0.1ms)
298
317
   (0.1ms) rollback transaction
299
-  (0.0ms) begin transaction
318
+  (0.1ms) begin transaction
300
319
  --------------------------------------------------------------------------------------
301
320
  CustomUnauthorizedEntityControllerTest: test_responds_with_not_found_to_invalid_entity
302
321
  --------------------------------------------------------------------------------------
@@ -306,15 +325,6 @@ Filter chain halted as :authenticate_user rendered or redirected
306
325
  Completed 404 Not Found in 1ms (ActiveRecord: 0.1ms)
307
326
   (0.1ms) rollback transaction
308
327
   (0.0ms) begin transaction
309
- -----------------------------------------------------------------------------------
310
- CustomUnauthorizedEntityControllerTest: test_responds_with_success_if_authenticated
311
- -----------------------------------------------------------------------------------
312
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
313
- Processing by CustomUnauthorizedEntityController#index as HTML
314
- User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
315
- Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
316
-  (0.1ms) rollback transaction
317
-  (0.0ms) begin transaction
318
328
  -------------------------------------------------------------------------------------
319
329
  CustomUnauthorizedEntityControllerTest: test_responds_with_not_found_to_invalid_token
320
330
  -------------------------------------------------------------------------------------
@@ -323,60 +333,32 @@ Filter chain halted as :authenticate_user rendered or redirected
323
333
  Completed 404 Not Found in 0ms (ActiveRecord: 0.0ms)
324
334
   (0.1ms) rollback transaction
325
335
   (0.1ms) begin transaction
326
- ------------------------------------------------------------------------
327
- TokenControllerGeneratorTest: test_assert_all_files_are_properly_created
328
- ------------------------------------------------------------------------
329
-  (0.1ms) rollback transaction
330
-  (0.0ms) begin transaction
331
- ---------------------------------------------------------------------------
332
- CompositeNameEntityProtectedControllerTest: test_responds_with_unauthorized
333
- ---------------------------------------------------------------------------
334
- Processing by CompositeNameEntityProtectedController#index as HTML
335
- CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", nil], ["LIMIT", 1]]
336
- Filter chain halted as :authenticate_composite_name_entity rendered or redirected
337
- Completed 401 Unauthorized in 2ms (ActiveRecord: 0.1ms)
338
-  (0.1ms) rollback transaction
339
-  (0.0ms) begin transaction
340
- --------------------------------------------------------------------------------------------
341
- CompositeNameEntityProtectedControllerTest: test_responds_with_unauthorized_to_invalid_token
342
- --------------------------------------------------------------------------------------------
343
- Processing by CompositeNameEntityProtectedController#index as HTML
344
- Filter chain halted as :authenticate_composite_name_entity rendered or redirected
345
- Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
346
-  (0.1ms) rollback transaction
347
-  (0.0ms) begin transaction
348
- ---------------------------------------------------------------------------------------------------------
349
- CompositeNameEntityProtectedControllerTest: test_has_a_current_composite_name_entity_after_authentication
350
- ---------------------------------------------------------------------------------------------------------
351
- CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
352
- Processing by CompositeNameEntityProtectedController#index as HTML
353
- CompositeNameEntity Load (0.0ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
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]]
354
342
  Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
355
343
   (0.1ms) rollback transaction
356
-  (0.0ms) begin transaction
357
- ---------------------------------------------------------------------------------------------
358
- CompositeNameEntityProtectedControllerTest: test_responds_with_unauthorized_to_invalid_entity
359
- ---------------------------------------------------------------------------------------------
360
- Processing by CompositeNameEntityProtectedController#index as HTML
361
- CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 0], ["LIMIT", 1]]
362
- Filter chain halted as :authenticate_composite_name_entity rendered or redirected
363
- Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
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)
364
351
   (0.1ms) rollback transaction
365
-  (0.0ms) begin transaction
366
- ---------------------------------------------------------------------------------------
367
- CompositeNameEntityProtectedControllerTest: test_responds_with_success_if_authenticated
368
- ---------------------------------------------------------------------------------------
369
- CompositeNameEntity Load (0.1ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
370
- Processing by CompositeNameEntityProtectedController#index as HTML
371
- CompositeNameEntity Load (0.0ms) SELECT "composite_name_entities".* FROM "composite_name_entities" WHERE "composite_name_entities"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
372
- Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
352
+  (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)
373
360
   (0.1ms) rollback transaction
374
-  (0.0ms) begin transaction
375
- ----------------------------------------------------------------
376
- InstallGeneratorTest: test_Assert_all_files_are_properly_created
377
- ----------------------------------------------------------------
378
-  (0.0ms) rollback transaction
379
-  (0.0ms) begin transaction
361
+  (0.1ms) begin transaction
380
362
  -------------------------------------------------------------
381
363
  AdminProtectedControllerTest: test_responds_with_unauthorized
382
364
  -------------------------------------------------------------
@@ -386,42 +368,85 @@ Filter chain halted as :authenticate_admin rendered or redirected
386
368
  Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
387
369
   (0.1ms) rollback transaction
388
370
   (0.0ms) begin transaction
389
- ------------------------------------------------------------------------------
390
- AdminProtectedControllerTest: test_responds_with_unauthorized_to_invalid_token
391
- ------------------------------------------------------------------------------
371
+ -------------------------------------------------------------------------------
372
+ AdminProtectedControllerTest: test_responds_with_unauthorized_to_invalid_entity
373
+ -------------------------------------------------------------------------------
392
374
  Processing by AdminProtectedController#index as HTML
375
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 0], ["LIMIT", 1]]
393
376
  Filter chain halted as :authenticate_admin rendered or redirected
394
- Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
395
-  (0.0ms) rollback transaction
377
+ Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
378
+  (0.1ms) rollback transaction
396
379
   (0.0ms) begin transaction
397
380
  ---------------------------------------------------------------------------
398
381
  AdminProtectedControllerTest: test_has_a_current_admin_after_authentication
399
382
  ---------------------------------------------------------------------------
400
383
  Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
401
384
  Processing by AdminProtectedController#index as HTML
402
- Admin Load (0.0ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
403
- Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
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)
387
+  (0.1ms) rollback transaction
388
+  (0.1ms) begin transaction
389
+ --------------------------------------------------------------------------------
390
+ Knock::AuthTokenTest: test_validate_aud_when_verify_options[:verify_aud]_is_true
391
+ --------------------------------------------------------------------------------
404
392
   (0.1ms) rollback transaction
405
393
   (0.0ms) begin transaction
406
394
  -------------------------------------------------------------------------
407
- AdminProtectedControllerTest: test_responds_with_success_if_authenticated
395
+ Knock::AuthTokenTest: test_verify_audience_when_token_audience_is_present
408
396
  -------------------------------------------------------------------------
409
- Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
410
- Processing by AdminProtectedController#index as HTML
411
- Admin Load (0.0ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 980190962], ["LIMIT", 1]]
412
- Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
397
+  (0.0ms) rollback transaction
398
+  (0.1ms) begin transaction
399
+ --------------------------------------------------------------------------------------------------------
400
+ Knock::AuthTokenTest: test_does_not_validate_expiration_when_verify_options[:verify_expiration]_is_false
401
+ --------------------------------------------------------------------------------------------------------
413
402
   (0.1ms) rollback transaction
414
403
   (0.0ms) begin transaction
415
- -------------------------------------------------------------------------------
416
- AdminProtectedControllerTest: test_responds_with_unauthorized_to_invalid_entity
417
- -------------------------------------------------------------------------------
418
- Processing by AdminProtectedController#index as HTML
419
- Admin Load (0.1ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = ? LIMIT ? [["id", 0], ["LIMIT", 1]]
420
- Filter chain halted as :authenticate_admin rendered or redirected
421
- Completed 401 Unauthorized in 1ms (ActiveRecord: 0.1ms)
404
+ ----------------------------------------------------
405
+ Knock::AuthTokenTest: test_decode_RSA_encoded_tokens
406
+ ----------------------------------------------------
407
+  (0.1ms) rollback transaction
408
+  (0.1ms) begin transaction
409
+ ----------------------------------------------------------------------------------------------
410
+ Knock::AuthTokenTest: test_validate_expiration_when_verify_options[:verify_expiration]_is_true
411
+ ----------------------------------------------------------------------------------------------
412
+  (0.1ms) rollback transaction
413
+  (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
422
   (0.1ms) rollback transaction
423
423
   (0.0ms) begin transaction
424
+ -------------------------------------------
425
+ Knock::AuthTokenTest: test_verify_algorithm
426
+ -------------------------------------------
427
+  (0.1ms) rollback transaction
428
+  (0.0ms) begin transaction
429
+ ---------------------------------------------------------------------------------------
430
+ Knock::AuthTokenTest: test_does_not_validate_expiration_claim_with_a_nil_token_lifetime
431
+ ---------------------------------------------------------------------------------------
432
+  (0.1ms) rollback transaction
433
+  (0.1ms) begin transaction
434
+ -------------------------------------------------
435
+ Knock::AuthTokenTest: test_encode_tokens_with_RSA
436
+ -------------------------------------------------
437
+  (0.1ms) rollback transaction
438
+  (0.1ms) begin transaction
439
+ ------------------------------------------
440
+ Knock::AuthTokenTest: test_is_serializable
441
+ ------------------------------------------
442
+  (0.1ms) rollback transaction
443
+  (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
424
449
  ---------------------------------------
425
450
  KnockTest: test_setup_block_yields_self
426
451
  ---------------------------------------
427
-  (0.0ms) rollback transaction
452
+  (0.1ms) rollback transaction
@@ -48,10 +48,10 @@ module Knock
48
48
  end
49
49
 
50
50
  test "validate expiration claim by default" do
51
- token = Knock::AuthToken.new(payload: { sub: 'foo' }).token
51
+ token = AuthToken.new(payload: {sub: 'foo'}).token
52
52
  Timecop.travel(25.hours.from_now) do
53
53
  assert_raises(JWT::ExpiredSignature) {
54
- Knock::AuthToken.new(token: token)
54
+ AuthToken.new(token: token)
55
55
  }
56
56
  end
57
57
  end
@@ -59,12 +59,61 @@ module Knock
59
59
  test "does not validate expiration claim with a nil token_lifetime" do
60
60
  Knock.token_lifetime = nil
61
61
 
62
- token = Knock::AuthToken.new(payload: { sub: 'foo' }).token
62
+ token = AuthToken.new(payload: {sub: 'foo'}).token
63
63
  Timecop.travel(10.years.from_now) do
64
- assert_not Knock::AuthToken.new(token: token).payload.has_key?('exp')
64
+ assert_not AuthToken.new(token: token).payload.has_key?('exp')
65
65
  end
66
66
  end
67
67
 
68
+ test "validate aud when verify_options[:verify_aud] is true" do
69
+ verify_options = {
70
+ verify_aud: true
71
+ }
72
+ Knock.token_audience = -> { 'bar' }
73
+ key = Knock.token_secret_signature_key.call
74
+ assert_raises(JWT::InvalidAudError) {
75
+ AuthToken.new token: @token, verify_options: verify_options
76
+ }
77
+ end
78
+
79
+ test "does not validate aud when verify_options[:verify_aud] is false" do
80
+ verify_options = {
81
+ verify_aud: false
82
+ }
83
+ Knock.token_audience = -> { 'bar' }
84
+ key = Knock.token_secret_signature_key.call
85
+ assert_not AuthToken.new(token: @token, verify_options: verify_options).payload.has_key?('aud')
86
+ end
87
+
88
+ test "validate expiration when verify_options[:verify_expiration] is true" do
89
+ verify_options = {
90
+ verify_expiration: true
91
+ }
92
+ token = AuthToken.new(payload: {sub: 'foo'}).token
93
+ Timecop.travel(25.hours.from_now) do
94
+ assert_raises(JWT::ExpiredSignature) {
95
+ AuthToken.new(token: token, verify_options: verify_options)
96
+ }
97
+ end
98
+ end
99
+
100
+ test "does not validate expiration when verify_options[:verify_expiration] is false" do
101
+ verify_options = {
102
+ verify_expiration: false
103
+ }
104
+ token = AuthToken.new(payload: {sub: 'foo'}).token
105
+ Timecop.travel(25.hours.from_now) do
106
+ assert AuthToken.new(token: token, verify_options: verify_options).payload.has_key?('exp')
107
+ end
108
+ end
109
+
110
+ test "Knock::AuthToken has all payloads" do
111
+ Knock.token_lifetime = 7.days
112
+ payload = Knock::AuthToken.new(payload: { sub: 'foo' }).payload
113
+ assert payload.has_key?(:sub)
114
+ assert payload.has_key?(:exp)
115
+ end
116
+
68
117
  test "is serializable" do
69
118
  auth_token = AuthToken.new token: @token
70
119
 
@@ -1,8 +1,6 @@
1
1
  require 'simplecov'
2
- require "codeclimate-test-reporter"
3
2
 
4
3
  SimpleCov.start
5
- CodeClimate::TestReporter.start
6
4
 
7
5
  # Configure Rails Environment
8
6
  ENV["RAILS_ENV"] = "test"
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.0'
4
+ version: '2.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud MESUREUR
@@ -9,76 +9,76 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-23 00:00:00.000000000 Z
12
+ date: 2017-01-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ! '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '4.2'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ! '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '4.2'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: jwt
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '1.5'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '1.5'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bcrypt
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: '3.1'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '3.1'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: sqlite3
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ~>
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '1.3'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ~>
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1.3'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: timecop
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ~>
74
+ - - "~>"
75
75
  - !ruby/object:Gem::Version
76
76
  version: 0.8.0
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ~>
81
+ - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: 0.8.0
84
84
  description: Authentication solution for Rails based on JWT
@@ -189,12 +189,12 @@ require_paths:
189
189
  - lib
190
190
  required_ruby_version: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ! '>='
192
+ - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  requirements:
197
- - - ! '>='
197
+ - - ">="
198
198
  - !ruby/object:Gem::Version
199
199
  version: '0'
200
200
  requirements: []