nulogy_sso 0.3.0 → 0.3.1

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
  SHA256:
3
- metadata.gz: 228ee96856caa782a84562d241a407a995eff6f036e143be561f0bbc0ad762ea
4
- data.tar.gz: 0bfa85d89f0df4fc65d543737cf7f9f5f28d3617702b1503558b8239b0db2362
3
+ metadata.gz: 1abb297df46aca53cab17459f3c5c48fd2ec261ffba96a79a3c8059785eafc0b
4
+ data.tar.gz: e5febc2597680cf99ccb2cf2c7ddda0671987c2a0b3df6d3b03bdb704a474af6
5
5
  SHA512:
6
- metadata.gz: a5afdd2da157f46ab113a271fa605bd1265a86ba733ef7012e0b4106e9ca9b287ce74dc56c36e5aa45496a9a3ed74e97c80c92a0472cf312a52944f75cbbd297
7
- data.tar.gz: fd869720b8d14f1e6666888436b243879127fbe229531605b40db32522f9f548d3af607f733aacf5c8cc8c7cdea85fcebbe04607a59b96078c83d9bd7179c421
6
+ metadata.gz: 4920a06889ea14c9f7a29c90f9f8bef5490f1881bffebf6a2351aaff307894d61b8017f21aa435ac55b378e933b75d232684fa29db1364318c26d080211d9472
7
+ data.tar.gz: a0e6d27e1a981e236f0c77830b1e29076fdcac67f476e38b180c10752fc1813be9d5a352c3ef1edc54c81a38333b43b33f975e6be855ef6df633350d24c1fb9f
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "curb"
4
- require "nulogy_sso/test_utilities/test_helper"
4
+ require_relative "jwt_test_helper"
5
5
 
6
6
  module NulogySSO
7
7
  module TestUtilities
8
8
 
9
9
  # This provides a simple mock implementation of Auth0 endpoints, via mockserver
10
- class AuthMock
10
+ class Auth0Mock
11
11
  def initialize
12
- @test_helper = NulogySSO::TestUtilities::TestHelper.new
12
+ @jwt_test_helper = NulogySSO::TestUtilities::JwtTestHelper.new
13
13
  end
14
14
 
15
15
  def setup_jwks
@@ -19,7 +19,7 @@ module NulogySSO
19
19
  path: "/.well-known/jwks.json"
20
20
  },
21
21
  httpResponse: {
22
- body: jwks_json
22
+ body: jwt_test_helper.jwks_json
23
23
  }
24
24
  )
25
25
  end
@@ -58,25 +58,13 @@ module NulogySSO
58
58
  )
59
59
  end
60
60
 
61
- def signed_jwt_response(email, overrides = {})
62
- jwt = test_helper.jwt(email, overrides)
63
-
64
- { access_token: jwt }.to_json
65
- end
66
-
67
61
  def mockserver_reset
68
62
  Curl.put(mockserver_url("reset"))
69
63
  end
70
64
 
71
- def jwks_json
72
- jwks = JSON::JWK::Set.new(test_helper.jwk)
73
- jwks.to_json
74
- end
75
-
76
65
  private
77
66
 
78
- attr_reader :test_helper
79
- delegate :private_key, to: :test_helper
67
+ attr_reader :jwt_test_helper
80
68
 
81
69
  def mockserver_expectation(body)
82
70
  Curl.put(mockserver_url("expectation"), body.to_json)
@@ -86,6 +74,12 @@ module NulogySSO
86
74
  "#{ENV.fetch("NULOGY_SSO_MOCKSERVER_HOST")}:#{ENV.fetch("NULOGY_SSO_MOCKSERVER_PORT")}/mockserver/#{path}"
87
75
  end
88
76
 
77
+ def signed_jwt_response(email, overrides = {})
78
+ jwt = jwt_test_helper.jwt(email, overrides)
79
+
80
+ { access_token: jwt }.to_json
81
+ end
82
+
89
83
  def capybara_current_host
90
84
  @capybara_current_host ||= "http://#{Capybara.current_session.server.host}:#{Capybara.current_session.server.port}"
91
85
  end
@@ -5,8 +5,9 @@ require "json/jwt"
5
5
  module NulogySSO
6
6
  module TestUtilities
7
7
 
8
- # Utilities that are useful for tests on projects using nulogy_sso
9
- class TestHelper
8
+ # Test utilities that revolve around the JWT (JSON Web Token) protocool.
9
+ # This class is mostly a helpful wrapper around this gem: https://github.com/nov/json-jwt
10
+ class JwtTestHelper
10
11
  def initialize
11
12
  @private_key = OpenSSL::PKey::RSA.new(
12
13
  File.read(File.expand_path("key.pem", __dir__))
@@ -43,6 +44,10 @@ module NulogySSO
43
44
  )
44
45
  end
45
46
 
47
+ def jwks_json
48
+ JSON::JWK::Set.new(jwk).to_json
49
+ end
50
+
46
51
  private
47
52
 
48
53
  def certificate_der
@@ -1,3 +1,3 @@
1
1
  module NulogySSO
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -3960,3 +3960,249 @@ Processing by NulogySSO::AuthenticationController#login as HTML
3960
3960
  Redirected to http://localhost:1080/authorize?audience=mock_audience&client_id=mock_client_id&redirect_uri=mock_login_uri%3Forigin%3D&response_type=code&scope=openid+email
3961
3961
  Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 159)
3962
3962
   (0.5ms) rollback transaction
3963
+  (1.9ms) SELECT sqlite_version(*)
3964
+  (0.6ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", "schema_sha1"]]
3965
+  (0.1ms) SELECT sqlite_version(*)
3966
+  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
3967
+  (0.2ms) begin transaction
3968
+  (0.4ms) SAVEPOINT active_record_1
3969
+ User Create (3.9ms) INSERT INTO "users" ("email", "created_at", "updated_at") VALUES (?, ?, ?) [["email", "test@nulogy.com"], ["created_at", "2019-09-23 19:46:49.849021"], ["updated_at", "2019-09-23 19:46:49.849021"]]
3970
+  (0.2ms) RELEASE SAVEPOINT active_record_1
3971
+ Started GET "/hello_world" for 10.2.2.127 at 2019-09-23 15:47:00 -0400
3972
+ Processing by ApplicationController#hello_world as HTML
3973
+ Redirected to http://10.2.2.127:56308/nulogy_sso/login
3974
+ Filter chain halted as :authenticate_sso_user rendered or redirected
3975
+ Completed 302 Found in 2ms (ActiveRecord: 0.0ms | Allocations: 576)
3976
+ Started GET "/nulogy_sso/login" for 10.2.2.127 at 2019-09-23 15:47:00 -0400
3977
+ Processing by NulogySSO::AuthenticationController#login as HTML
3978
+ Redirected to http://localhost:1080/authorize?audience=mock_audience&client_id=mock_client_id&redirect_uri=mock_login_uri%3Forigin%3D&response_type=code&scope=openid+email
3979
+ Completed 302 Found in 6ms (ActiveRecord: 0.0ms | Allocations: 220)
3980
+  (0.7ms) rollback transaction
3981
+  (0.1ms) begin transaction
3982
+  (0.2ms) SAVEPOINT active_record_1
3983
+ User Create (0.6ms) INSERT INTO "users" ("email", "created_at", "updated_at") VALUES (?, ?, ?) [["email", "test@nulogy.com"], ["created_at", "2019-09-23 19:47:02.368593"], ["updated_at", "2019-09-23 19:47:02.368593"]]
3984
+  (0.2ms) RELEASE SAVEPOINT active_record_1
3985
+ Started GET "/hello_world" for 10.2.2.127 at 2019-09-23 15:47:02 -0400
3986
+ Processing by ApplicationController#hello_world as HTML
3987
+ Redirected to http://10.2.2.127:56308/nulogy_sso/login
3988
+ Filter chain halted as :authenticate_sso_user rendered or redirected
3989
+ Completed 302 Found in 92ms (ActiveRecord: 0.0ms | Allocations: 2020)
3990
+ Started GET "/nulogy_sso/login" for 10.2.2.127 at 2019-09-23 15:47:02 -0400
3991
+ Processing by NulogySSO::AuthenticationController#login as HTML
3992
+ Redirected to http://localhost:1080/authorize?audience=mock_audience&client_id=mock_client_id&redirect_uri=mock_login_uri%3Forigin%3D&response_type=code&scope=openid+email
3993
+ Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 340)
3994
+  (0.4ms) rollback transaction
3995
+  (0.1ms) begin transaction
3996
+  (0.1ms) SAVEPOINT active_record_1
3997
+ User Create (0.4ms) INSERT INTO "users" ("email", "created_at", "updated_at") VALUES (?, ?, ?) [["email", "test@nulogy.com"], ["created_at", "2019-09-23 19:47:03.646699"], ["updated_at", "2019-09-23 19:47:03.646699"]]
3998
+  (0.1ms) RELEASE SAVEPOINT active_record_1
3999
+ Started GET "/hello_world" for 10.2.2.127 at 2019-09-23 15:47:04 -0400
4000
+ Processing by ApplicationController#hello_world as HTML
4001
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "test@nulogy.com"], ["LIMIT", 1]]
4002
+ Rendering text template
4003
+ Rendered text template (Duration: 0.0ms | Allocations: 3)
4004
+ Completed 200 OK in 9ms (Views: 5.5ms | ActiveRecord: 0.2ms | Allocations: 1814)
4005
+  (0.6ms) rollback transaction
4006
+  (0.1ms) begin transaction
4007
+ Started GET "/hello_world" for 10.2.2.127 at 2019-09-23 15:47:05 -0400
4008
+ Processing by ApplicationController#hello_world as HTML
4009
+ Redirected to http://10.2.2.127:56308/nulogy_sso/login
4010
+ Filter chain halted as :authenticate_sso_user rendered or redirected
4011
+ Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 171)
4012
+ Started GET "/nulogy_sso/login" for 10.2.2.127 at 2019-09-23 15:47:05 -0400
4013
+ Processing by NulogySSO::AuthenticationController#login as HTML
4014
+ Redirected to http://localhost:1080/authorize?audience=mock_audience&client_id=mock_client_id&redirect_uri=mock_login_uri%3Forigin%3D&response_type=code&scope=openid+email
4015
+ Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 159)
4016
+ Started GET "/nulogy_sso/code?code=FAKE_CODE&origin=http%3A%2F%2F10.2.2.127%3A56308" for 10.2.2.127 at 2019-09-23 15:47:05 -0400
4017
+ Processing by NulogySSO::AuthenticationController#code as HTML
4018
+ Parameters: {"code"=>"FAKE_CODE", "origin"=>"http://10.2.2.127:56308"}
4019
+ User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "test@nulogy.com"], ["LIMIT", 1]]
4020
+ Rendering text template
4021
+ Rendered text template (Duration: 0.1ms | Allocations: 1)
4022
+ Completed 200 OK in 86ms (Views: 1.7ms | ActiveRecord: 0.5ms | Allocations: 3832)
4023
+  (0.1ms) rollback transaction
4024
+  (0.2ms) begin transaction
4025
+  (0.1ms) SAVEPOINT active_record_1
4026
+ User Create (0.4ms) INSERT INTO "users" ("email", "created_at", "updated_at") VALUES (?, ?, ?) [["email", "test@nulogy.com"], ["created_at", "2019-09-23 19:47:06.000109"], ["updated_at", "2019-09-23 19:47:06.000109"]]
4027
+  (0.1ms) RELEASE SAVEPOINT active_record_1
4028
+ Started GET "/hello_world" for 10.2.2.127 at 2019-09-23 15:47:06 -0400
4029
+ Processing by ApplicationController#hello_world as HTML
4030
+ Redirected to http://10.2.2.127:56308/nulogy_sso/login
4031
+ Filter chain halted as :authenticate_sso_user rendered or redirected
4032
+ Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 171)
4033
+ Started GET "/nulogy_sso/login" for 10.2.2.127 at 2019-09-23 15:47:06 -0400
4034
+ Processing by NulogySSO::AuthenticationController#login as HTML
4035
+ Redirected to http://localhost:1080/authorize?audience=mock_audience&client_id=mock_client_id&redirect_uri=mock_login_uri%3Forigin%3D&response_type=code&scope=openid+email
4036
+ Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 159)
4037
+ Started GET "/nulogy_sso/code?code=FAKE_CODE&origin=http%3A%2F%2F10.2.2.127%3A56308%2Fhello_world" for 10.2.2.127 at 2019-09-23 15:47:06 -0400
4038
+ Processing by NulogySSO::AuthenticationController#code as HTML
4039
+ Parameters: {"code"=>"FAKE_CODE", "origin"=>"http://10.2.2.127:56308/hello_world"}
4040
+ User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "test@nulogy.com"], ["LIMIT", 1]]
4041
+ Redirected to http://10.2.2.127:56308/hello_world
4042
+ Completed 302 Found in 57ms (ActiveRecord: 0.3ms | Allocations: 2481)
4043
+ Started GET "/hello_world" for 10.2.2.127 at 2019-09-23 15:47:06 -0400
4044
+ Processing by ApplicationController#hello_world as HTML
4045
+ User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "test@nulogy.com"], ["LIMIT", 1]]
4046
+ Rendering text template
4047
+ Rendered text template (Duration: 0.1ms | Allocations: 1)
4048
+ Completed 200 OK in 4ms (Views: 1.1ms | ActiveRecord: 0.3ms | Allocations: 502)
4049
+  (0.4ms) rollback transaction
4050
+  (0.1ms) begin transaction
4051
+  (0.1ms) SAVEPOINT active_record_1
4052
+ User Create (0.4ms) INSERT INTO "users" ("email", "created_at", "updated_at") VALUES (?, ?, ?) [["email", "test@nulogy.com"], ["created_at", "2019-09-23 19:47:07.665881"], ["updated_at", "2019-09-23 19:47:07.665881"]]
4053
+  (0.1ms) RELEASE SAVEPOINT active_record_1
4054
+ Started GET "/hello_world" for 10.2.2.127 at 2019-09-23 15:47:07 -0400
4055
+ Processing by ApplicationController#hello_world as HTML
4056
+ Redirected to http://10.2.2.127:56308/nulogy_sso/login
4057
+ Filter chain halted as :authenticate_sso_user rendered or redirected
4058
+ Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 171)
4059
+ Started GET "/nulogy_sso/login" for 10.2.2.127 at 2019-09-23 15:47:07 -0400
4060
+ Processing by NulogySSO::AuthenticationController#login as HTML
4061
+ Redirected to http://localhost:1080/authorize?audience=mock_audience&client_id=mock_client_id&redirect_uri=mock_login_uri%3Forigin%3D&response_type=code&scope=openid+email
4062
+ Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 159)
4063
+ Started GET "/nulogy_sso/code?code=FAKE_CODE&origin=http%3A%2F%2F10.2.2.127%3A56308" for 10.2.2.127 at 2019-09-23 15:47:07 -0400
4064
+ Processing by NulogySSO::AuthenticationController#code as HTML
4065
+ Parameters: {"code"=>"FAKE_CODE", "origin"=>"http://10.2.2.127:56308"}
4066
+ Rendering text template
4067
+ Rendered text template (Duration: 0.1ms | Allocations: 1)
4068
+ Completed 200 OK in 62ms (Views: 0.9ms | ActiveRecord: 0.0ms | Allocations: 2185)
4069
+  (0.7ms) rollback transaction
4070
+  (0.1ms) begin transaction
4071
+  (0.1ms) rollback transaction
4072
+  (0.1ms) begin transaction
4073
+  (0.1ms) rollback transaction
4074
+  (0.1ms) begin transaction
4075
+  (0.0ms) rollback transaction
4076
+  (0.1ms) begin transaction
4077
+  (0.1ms) rollback transaction
4078
+  (0.1ms) begin transaction
4079
+  (0.1ms) rollback transaction
4080
+  (0.0ms) begin transaction
4081
+  (0.0ms) rollback transaction
4082
+  (0.1ms) begin transaction
4083
+  (0.1ms) rollback transaction
4084
+  (0.1ms) begin transaction
4085
+  (0.1ms) rollback transaction
4086
+  (1.9ms) SELECT sqlite_version(*)
4087
+  (0.6ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", "schema_sha1"]]
4088
+  (0.1ms) SELECT sqlite_version(*)
4089
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
4090
+  (0.3ms) begin transaction
4091
+  (0.1ms) rollback transaction
4092
+  (0.1ms) begin transaction
4093
+  (0.3ms) rollback transaction
4094
+  (0.2ms) begin transaction
4095
+  (0.1ms) rollback transaction
4096
+  (0.1ms) begin transaction
4097
+  (0.6ms) rollback transaction
4098
+  (1.4ms) begin transaction
4099
+  (0.2ms) rollback transaction
4100
+  (0.1ms) begin transaction
4101
+  (0.3ms) rollback transaction
4102
+  (0.4ms) begin transaction
4103
+  (0.1ms) rollback transaction
4104
+  (0.0ms) begin transaction
4105
+  (0.1ms) rollback transaction
4106
+  (0.3ms) begin transaction
4107
+  (0.1ms) SAVEPOINT active_record_1
4108
+ User Create (0.4ms) INSERT INTO "users" ("email", "created_at", "updated_at") VALUES (?, ?, ?) [["email", "test@nulogy.com"], ["created_at", "2019-09-23 19:47:47.229667"], ["updated_at", "2019-09-23 19:47:47.229667"]]
4109
+  (0.0ms) RELEASE SAVEPOINT active_record_1
4110
+ Started GET "/hello_world" for 10.2.2.127 at 2019-09-23 15:47:48 -0400
4111
+ Processing by ApplicationController#hello_world as HTML
4112
+ Redirected to http://10.2.2.127:56392/nulogy_sso/login
4113
+ Filter chain halted as :authenticate_sso_user rendered or redirected
4114
+ Completed 302 Found in 3ms (ActiveRecord: 0.0ms | Allocations: 568)
4115
+ Started GET "/nulogy_sso/login" for 10.2.2.127 at 2019-09-23 15:47:48 -0400
4116
+ Processing by NulogySSO::AuthenticationController#login as HTML
4117
+ Redirected to http://localhost:1080/authorize?audience=mock_audience&client_id=mock_client_id&redirect_uri=mock_login_uri%3Forigin%3D&response_type=code&scope=openid+email
4118
+ Completed 302 Found in 5ms (ActiveRecord: 0.0ms | Allocations: 219)
4119
+ Started GET "/nulogy_sso/code?code=FAKE_CODE&origin=http%3A%2F%2F10.2.2.127%3A56392" for 10.2.2.127 at 2019-09-23 15:47:49 -0400
4120
+ Processing by NulogySSO::AuthenticationController#code as HTML
4121
+ Parameters: {"code"=>"FAKE_CODE", "origin"=>"http://10.2.2.127:56392"}
4122
+ Rendering text template
4123
+ Rendered text template (Duration: 0.0ms | Allocations: 3)
4124
+ Completed 200 OK in 99ms (Views: 5.6ms | ActiveRecord: 0.0ms | Allocations: 4454)
4125
+  (0.5ms) rollback transaction
4126
+  (0.2ms) begin transaction
4127
+ Started GET "/hello_world" for 10.2.2.127 at 2019-09-23 15:47:50 -0400
4128
+ Processing by ApplicationController#hello_world as HTML
4129
+ Redirected to http://10.2.2.127:56392/nulogy_sso/login
4130
+ Filter chain halted as :authenticate_sso_user rendered or redirected
4131
+ Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 171)
4132
+ Started GET "/nulogy_sso/login" for 10.2.2.127 at 2019-09-23 15:47:50 -0400
4133
+ Processing by NulogySSO::AuthenticationController#login as HTML
4134
+ Redirected to http://localhost:1080/authorize?audience=mock_audience&client_id=mock_client_id&redirect_uri=mock_login_uri%3Forigin%3D&response_type=code&scope=openid+email
4135
+ Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 159)
4136
+ Started GET "/nulogy_sso/code?code=FAKE_CODE&origin=http%3A%2F%2F10.2.2.127%3A56392" for 10.2.2.127 at 2019-09-23 15:47:50 -0400
4137
+ Processing by NulogySSO::AuthenticationController#code as HTML
4138
+ Parameters: {"code"=>"FAKE_CODE", "origin"=>"http://10.2.2.127:56392"}
4139
+ User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "test@nulogy.com"], ["LIMIT", 1]]
4140
+ Rendering text template
4141
+ Rendered text template (Duration: 0.1ms | Allocations: 1)
4142
+ Completed 200 OK in 78ms (Views: 0.9ms | ActiveRecord: 0.5ms | Allocations: 4370)
4143
+  (0.1ms) rollback transaction
4144
+  (0.3ms) begin transaction
4145
+  (0.1ms) SAVEPOINT active_record_1
4146
+ User Create (0.6ms) INSERT INTO "users" ("email", "created_at", "updated_at") VALUES (?, ?, ?) [["email", "test@nulogy.com"], ["created_at", "2019-09-23 19:47:51.067553"], ["updated_at", "2019-09-23 19:47:51.067553"]]
4147
+  (0.1ms) RELEASE SAVEPOINT active_record_1
4148
+ Started GET "/hello_world" for 10.2.2.127 at 2019-09-23 15:47:51 -0400
4149
+ Processing by ApplicationController#hello_world as HTML
4150
+ Redirected to http://10.2.2.127:56392/nulogy_sso/login
4151
+ Filter chain halted as :authenticate_sso_user rendered or redirected
4152
+ Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 171)
4153
+ Started GET "/nulogy_sso/login" for 10.2.2.127 at 2019-09-23 15:47:51 -0400
4154
+ Processing by NulogySSO::AuthenticationController#login as HTML
4155
+ Redirected to http://localhost:1080/authorize?audience=mock_audience&client_id=mock_client_id&redirect_uri=mock_login_uri%3Forigin%3D&response_type=code&scope=openid+email
4156
+ Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 159)
4157
+ Started GET "/nulogy_sso/code?code=FAKE_CODE&origin=http%3A%2F%2F10.2.2.127%3A56392%2Fhello_world" for 10.2.2.127 at 2019-09-23 15:47:51 -0400
4158
+ Processing by NulogySSO::AuthenticationController#code as HTML
4159
+ Parameters: {"code"=>"FAKE_CODE", "origin"=>"http://10.2.2.127:56392/hello_world"}
4160
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "test@nulogy.com"], ["LIMIT", 1]]
4161
+ Redirected to http://10.2.2.127:56392/hello_world
4162
+ Completed 302 Found in 49ms (ActiveRecord: 0.2ms | Allocations: 2492)
4163
+ Started GET "/hello_world" for 10.2.2.127 at 2019-09-23 15:47:51 -0400
4164
+ Processing by ApplicationController#hello_world as HTML
4165
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "test@nulogy.com"], ["LIMIT", 1]]
4166
+ Rendering text template
4167
+ Rendered text template (Duration: 0.0ms | Allocations: 1)
4168
+ Completed 200 OK in 2ms (Views: 0.7ms | ActiveRecord: 0.1ms | Allocations: 649)
4169
+  (0.8ms) rollback transaction
4170
+  (0.1ms) begin transaction
4171
+  (0.2ms) SAVEPOINT active_record_1
4172
+ User Create (0.9ms) INSERT INTO "users" ("email", "created_at", "updated_at") VALUES (?, ?, ?) [["email", "test@nulogy.com"], ["created_at", "2019-09-23 19:47:51.967119"], ["updated_at", "2019-09-23 19:47:51.967119"]]
4173
+  (0.2ms) RELEASE SAVEPOINT active_record_1
4174
+ Started GET "/hello_world" for 10.2.2.127 at 2019-09-23 15:47:52 -0400
4175
+ Processing by ApplicationController#hello_world as HTML
4176
+ User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "test@nulogy.com"], ["LIMIT", 1]]
4177
+ Rendering text template
4178
+ Rendered text template (Duration: 0.1ms | Allocations: 1)
4179
+ Completed 200 OK in 6ms (Views: 1.1ms | ActiveRecord: 0.3ms | Allocations: 502)
4180
+  (0.4ms) rollback transaction
4181
+  (0.2ms) begin transaction
4182
+  (0.3ms) SAVEPOINT active_record_1
4183
+ User Create (0.8ms) INSERT INTO "users" ("email", "created_at", "updated_at") VALUES (?, ?, ?) [["email", "test@nulogy.com"], ["created_at", "2019-09-23 19:47:54.143490"], ["updated_at", "2019-09-23 19:47:54.143490"]]
4184
+  (0.1ms) RELEASE SAVEPOINT active_record_1
4185
+ Started GET "/hello_world" for 10.2.2.127 at 2019-09-23 15:47:54 -0400
4186
+ Processing by ApplicationController#hello_world as HTML
4187
+ Redirected to http://10.2.2.127:56392/nulogy_sso/login
4188
+ Filter chain halted as :authenticate_sso_user rendered or redirected
4189
+ Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 171)
4190
+ Started GET "/nulogy_sso/login" for 10.2.2.127 at 2019-09-23 15:47:54 -0400
4191
+ Processing by NulogySSO::AuthenticationController#login as HTML
4192
+ Redirected to http://localhost:1080/authorize?audience=mock_audience&client_id=mock_client_id&redirect_uri=mock_login_uri%3Forigin%3D&response_type=code&scope=openid+email
4193
+ Completed 302 Found in 2ms (ActiveRecord: 0.0ms | Allocations: 159)
4194
+  (0.3ms) rollback transaction
4195
+  (0.1ms) begin transaction
4196
+  (0.1ms) SAVEPOINT active_record_1
4197
+ User Create (0.4ms) INSERT INTO "users" ("email", "created_at", "updated_at") VALUES (?, ?, ?) [["email", "test@nulogy.com"], ["created_at", "2019-09-23 19:47:55.948316"], ["updated_at", "2019-09-23 19:47:55.948316"]]
4198
+  (0.1ms) RELEASE SAVEPOINT active_record_1
4199
+ Started GET "/hello_world" for 10.2.2.127 at 2019-09-23 15:47:56 -0400
4200
+ Processing by ApplicationController#hello_world as HTML
4201
+ Redirected to http://10.2.2.127:56392/nulogy_sso/login
4202
+ Filter chain halted as :authenticate_sso_user rendered or redirected
4203
+ Completed 302 Found in 3ms (ActiveRecord: 0.0ms | Allocations: 353)
4204
+ Started GET "/nulogy_sso/login" for 10.2.2.127 at 2019-09-23 15:47:56 -0400
4205
+ Processing by NulogySSO::AuthenticationController#login as HTML
4206
+ Redirected to http://localhost:1080/authorize?audience=mock_audience&client_id=mock_client_id&redirect_uri=mock_login_uri%3Forigin%3D&response_type=code&scope=openid+email
4207
+ Completed 302 Found in 2ms (ActiveRecord: 0.0ms | Allocations: 340)
4208
+  (0.5ms) rollback transaction
data/spec/examples.txt CHANGED
@@ -1,16 +1,16 @@
1
1
  example_id | status | run_time |
2
2
  --------------------------------------------------------------------- | ------ | --------------- |
3
- ./spec/features/nulogy_sso/sso_login_spec.rb[1:1:1] | passed | 3.41 seconds |
4
- ./spec/features/nulogy_sso/sso_login_spec.rb[1:1:2] | passed | 0.90831 seconds |
5
- ./spec/features/nulogy_sso/sso_login_spec.rb[1:1:3] | passed | 0.66936 seconds |
6
- ./spec/features/nulogy_sso/sso_login_spec.rb[1:2:1] | passed | 0.82161 seconds |
7
- ./spec/features/nulogy_sso/sso_login_spec.rb[1:2:2] | passed | 0.72697 seconds |
8
- ./spec/features/nulogy_sso/sso_login_spec.rb[1:2:3] | passed | 0.82277 seconds |
9
- ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:1:1] | passed | 0.00927 seconds |
10
- ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:1:2:1] | passed | 0.02476 seconds |
11
- ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:1:2:2] | passed | 0.01496 seconds |
12
- ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:1:3:1] | passed | 0.01599 seconds |
13
- ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:2:1] | passed | 0.03698 seconds |
14
- ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:2:2] | passed | 0.03118 seconds |
15
- ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:2:3] | passed | 0.00426 seconds |
16
- ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:2:4] | passed | 0.02018 seconds |
3
+ ./spec/features/nulogy_sso/sso_login_spec.rb[1:1:1] | passed | 1.06 seconds |
4
+ ./spec/features/nulogy_sso/sso_login_spec.rb[1:1:2] | passed | 1.02 seconds |
5
+ ./spec/features/nulogy_sso/sso_login_spec.rb[1:1:3] | passed | 3.32 seconds |
6
+ ./spec/features/nulogy_sso/sso_login_spec.rb[1:2:1] | passed | 2.18 seconds |
7
+ ./spec/features/nulogy_sso/sso_login_spec.rb[1:2:2] | passed | 1.88 seconds |
8
+ ./spec/features/nulogy_sso/sso_login_spec.rb[1:2:3] | passed | 1.81 seconds |
9
+ ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:1:1] | passed | 0.01087 seconds |
10
+ ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:1:2:1] | passed | 0.02615 seconds |
11
+ ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:1:2:2] | passed | 0.0203 seconds |
12
+ ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:1:3:1] | passed | 0.0369 seconds |
13
+ ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:2:1] | passed | 0.03127 seconds |
14
+ ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:2:2] | passed | 0.02067 seconds |
15
+ ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:2:3] | passed | 0.00746 seconds |
16
+ ./spec/integration/services/nulogy_sso/authenticator_spec.rb[1:2:4] | passed | 0.01329 seconds |
@@ -5,12 +5,12 @@ require "feature_spec_helper"
5
5
  module NulogySSO
6
6
  RSpec.describe "the SSO login process", type: :feature, js: true do
7
7
  let(:email) { "test@nulogy.com" }
8
- let(:auth_mock) { TestUtilities::AuthMock.new }
9
- let(:test_helper) { TestUtilities::TestHelper.new }
8
+ let(:auth0_mock) { TestUtilities::Auth0Mock.new }
9
+ let(:jwt_test_helper) { TestUtilities::JwtTestHelper.new }
10
10
 
11
11
  describe "login flow" do
12
12
  it "can successfully login" do
13
- auth_mock.setup(email: email, redirect_path: "/hello_world")
13
+ auth0_mock.setup(email: email, redirect_path: "/hello_world")
14
14
  create_user
15
15
 
16
16
  visit "/hello_world"
@@ -19,7 +19,7 @@ module NulogySSO
19
19
  end
20
20
 
21
21
  it "shows an error page when the user can authorize with Auth0 but not exist in the app" do
22
- auth_mock.setup(email: email)
22
+ auth0_mock.setup(email: email)
23
23
 
24
24
  visit "/hello_world"
25
25
 
@@ -27,7 +27,7 @@ module NulogySSO
27
27
  end
28
28
 
29
29
  it "shows an error page when Auth0 throws an error" do
30
- auth_mock.setup(email: email, status_code: 403)
30
+ auth0_mock.setup(email: email, status_code: 403)
31
31
  create_user
32
32
 
33
33
  visit "/hello_world"
@@ -40,15 +40,15 @@ module NulogySSO
40
40
  let!(:user) { create_user }
41
41
 
42
42
  before do
43
- auth_mock.mockserver_reset
44
- auth_mock.setup_jwks
43
+ auth0_mock.mockserver_reset
44
+ auth0_mock.setup_jwks
45
45
 
46
46
  # have to visit an unauthenticated endpoint in order for capybara to have something to have a tab to set the cookie on
47
47
  visit "/robots.txt"
48
48
  end
49
49
 
50
50
  it "allows a user with a valid JWT to visit a secured endpoint" do
51
- set_access_token_cookie(test_helper.jwt(email))
51
+ set_access_token_cookie(jwt_test_helper.jwt(email))
52
52
 
53
53
  visit "/hello_world"
54
54
 
@@ -56,7 +56,7 @@ module NulogySSO
56
56
  end
57
57
 
58
58
  it "prevents sessions with invalid JWTs from accessing secured endpoints" do
59
- set_access_token_cookie(test_helper.jwt(email, "exp" => (Time.now - 1.day).to_i))
59
+ set_access_token_cookie(jwt_test_helper.jwt(email, "exp" => (Time.now - 1.day).to_i))
60
60
 
61
61
  visit "/hello_world"
62
62
 
@@ -7,7 +7,7 @@ module NulogySSO
7
7
  MockAuth0Verifier.new(
8
8
  issuer: "#{auth_config.base_uri}/",
9
9
  audience: auth_config.audience,
10
- jwks: TestUtilities::AuthMock.new.jwks_json
10
+ jwks: jwt_test_helper.jwks_json
11
11
  )
12
12
  end
13
13
  let(:default_authenticator) { Authenticator.new(verifier: verifier, find_user_by_email: find_a_user) }
@@ -17,9 +17,9 @@ module NulogySSO
17
17
  let(:on_success) { spy("on_success") }
18
18
  let(:on_invalid_token) { spy("on_invalid_token") }
19
19
  let(:email) { "sso_test@nulogy.com" }
20
- let(:valid_signed_token) { test_helper.jwt(email) }
21
- let(:invalid_signed_token) { test_helper.jwt(email, "exp" => 1.day.ago.to_i) }
22
- let(:test_helper) { TestUtilities::TestHelper.new }
20
+ let(:valid_signed_token) { jwt_test_helper.jwt(email) }
21
+ let(:invalid_signed_token) { jwt_test_helper.jwt(email, "exp" => 1.day.ago.to_i) }
22
+ let(:jwt_test_helper) { TestUtilities::JwtTestHelper.new }
23
23
 
24
24
  describe "#validate_token" do
25
25
  it "calls on_invalid_token when the access token is blank" do
data/spec/rails_helper.rb CHANGED
@@ -10,8 +10,8 @@ require "rspec/rails"
10
10
 
11
11
  Dir[NulogySSO::Engine.root.join("spec/support/**/*.rb")].each { |f| require f }
12
12
 
13
- require "nulogy_sso/test_utilities/auth_mock"
14
- require "nulogy_sso/test_utilities/test_helper"
13
+ require "nulogy_sso/test_utilities/auth0_mock"
14
+ require "nulogy_sso/test_utilities/jwt_test_helper"
15
15
 
16
16
  begin
17
17
  ActiveRecord::Migration.maintain_test_schema!
@@ -4,7 +4,6 @@
4
4
  # to still be used for verifying JWTs, but with a localhost JWKS specified.
5
5
  # This code was adapted from the gem's test suite:
6
6
  # https://github.com/DroidsOnRoids/auth0_rs256_jwt_verifier/blob/master/test/auth0_rs256_jwt_verifier_test.rb
7
-
8
7
  class MockAuth0Verifier
9
8
  def initialize(issuer:, audience:, jwks:)
10
9
  @internal_verifier = Auth0RS256JWTVerifier.new(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nulogy_sso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nulogy Corporation
@@ -186,10 +186,10 @@ files:
186
186
  - lib/nulogy_sso.rb
187
187
  - lib/nulogy_sso/controller_helper.rb
188
188
  - lib/nulogy_sso/engine.rb
189
- - lib/nulogy_sso/test_utilities/auth_mock.rb
189
+ - lib/nulogy_sso/test_utilities/auth0_mock.rb
190
190
  - lib/nulogy_sso/test_utilities/cert.der
191
+ - lib/nulogy_sso/test_utilities/jwt_test_helper.rb
191
192
  - lib/nulogy_sso/test_utilities/key.pem
192
- - lib/nulogy_sso/test_utilities/test_helper.rb
193
193
  - lib/nulogy_sso/version.rb
194
194
  - spec/dummy/Rakefile
195
195
  - spec/dummy/app/assets/config/manifest.js