knock 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95b56eed3136555f3aa41844e00f9dd8faedb638
4
- data.tar.gz: bf957608fc856b195c6e668b1b2d373a04b498f4
3
+ metadata.gz: a3966295873b5de911304239f5bd841144a88333
4
+ data.tar.gz: 4a88b9f1efbf8b6919e29b17ea331824b51c44c5
5
5
  SHA512:
6
- metadata.gz: 5608467c83aee855c5474388aa6cb9725a397d59ba45afeb27137455958c5c0f0c541d8a7420a8132965e0a3c2e001abea0b43a83aa9b89d186651fa008bf6b2
7
- data.tar.gz: ebfd80d26c2655cb77032921ef60221c3e0312ffaf70983692d5b691456ae5d3c2cd0254a4d6d95d70413dcd1148559c135705ab4733744a134a0213a5b0bd81
6
+ metadata.gz: be761b6599228ae01ec6533eb8f7f99b79dab91d6b69b62bc2be54839cbdd9392773be7ee8c673e0c076802ad83fa70e4081c24d8ecfa9d5c5a585a2fbec9db8
7
+ data.tar.gz: 5e0a0d1b1edc8071935ac6f99fbf4dcda8d91e2a859278fc704070b307840bb42453b1f3aa8b123ee9db02f7884edc15f96ebd799aff37f1900c5da411253e25
@@ -14,7 +14,7 @@ module Knock
14
14
  end
15
15
 
16
16
  def auth_token
17
- AuthToken.new payload: { user_id: user.id }
17
+ AuthToken.new payload: { sub: user.id }
18
18
  end
19
19
 
20
20
  def user
@@ -1,5 +1,16 @@
1
1
  Knock.setup do |config|
2
2
 
3
+ ## Current user retrieval when validating token
4
+ ## --------------------------------------------
5
+ ##
6
+ ## This is how you can tell Knock how to retrieve the current_user.
7
+ ## By default, it assumes you have a model called `User` and that
8
+ ## the user_id is stored in the 'sub' claim.
9
+ ##
10
+ ## Default:
11
+ # config.current_user_from_token = -> (claims) { User.find claims['sub'] }
12
+
13
+
3
14
  ## Expiration claim
4
15
  ## ----------------
5
16
  ##
@@ -31,6 +42,6 @@ Knock.setup do |config|
31
42
  # config.token_secret_signature_key = -> { Rails.application.secrets.secret_key_base }
32
43
 
33
44
  ## If using Auth0, uncomment the line below
34
- # config.token_secret_signature_key = -> { Rails.application.secrets.auth0_client_secret }
45
+ # config.token_secret_signature_key = -> { JWT.base64url_decode Rails.application.secrets.auth0_client_secret }
35
46
 
36
47
  end
@@ -11,6 +11,9 @@ module Knock
11
11
  mattr_accessor :token_secret_signature_key
12
12
  self.token_secret_signature_key = -> { Rails.application.secrets.secret_key_base }
13
13
 
14
+ mattr_accessor :current_user_from_token
15
+ self.current_user_from_token = -> (claims) { User.find claims['sub'] }
16
+
14
17
  # Default way to setup Knock. Run rails generate knock_install to create
15
18
  # a fresh initializer with all configuration values.
16
19
  def self.setup
@@ -5,7 +5,7 @@ module Knock::Authenticable
5
5
  begin
6
6
  token = request.headers['Authorization'].split(' ').last
7
7
  payload, header = Knock::AuthToken.new(token: token).validate!
8
- @current_user = User.find(payload['user_id'])
8
+ @current_user = Knock.current_user_from_token.call(payload)
9
9
  rescue
10
10
  head :unauthorized
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module Knock
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
Binary file
@@ -3846,3 +3846,579 @@ Processing by Knock::AuthTokenController#create as HTML
3846
3846
  User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
3847
3847
  Completed 201 Created in 3ms (Views: 0.2ms | ActiveRecord: 0.1ms)
3848
3848
   (0.1ms) rollback transaction
3849
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
3850
+  (0.1ms) begin transaction
3851
+ Fixture Delete (0.8ms) DELETE FROM "users"
3852
+ Fixture Insert (0.5ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('one@example.net', '$2a$04$XIklu6b1fu1FKZ40/zthquwZtWD1iOVDxOHSKXMCiXQTmv9tdE1k2', '2015-07-16 09:38:29', '2015-07-16 09:38:29', 980190962)
3853
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$HmSbuUSOgrKFCMcSG3bHgOBOqNlaEOGaLodG3bkgYK7vae.DCe81y', '2015-07-16 09:38:29', '2015-07-16 09:38:29', 298486374)
3854
+  (0.8ms) commit transaction
3855
+  (0.0ms) begin transaction
3856
+ -----------------------------------------------------------------------------
3857
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_password_is_invalid
3858
+ -----------------------------------------------------------------------------
3859
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
3860
+ Processing by Knock::AuthTokenController#create as HTML
3861
+ Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
3862
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" IS NULL LIMIT 1
3863
+ Completed 404 Not Found in 1ms (ActiveRecord: 0.1ms)
3864
+  (0.1ms) rollback transaction
3865
+  (0.1ms) begin transaction
3866
+ ------------------------------------------------------
3867
+ Knock::AuthTokenControllerTest: test_responds_with_201
3868
+ ------------------------------------------------------
3869
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
3870
+ Processing by Knock::AuthTokenController#create as HTML
3871
+ Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
3872
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" IS NULL LIMIT 1
3873
+ Completed 404 Not Found in 0ms (ActiveRecord: 0.1ms)
3874
+  (0.0ms) rollback transaction
3875
+  (0.1ms) begin transaction
3876
+ -----------------------------------------------------------------------------
3877
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_user_does_not_exist
3878
+ -----------------------------------------------------------------------------
3879
+ Processing by Knock::AuthTokenController#create as HTML
3880
+ Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
3881
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" IS NULL LIMIT 1
3882
+ Completed 404 Not Found in 0ms (ActiveRecord: 0.1ms)
3883
+  (0.0ms) rollback transaction
3884
+  (0.0ms) begin transaction
3885
+ ----------------------------------------------------------------
3886
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
3887
+ ----------------------------------------------------------------
3888
+  (0.0ms) rollback transaction
3889
+  (0.0ms) begin transaction
3890
+ -----------------------------------------------------------------
3891
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized
3892
+ -----------------------------------------------------------------
3893
+ Processing by ProtectedResourcesController#index as HTML
3894
+ Filter chain halted as :authenticate rendered or redirected
3895
+ Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)
3896
+  (0.1ms) rollback transaction
3897
+  (0.0ms) begin transaction
3898
+ -----------------------------------------------------------------------------
3899
+ ProtectedResourcesControllerTest: test_responds_with_success_if_authenticated
3900
+ -----------------------------------------------------------------------------
3901
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
3902
+ Processing by ProtectedResourcesController#index as HTML
3903
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", nil]]
3904
+ Filter chain halted as :authenticate rendered or redirected
3905
+ Completed 401 Unauthorized in 2ms (ActiveRecord: 0.1ms)
3906
+  (0.1ms) rollback transaction
3907
+  (0.1ms) begin transaction
3908
+ ------------------------------------------------------------------------------
3909
+ ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
3910
+ ------------------------------------------------------------------------------
3911
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
3912
+ Processing by ProtectedResourcesController#index as HTML
3913
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", nil]]
3914
+ Filter chain halted as :authenticate rendered or redirected
3915
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
3916
+  (0.0ms) rollback transaction
3917
+  (0.0ms) begin transaction
3918
+ ---------------------------------------
3919
+ KnockTest: test_setup_block_yields_self
3920
+ ---------------------------------------
3921
+  (0.0ms) rollback transaction
3922
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
3923
+  (0.1ms) begin transaction
3924
+ Fixture Delete (0.2ms) DELETE FROM "users"
3925
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('one@example.net', '$2a$04$.sMdp6yE/Zt4bywOmkjEyeR/M9ZMkTAQCLYSvbdgyAZEDwYVhq8oS', '2015-07-16 09:44:11', '2015-07-16 09:44:11', 980190962)
3926
+ Fixture Insert (0.0ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$8dRtTY5vUsVbAdOk5FYkU.Jn37Li2HVIH8xhowD1QY7Mu.6zU2teG', '2015-07-16 09:44:11', '2015-07-16 09:44:11', 298486374)
3927
+  (0.8ms) commit transaction
3928
+  (0.0ms) begin transaction
3929
+ -----------------------------------------------------------------------------
3930
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_password_is_invalid
3931
+ -----------------------------------------------------------------------------
3932
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
3933
+ Processing by Knock::AuthTokenController#create as HTML
3934
+ Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
3935
+ User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."email" IS NULL LIMIT 1
3936
+ Completed 404 Not Found in 1ms (ActiveRecord: 0.3ms)
3937
+  (0.2ms) rollback transaction
3938
+  (0.1ms) begin transaction
3939
+ -----------------------------------------------------------------------------
3940
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_user_does_not_exist
3941
+ -----------------------------------------------------------------------------
3942
+ Processing by Knock::AuthTokenController#create as HTML
3943
+ Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
3944
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" IS NULL LIMIT 1
3945
+ Completed 404 Not Found in 1ms (ActiveRecord: 0.2ms)
3946
+  (0.1ms) rollback transaction
3947
+  (0.1ms) begin transaction
3948
+ ------------------------------------------------------
3949
+ Knock::AuthTokenControllerTest: test_responds_with_201
3950
+ ------------------------------------------------------
3951
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
3952
+ Processing by Knock::AuthTokenController#create as HTML
3953
+ Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
3954
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" IS NULL LIMIT 1
3955
+ Completed 404 Not Found in 0ms (ActiveRecord: 0.1ms)
3956
+  (0.0ms) rollback transaction
3957
+  (0.0ms) begin transaction
3958
+ -----------------------------------------------------------------
3959
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized
3960
+ -----------------------------------------------------------------
3961
+ Processing by ProtectedResourcesController#index as HTML
3962
+ Filter chain halted as :authenticate rendered or redirected
3963
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
3964
+  (0.0ms) rollback transaction
3965
+  (0.0ms) begin transaction
3966
+ -----------------------------------------------------------------------------
3967
+ ProtectedResourcesControllerTest: test_responds_with_success_if_authenticated
3968
+ -----------------------------------------------------------------------------
3969
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
3970
+ Processing by ProtectedResourcesController#index as HTML
3971
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", nil]]
3972
+ Filter chain halted as :authenticate rendered or redirected
3973
+ Completed 401 Unauthorized in 2ms (ActiveRecord: 0.0ms)
3974
+  (0.1ms) rollback transaction
3975
+  (0.1ms) begin transaction
3976
+ ------------------------------------------------------------------------------
3977
+ ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
3978
+ ------------------------------------------------------------------------------
3979
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
3980
+ Processing by ProtectedResourcesController#index as HTML
3981
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", nil]]
3982
+ Filter chain halted as :authenticate rendered or redirected
3983
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
3984
+  (0.0ms) rollback transaction
3985
+  (0.0ms) begin transaction
3986
+ ----------------------------------------------------------------
3987
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
3988
+ ----------------------------------------------------------------
3989
+  (0.1ms) rollback transaction
3990
+  (0.1ms) begin transaction
3991
+ ---------------------------------------
3992
+ KnockTest: test_setup_block_yields_self
3993
+ ---------------------------------------
3994
+  (0.0ms) rollback transaction
3995
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
3996
+  (0.1ms) begin transaction
3997
+ Fixture Delete (0.2ms) DELETE FROM "users"
3998
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('one@example.net', '$2a$04$08oFJCfJGV4ze1vKJRYbAOKcHdp/oH6IVeF4YcX44cs2TVvYmJcgK', '2015-07-16 09:56:24', '2015-07-16 09:56:24', 980190962)
3999
+ Fixture Insert (0.0ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$ugtejufJzCgRRVlNVR.fq.MQeJ8dykhBw0wOxWc1IrC021SJHSfPq', '2015-07-16 09:56:24', '2015-07-16 09:56:24', 298486374)
4000
+  (1.1ms) commit transaction
4001
+  (0.0ms) begin transaction
4002
+ ------------------------------------------------------------------------------
4003
+ ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
4004
+ ------------------------------------------------------------------------------
4005
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4006
+ Processing by ProtectedResourcesController#index as HTML
4007
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", nil]]
4008
+ Filter chain halted as :authenticate rendered or redirected
4009
+ Completed 401 Unauthorized in 2ms (ActiveRecord: 0.1ms)
4010
+  (0.1ms) rollback transaction
4011
+  (0.0ms) begin transaction
4012
+ -----------------------------------------------------------------------------
4013
+ ProtectedResourcesControllerTest: test_responds_with_success_if_authenticated
4014
+ -----------------------------------------------------------------------------
4015
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4016
+ Processing by ProtectedResourcesController#index as HTML
4017
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", nil]]
4018
+ Filter chain halted as :authenticate rendered or redirected
4019
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
4020
+  (0.0ms) rollback transaction
4021
+  (0.1ms) begin transaction
4022
+ -----------------------------------------------------------------
4023
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized
4024
+ -----------------------------------------------------------------
4025
+ Processing by ProtectedResourcesController#index as HTML
4026
+ Filter chain halted as :authenticate rendered or redirected
4027
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
4028
+  (0.0ms) rollback transaction
4029
+  (0.0ms) begin transaction
4030
+ ---------------------------------------
4031
+ KnockTest: test_setup_block_yields_self
4032
+ ---------------------------------------
4033
+  (0.0ms) rollback transaction
4034
+  (0.0ms) begin transaction
4035
+ ------------------------------------------------------
4036
+ Knock::AuthTokenControllerTest: test_responds_with_201
4037
+ ------------------------------------------------------
4038
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4039
+ Processing by Knock::AuthTokenController#create as HTML
4040
+ Parameters: {"email"=>"one@example.net", "password"=>"[FILTERED]"}
4041
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4042
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4043
+ Completed 201 Created in 2ms (Views: 0.1ms | ActiveRecord: 0.1ms)
4044
+  (0.0ms) rollback transaction
4045
+  (0.0ms) begin transaction
4046
+ -----------------------------------------------------------------------------
4047
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_password_is_invalid
4048
+ -----------------------------------------------------------------------------
4049
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4050
+ Processing by Knock::AuthTokenController#create as HTML
4051
+ Parameters: {"email"=>"one@example.net", "password"=>"[FILTERED]"}
4052
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4053
+ Completed 404 Not Found in 1ms (ActiveRecord: 0.0ms)
4054
+  (0.0ms) rollback transaction
4055
+  (0.1ms) begin transaction
4056
+ -----------------------------------------------------------------------------
4057
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_user_does_not_exist
4058
+ -----------------------------------------------------------------------------
4059
+ Processing by Knock::AuthTokenController#create as HTML
4060
+ Parameters: {"email"=>"wrong@example.net", "password"=>"[FILTERED]"}
4061
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "wrong@example.net"]]
4062
+ Completed 404 Not Found in 0ms (ActiveRecord: 0.1ms)
4063
+  (0.0ms) rollback transaction
4064
+  (0.0ms) begin transaction
4065
+ ----------------------------------------------------------------
4066
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
4067
+ ----------------------------------------------------------------
4068
+  (0.0ms) rollback transaction
4069
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
4070
+  (0.1ms) begin transaction
4071
+ Fixture Delete (0.2ms) DELETE FROM "users"
4072
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('one@example.net', '$2a$04$mGECCWvf2.VjIDBcfKh7MOg4UyxtY5Q./myTBhaYkh.S77ZuY8z.O', '2015-07-16 09:57:12', '2015-07-16 09:57:12', 980190962)
4073
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$GET9U7cpvZqQmrWl4lSdee6IW6zvMICcVi.zojH4rZTXE8Mao/EHi', '2015-07-16 09:57:12', '2015-07-16 09:57:12', 298486374)
4074
+  (1.4ms) commit transaction
4075
+  (0.1ms) begin transaction
4076
+ ------------------------------------------------------
4077
+ Knock::AuthTokenControllerTest: test_responds_with_201
4078
+ ------------------------------------------------------
4079
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4080
+ Processing by Knock::AuthTokenController#create as HTML
4081
+ Parameters: {"email"=>"one@example.net", "password"=>"[FILTERED]"}
4082
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4083
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4084
+ Completed 201 Created in 17ms (Views: 0.2ms | ActiveRecord: 0.2ms)
4085
+  (0.1ms) rollback transaction
4086
+  (0.1ms) begin transaction
4087
+ -----------------------------------------------------------------------------
4088
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_user_does_not_exist
4089
+ -----------------------------------------------------------------------------
4090
+ Processing by Knock::AuthTokenController#create as HTML
4091
+ Parameters: {"email"=>"wrong@example.net", "password"=>"[FILTERED]"}
4092
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "wrong@example.net"]]
4093
+ Completed 404 Not Found in 0ms (ActiveRecord: 0.1ms)
4094
+  (0.0ms) rollback transaction
4095
+  (0.0ms) begin transaction
4096
+ -----------------------------------------------------------------------------
4097
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_password_is_invalid
4098
+ -----------------------------------------------------------------------------
4099
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4100
+ Processing by Knock::AuthTokenController#create as HTML
4101
+ Parameters: {"email"=>"one@example.net", "password"=>"[FILTERED]"}
4102
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4103
+ Completed 404 Not Found in 2ms (ActiveRecord: 0.1ms)
4104
+  (0.1ms) rollback transaction
4105
+  (0.0ms) begin transaction
4106
+ ----------------------------------------------------------------
4107
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
4108
+ ----------------------------------------------------------------
4109
+  (0.1ms) rollback transaction
4110
+  (0.0ms) begin transaction
4111
+ -----------------------------------------------------------------------------
4112
+ ProtectedResourcesControllerTest: test_responds_with_success_if_authenticated
4113
+ -----------------------------------------------------------------------------
4114
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4115
+ Processing by ProtectedResourcesController#index as HTML
4116
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4117
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
4118
+  (0.1ms) rollback transaction
4119
+  (0.0ms) begin transaction
4120
+ ------------------------------------------------------------------------------
4121
+ ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
4122
+ ------------------------------------------------------------------------------
4123
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4124
+ Processing by ProtectedResourcesController#index as HTML
4125
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4126
+ Completed 200 OK in 0ms (ActiveRecord: 0.0ms)
4127
+  (0.0ms) rollback transaction
4128
+  (0.1ms) begin transaction
4129
+ -----------------------------------------------------------------
4130
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized
4131
+ -----------------------------------------------------------------
4132
+ Processing by ProtectedResourcesController#index as HTML
4133
+ Filter chain halted as :authenticate rendered or redirected
4134
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
4135
+  (0.0ms) rollback transaction
4136
+  (0.0ms) begin transaction
4137
+ ---------------------------------------
4138
+ KnockTest: test_setup_block_yields_self
4139
+ ---------------------------------------
4140
+  (0.0ms) rollback transaction
4141
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
4142
+  (0.1ms) begin transaction
4143
+ Fixture Delete (0.3ms) DELETE FROM "users"
4144
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('one@example.net', '$2a$04$PYLUT1UhR5lwzT8P22ef8Ojnb4AHZNzaAD67NQP1xsPHG8UzmslnO', '2015-07-16 10:23:58', '2015-07-16 10:23:58', 980190962)
4145
+ Fixture Insert (0.0ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$eXOZCzcgj5DbFV/K0OIDhu.BQQbx2cVS7krRqQJsxnfRJSHhUJCAC', '2015-07-16 10:23:58', '2015-07-16 10:23:58', 298486374)
4146
+  (0.7ms) commit transaction
4147
+  (0.0ms) begin transaction
4148
+ ------------------------------------------------------------------------------
4149
+ ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
4150
+ ------------------------------------------------------------------------------
4151
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4152
+ Processing by ProtectedResourcesController#index as HTML
4153
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4154
+ Completed 200 OK in 2ms (ActiveRecord: 0.1ms)
4155
+  (0.1ms) rollback transaction
4156
+  (0.0ms) begin transaction
4157
+ -----------------------------------------------------------------------------
4158
+ ProtectedResourcesControllerTest: test_responds_with_success_if_authenticated
4159
+ -----------------------------------------------------------------------------
4160
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4161
+ Processing by ProtectedResourcesController#index as HTML
4162
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4163
+ Completed 200 OK in 0ms (ActiveRecord: 0.0ms)
4164
+  (0.1ms) rollback transaction
4165
+  (0.0ms) begin transaction
4166
+ -----------------------------------------------------------------
4167
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized
4168
+ -----------------------------------------------------------------
4169
+ Processing by ProtectedResourcesController#index as HTML
4170
+ Filter chain halted as :authenticate rendered or redirected
4171
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
4172
+  (0.0ms) rollback transaction
4173
+  (0.1ms) begin transaction
4174
+ ------------------------------------------------------
4175
+ Knock::AuthTokenControllerTest: test_responds_with_201
4176
+ ------------------------------------------------------
4177
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4178
+ Processing by Knock::AuthTokenController#create as HTML
4179
+ Parameters: {"email"=>"one@example.net", "password"=>"[FILTERED]"}
4180
+ Completed 400 Bad Request in 0ms (ActiveRecord: 0.0ms)
4181
+  (0.1ms) rollback transaction
4182
+  (0.0ms) begin transaction
4183
+ -----------------------------------------------------------------------------
4184
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_user_does_not_exist
4185
+ -----------------------------------------------------------------------------
4186
+ Processing by Knock::AuthTokenController#create as HTML
4187
+ Parameters: {"email"=>"wrong@example.net", "password"=>"[FILTERED]"}
4188
+ Completed 400 Bad Request in 0ms (ActiveRecord: 0.0ms)
4189
+  (0.0ms) rollback transaction
4190
+  (0.0ms) begin transaction
4191
+ -----------------------------------------------------------------------------
4192
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_password_is_invalid
4193
+ -----------------------------------------------------------------------------
4194
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4195
+ Processing by Knock::AuthTokenController#create as HTML
4196
+ Parameters: {"email"=>"one@example.net", "password"=>"[FILTERED]"}
4197
+ Completed 400 Bad Request in 0ms (ActiveRecord: 0.0ms)
4198
+  (0.0ms) rollback transaction
4199
+  (0.0ms) begin transaction
4200
+ ----------------------------------------------------------------
4201
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
4202
+ ----------------------------------------------------------------
4203
+  (0.0ms) rollback transaction
4204
+  (0.0ms) begin transaction
4205
+ ---------------------------------------
4206
+ KnockTest: test_setup_block_yields_self
4207
+ ---------------------------------------
4208
+  (0.0ms) rollback transaction
4209
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
4210
+  (0.1ms) begin transaction
4211
+ Fixture Delete (0.3ms) DELETE FROM "users"
4212
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('one@example.net', '$2a$04$fj8sa6plfdreIFtTWP60Vud08hkBuX9pHRKlei2z72X20aEol3v0O', '2015-07-16 10:24:41', '2015-07-16 10:24:41', 980190962)
4213
+ Fixture Insert (0.0ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$ql5fbaUCydiFeL/KoZfe3OS9EJTK6e16PHuuxTnIfzPxQZYjj95xK', '2015-07-16 10:24:41', '2015-07-16 10:24:41', 298486374)
4214
+  (1.5ms) commit transaction
4215
+  (0.1ms) begin transaction
4216
+ ---------------------------------------
4217
+ KnockTest: test_setup_block_yields_self
4218
+ ---------------------------------------
4219
+  (0.1ms) rollback transaction
4220
+  (0.0ms) begin transaction
4221
+ ----------------------------------------------------------------
4222
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
4223
+ ----------------------------------------------------------------
4224
+  (0.0ms) rollback transaction
4225
+  (0.0ms) begin transaction
4226
+ -----------------------------------------------------------------------------
4227
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_user_does_not_exist
4228
+ -----------------------------------------------------------------------------
4229
+ Processing by Knock::AuthTokenController#create as HTML
4230
+ Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
4231
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "wrong@example.net"]]
4232
+ Completed 404 Not Found in 11ms (ActiveRecord: 0.2ms)
4233
+  (0.1ms) rollback transaction
4234
+  (0.1ms) begin transaction
4235
+ -----------------------------------------------------------------------------
4236
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_password_is_invalid
4237
+ -----------------------------------------------------------------------------
4238
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4239
+ Processing by Knock::AuthTokenController#create as HTML
4240
+ Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
4241
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4242
+ Completed 404 Not Found in 2ms (ActiveRecord: 0.0ms)
4243
+  (0.0ms) rollback transaction
4244
+  (0.1ms) begin transaction
4245
+ ------------------------------------------------------
4246
+ Knock::AuthTokenControllerTest: test_responds_with_201
4247
+ ------------------------------------------------------
4248
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4249
+ Processing by Knock::AuthTokenController#create as HTML
4250
+ Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
4251
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4252
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4253
+ Completed 201 Created in 7ms (Views: 0.1ms | ActiveRecord: 0.1ms)
4254
+  (0.1ms) rollback transaction
4255
+  (0.0ms) begin transaction
4256
+ -----------------------------------------------------------------
4257
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized
4258
+ -----------------------------------------------------------------
4259
+ Processing by ProtectedResourcesController#index as HTML
4260
+ Filter chain halted as :authenticate rendered or redirected
4261
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
4262
+  (0.0ms) rollback transaction
4263
+  (0.1ms) begin transaction
4264
+ -----------------------------------------------------------------------------
4265
+ ProtectedResourcesControllerTest: test_responds_with_success_if_authenticated
4266
+ -----------------------------------------------------------------------------
4267
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4268
+ Processing by ProtectedResourcesController#index as HTML
4269
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4270
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
4271
+  (0.0ms) rollback transaction
4272
+  (0.1ms) begin transaction
4273
+ ------------------------------------------------------------------------------
4274
+ ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
4275
+ ------------------------------------------------------------------------------
4276
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4277
+ Processing by ProtectedResourcesController#index as HTML
4278
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4279
+ Completed 200 OK in 0ms (ActiveRecord: 0.0ms)
4280
+  (0.0ms) rollback transaction
4281
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
4282
+  (0.1ms) begin transaction
4283
+ Fixture Delete (0.2ms) DELETE FROM "users"
4284
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('one@example.net', '$2a$04$orGP2.6Hy7ckBDOemlIv2ejeS3MPla.ULVHFqJOiPWRB6dz6x5DHK', '2015-07-16 10:26:51', '2015-07-16 10:26:51', 980190962)
4285
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$oYsWRTGRx4sfJIGsruqNM.eTjI0ZzjufLbKkjD4YkJJh26j7WhUCG', '2015-07-16 10:26:51', '2015-07-16 10:26:51', 298486374)
4286
+  (1.5ms) commit transaction
4287
+  (0.1ms) begin transaction
4288
+ ---------------------------------------
4289
+ KnockTest: test_setup_block_yields_self
4290
+ ---------------------------------------
4291
+  (0.0ms) rollback transaction
4292
+  (0.0ms) begin transaction
4293
+ -----------------------------------------------------------------------------
4294
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_password_is_invalid
4295
+ -----------------------------------------------------------------------------
4296
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4297
+ Processing by Knock::AuthTokenController#create as HTML
4298
+ Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
4299
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4300
+ Completed 404 Not Found in 11ms (ActiveRecord: 0.1ms)
4301
+  (0.0ms) rollback transaction
4302
+  (0.0ms) begin transaction
4303
+ ------------------------------------------------------
4304
+ Knock::AuthTokenControllerTest: test_responds_with_201
4305
+ ------------------------------------------------------
4306
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4307
+ Processing by Knock::AuthTokenController#create as HTML
4308
+ Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
4309
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4310
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4311
+ Completed 201 Created in 7ms (Views: 0.2ms | ActiveRecord: 0.1ms)
4312
+  (0.1ms) rollback transaction
4313
+  (0.1ms) begin transaction
4314
+ -----------------------------------------------------------------------------
4315
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_user_does_not_exist
4316
+ -----------------------------------------------------------------------------
4317
+ Processing by Knock::AuthTokenController#create as HTML
4318
+ Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
4319
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "wrong@example.net"]]
4320
+ Completed 404 Not Found in 0ms (ActiveRecord: 0.1ms)
4321
+  (0.0ms) rollback transaction
4322
+  (0.0ms) begin transaction
4323
+ ----------------------------------------------------------------
4324
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
4325
+ ----------------------------------------------------------------
4326
+  (0.0ms) rollback transaction
4327
+  (0.0ms) begin transaction
4328
+ -----------------------------------------------------------------
4329
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized
4330
+ -----------------------------------------------------------------
4331
+ Processing by ProtectedResourcesController#index as HTML
4332
+ Filter chain halted as :authenticate rendered or redirected
4333
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
4334
+  (0.0ms) rollback transaction
4335
+  (0.0ms) begin transaction
4336
+ -----------------------------------------------------------------------------
4337
+ ProtectedResourcesControllerTest: test_responds_with_success_if_authenticated
4338
+ -----------------------------------------------------------------------------
4339
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4340
+ Processing by ProtectedResourcesController#index as HTML
4341
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4342
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
4343
+  (0.0ms) rollback transaction
4344
+  (0.1ms) begin transaction
4345
+ ------------------------------------------------------------------------------
4346
+ ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
4347
+ ------------------------------------------------------------------------------
4348
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4349
+ Processing by ProtectedResourcesController#index as HTML
4350
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4351
+ Completed 200 OK in 0ms (ActiveRecord: 0.0ms)
4352
+  (0.1ms) rollback transaction
4353
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
4354
+  (0.1ms) begin transaction
4355
+ Fixture Delete (0.3ms) DELETE FROM "users"
4356
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('one@example.net', '$2a$04$YvWXmr54tipdqITMnPZ80eLyBpR3RCJClbMMvxFmmou2IhdPOKGia', '2015-07-16 10:26:56', '2015-07-16 10:26:56', 980190962)
4357
+ Fixture Insert (0.0ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$LvbNMrc1vHI8pnUO3O6sFummv4nXdKvH2/V7Tn6d40uRA/dUatK/2', '2015-07-16 10:26:56', '2015-07-16 10:26:56', 298486374)
4358
+  (1.2ms) commit transaction
4359
+  (0.0ms) begin transaction
4360
+ ---------------------------------------
4361
+ KnockTest: test_setup_block_yields_self
4362
+ ---------------------------------------
4363
+  (0.1ms) rollback transaction
4364
+  (0.0ms) begin transaction
4365
+ -----------------------------------------------------------------------------
4366
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_user_does_not_exist
4367
+ -----------------------------------------------------------------------------
4368
+ Processing by Knock::AuthTokenController#create as HTML
4369
+ Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
4370
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "wrong@example.net"]]
4371
+ Completed 404 Not Found in 4ms (ActiveRecord: 0.2ms)
4372
+  (0.1ms) rollback transaction
4373
+  (0.1ms) begin transaction
4374
+ -----------------------------------------------------------------------------
4375
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_password_is_invalid
4376
+ -----------------------------------------------------------------------------
4377
+ User Load (8.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4378
+ Processing by Knock::AuthTokenController#create as HTML
4379
+ Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
4380
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4381
+ Completed 404 Not Found in 2ms (ActiveRecord: 0.0ms)
4382
+  (0.1ms) rollback transaction
4383
+  (0.1ms) begin transaction
4384
+ ------------------------------------------------------
4385
+ Knock::AuthTokenControllerTest: test_responds_with_201
4386
+ ------------------------------------------------------
4387
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4388
+ Processing by Knock::AuthTokenController#create as HTML
4389
+ Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
4390
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4391
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
4392
+ Completed 201 Created in 7ms (Views: 0.2ms | ActiveRecord: 0.1ms)
4393
+  (0.1ms) rollback transaction
4394
+  (0.0ms) begin transaction
4395
+ ------------------------------------------------------------------------------
4396
+ ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
4397
+ ------------------------------------------------------------------------------
4398
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4399
+ Processing by ProtectedResourcesController#index as HTML
4400
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4401
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
4402
+  (0.1ms) rollback transaction
4403
+  (0.1ms) begin transaction
4404
+ -----------------------------------------------------------------------------
4405
+ ProtectedResourcesControllerTest: test_responds_with_success_if_authenticated
4406
+ -----------------------------------------------------------------------------
4407
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4408
+ Processing by ProtectedResourcesController#index as HTML
4409
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
4410
+ Completed 200 OK in 0ms (ActiveRecord: 0.0ms)
4411
+  (0.1ms) rollback transaction
4412
+  (0.0ms) begin transaction
4413
+ -----------------------------------------------------------------
4414
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized
4415
+ -----------------------------------------------------------------
4416
+ Processing by ProtectedResourcesController#index as HTML
4417
+ Filter chain halted as :authenticate rendered or redirected
4418
+ Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
4419
+  (0.1ms) rollback transaction
4420
+  (0.1ms) begin transaction
4421
+ ----------------------------------------------------------------
4422
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
4423
+ ----------------------------------------------------------------
4424
+  (0.1ms) rollback transaction
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  class ProtectedResourcesControllerTest < ActionController::TestCase
4
4
  def authenticate
5
5
  @user = users(:one)
6
- @token = Knock::AuthToken.new(payload: { user_id: @user.id }).token
6
+ @token = Knock::AuthToken.new(payload: { sub: @user.id }).token
7
7
  @request.env['HTTP_AUTHORIZATION'] = "Bearer #{@token}"
8
8
  end
9
9
 
@@ -1,5 +1,16 @@
1
1
  Knock.setup do |config|
2
2
 
3
+ ## Current user retrieval when validating token
4
+ ## --------------------------------------------
5
+ ##
6
+ ## This is how you can tell Knock how to retrieve the current_user.
7
+ ## By default, it assumes you have a model called `User` and that
8
+ ## the user_id is stored in the 'sub' claim.
9
+ ##
10
+ ## Default:
11
+ # config.current_user_from_token = -> (claims) { User.find claims['sub'] }
12
+
13
+
3
14
  ## Expiration claim
4
15
  ## ----------------
5
16
  ##
@@ -31,6 +42,6 @@ Knock.setup do |config|
31
42
  # config.token_secret_signature_key = -> { Rails.application.secrets.secret_key_base }
32
43
 
33
44
  ## If using Auth0, uncomment the line below
34
- # config.token_secret_signature_key = -> { Rails.application.secrets.auth0_client_secret }
45
+ # config.token_secret_signature_key = -> { JWT.base64url_decode Rails.application.secrets.auth0_client_secret }
35
46
 
36
47
  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: 1.1.0
4
+ version: 1.2.0
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: 2015-07-15 00:00:00.000000000 Z
12
+ date: 2015-07-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails