Skip to content

Commit

Permalink
test: fix tests config for OmniAuth
Browse files Browse the repository at this point in the history
  • Loading branch information
yetti committed Oct 15, 2023
1 parent 71eea98 commit 24c53d8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 44 deletions.
2 changes: 1 addition & 1 deletion spec/dummy/app/views/shared/_user_links.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<li><%= link_to "About", about_path, class: "#{active_link_class_controller(%w[pages])}" %></li>
<% if current_user %>
<li>
<%= link_to t('blacklight.header_links.logout'), destroy_user_session_path, method: :delete, data: { turbo_method: :delete } %>
<%= link_to t('blacklight.header_links.logout'), destroy_user_session_url, method: :delete, data: { turbo_method: :delete } %>
</li>
<% unless current_user.to_s.blank? %>
<li>
Expand Down
6 changes: 2 additions & 4 deletions spec/features/active_link_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@
click_link "Login"
expect(page).to have_content("Login")

fill_in "user_username", with: "bltest"
fill_in "user_password", with: "test"
click_button "Login"
click_button "Patron Login"

visit account_path

expect(page).to have_css("a.active", text: "blacklight test")
expect(page).to have_css("a.active", text: "Blacklight Test")
end
end
end
24 changes: 0 additions & 24 deletions spec/features/logout_spec.rb

This file was deleted.

30 changes: 15 additions & 15 deletions spec/files/auth/auth_hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
"provider": "keycloakopenid",
"uid": "603e26dd-b2d4-4a88-ad9d-406eaec31463",
"info": {
"name": "Staff User",
"email": "staff@nla.gov.au",
"first_name": "Staff",
"last_name": "User"
"name": "Blacklight Test",
"email": "test@example.com",
"first_name": "Blacklight",
"last_name": "Test"
},
"credentials": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6ImYyZjVmYjc3OWY4YjhhNjM2NDVlYjcxMTEzOWJhN2VhIn0.eyJleHAiOjE2NzM4NDAyOTYsImlhdCI6MTY3MzgzNjY5NiwiYXV0aF90aW1lIjoxNjcz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yJleHAiOjE2NzQwMDk0OTYsImlhdCI6MTY3MzgzNjY5NiwianRpIjoiZDE4ODViNzctMGUxNi00MzBjLWEyOTctNGE3NTA1ZWY0ZDFmIiwiaXNzIjoiaHR0cHM6Ly9sb2dpbi1kZXZlbC5ubGEuZ292LmF1L2F1dGgvcmVhbG1zL3NoaXJlIiwiYXVkIjoiaHR0cHM6Ly9sb2dpbi1kZXZlbC5ubGEuZ292LmF1L2F1dGgvcmVhbG1zL3NoaXJlIiwic3ViIjoiZjVhZmFkODEtMDZjNC00OWE2LTgyN2UtMmVmMmRkM2I4ZmRhIiwidHlwIjoiUmVmcmVzaCIsImF6cCI6ImNhdGFsb2d1ZSIsInNlc3Npb25fc3RhdGUiOiI4MDI0MjQ2MC1lZTIxLTRlMmMtYmZmNi0zY2ZjNTNiYzhlZmIiLCJzY29wZSI6InByb2ZpbGUgZW1haWwgcm9sZXMiLCJzaWQiOiI4MDI0MjQ2MC1lZTIxLTRlMmMtYmZmNi0zY2ZjNTNiYzhlZmIifQ.q_P4zHKyeEHnhlu0FFENX9c6n_YimkaokX7AV9MC-Ag",
"expires_at": 1673840296,
"expires_at": 1728943716,
"expires": true
},
"extra": {
"raw_info": {
"exp": 1673840296,
"iat": 1673836696,
"exp": 1728943716,
"iat": 1697407716,
"auth_time": 1673836696,
"jti": "8dbf0885-d727-45c4-860a-9816ae19ff5f",
"iss": "https://login.example.com/auth/realms/staff",
"iss": "https://login.example.com/auth/realms/example",
"aud": "account",
"sub": "603e26dd-b2d4-4a88-ad9d-406eaec31463",
"typ": "Bearer",
"azp": "catalogue",
"azp": "join-us",
"session_state": "80242460-ee21-4e2c-bff6-3cfc53bc8efb",
"allowed-origins": [
"localhost",
Expand Down Expand Up @@ -52,11 +52,11 @@
"offline_access",
"uma_authorization"
],
"name": "Staff User",
"preferred_username": "staff",
"given_name": "Staff",
"family_name": "User",
"email": "staff@nla.gov.au"
"name": "Blacklight Test",
"preferred_username": "c202a7d5-3d30-411a-b0a7-53753801bf98",
"given_name": "Blacklight",
"family_name": "Test",
"email": "test@example.com"
},
"id_token": null
}
Expand Down
2 changes: 2 additions & 0 deletions spec/simplecov_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
# these will be removed soon
add_filter "lib/devise/models/getalibrarycard_authenticatable.rb"
add_filter "lib/devise/strategies/getalibrarycard_authenticatable.rb"
add_filter "lib/devise/models/user_reg_authenticatable.rb"
add_filter "lib/devise/strategies/user_reg_authenticatable.rb"
end
9 changes: 9 additions & 0 deletions spec/support/omniauth.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "omniauth"

OmniAuth.config.test_mode = true

RSpec.configure do |config|
config.before do
OmniAuth.config.add_mock(:catalogue_patron, JSON.parse(IO.read("spec/files/auth/auth_hash.json")))
end
end

0 comments on commit 24c53d8

Please sign in to comment.