<% if flash[:notice]%>
-
<%= flash[:notice] %>
+
<%= flash[:notice]&.html_safe %>
<% end %>
<% if flash[:alert]%>
<%= flash[:alert] %>
diff --git a/config/environments/qa.rb b/config/environments/qa.rb
index 5233c4ae7..cd14dc15f 100644
--- a/config/environments/qa.rb
+++ b/config/environments/qa.rb
@@ -50,7 +50,7 @@
# Include generic and useful information about system operation, but avoid logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII).
- config.log_level = :info
+ config.log_level = :debug
# Prepend all log lines with the following tags.
config.log_tags = [:request_id]
diff --git a/config/initializers/health_monitor.rb b/config/initializers/health_monitor.rb
index c9cfbc51a..eebd03ada 100644
--- a/config/initializers/health_monitor.rb
+++ b/config/initializers/health_monitor.rb
@@ -9,6 +9,9 @@
# Mediaflux check
config.add_custom_provider(MediafluxStatus)
+ # allow the UI to load evn if mediaflux is down
+ config.providers.last.configuration.critical = false
+
# Make this health check available at /health
config.path = :health
diff --git a/config/mediaflux.yml b/config/mediaflux.yml
index b6e8fee76..0053fc2d7 100644
--- a/config/mediaflux.yml
+++ b/config/mediaflux.yml
@@ -83,7 +83,7 @@ development:
api_transport: <%= ENV["MEDIAFLUX_TRANSPORT"] || 'http' %>
api_host: <%= ENV["MEDIAFLUX_HOST"] || '0.0.0.0' %>
api_port: <%= ENV["MEDIAFLUX_PORT"] || '8888' %>
-
+
# Alternate to development is an alternate location in docker
api_alternate_hidden_root: '/td-alternate-001'
api_alternate_root_ns: '/td-alternate-001/tigerdataNS'
diff --git a/config/routes.rb b/config/routes.rb
index c2e3069bc..3bc706859 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -43,4 +43,6 @@
end
mount ActionCable.server => "/cable"
+ get "mediaflux_extra", to: "users/mediaflux_callbacks#cas", as: :mediaflux_extra
+ get "mediaflux_passthru", to: "users/mediaflux_callbacks#passthru", as: :mediaflux_passthru
end
diff --git a/docs/aterm_101.md b/docs/aterm_101.md
index 68941031a..627fc3450 100644
--- a/docs/aterm_101.md
+++ b/docs/aterm_101.md
@@ -410,7 +410,7 @@ For example:
**Note 2** Our version of mediaflux in docker does not have this command. The xtoshell command does exist on td-meta1
```
- session_id = User.first.mediaflux_session
+ session_id = SystemUser.mediaflux_session
project = Project.first
project_name = project.project_directory
project_namespace = "#{project_name}NS"
diff --git a/docs/local_development.md b/docs/local_development.md
index a7538d21c..bd5dbca00 100644
--- a/docs/local_development.md
+++ b/docs/local_development.md
@@ -127,7 +127,7 @@ You can also utilize the TestAssetGenerator in the rails console to add assets t
rails c
user = User.first
project = Project.last
- project.save_in_mediaflux(session_id: user.mediaflux_session)
+ project.save_in_mediaflux(session_id: SystemUser.mediaflux_session)
gen = TestAssetGenerator.new(project_id: project.id,user:, levels: 2, directory_per_level: 2,file_count_per_directory: 20)
gen.generate
```
@@ -137,7 +137,7 @@ You can also utilize `Mediaflux::TestAssetCreateRequest` to generate some assets
```
rails c
parent_id = 1234 # collection id from mediaflux
- gen = Mediaflux::TestAssetCreateRequest.new(session_token: User.first.mediaflux_session, parent_id:, count: 5, pattern: "test_asset_" )
+ gen = Mediaflux::TestAssetCreateRequest.new(session_token: SystemUser.mediaflux_session, parent_id:, count: 5, pattern: "test_asset_" )
gen.resolve
```
diff --git a/docs/mediaflux_manual_installation.md b/docs/mediaflux_manual_installation.md
index 428e7938b..cd37f2d60 100644
--- a/docs/mediaflux_manual_installation.md
+++ b/docs/mediaflux_manual_installation.md
@@ -33,7 +33,7 @@ Per notes from Robert Knight, Mediaflux production is running Java 1.8.0.412.b08
### 4. get the installer
```unix
$ sudo dnf install wget
-$ wget https://www.arcitecta.com/software/mf/4.16.071/mflux-dev_4.16.071_jvm_1.8.jar
+$ wget https://www.arcitecta.com/software/mf/4.16.082/mflux-dev_4.16.082_jvm_1.8.jar
$ sudo java -jar mflux-dev_jvm_1.8.jar nogui
-> accept
-> /opt/mediaflux
diff --git a/docs/mediaflux_script_access.md b/docs/mediaflux_script_access.md
index 1015a4049..e5b11acd0 100644
--- a/docs/mediaflux_script_access.md
+++ b/docs/mediaflux_script_access.md
@@ -107,7 +107,7 @@ Because the user has has access to `server.log` we can even look at the log on t
$ cat /usr/local/mediaflux/volatile/logs/filelist.1.log
# output will include something along the lines of
-# [281 76649: Network Connection: http [port=8888]],version=4.16.071,filelist,30-Sep-2024
+# [281 76649: Network Connection: http [port=8888]],version=4.16.082,filelist,30-Sep-2024
# 20:34:44.081:INFO:[user, id=157] system:scripter_user: File list for /path/to/collection
```
diff --git a/lib/tasks/projects.rake b/lib/tasks/projects.rake
index b0c0e232f..d5cb83b71 100644
--- a/lib/tasks/projects.rake
+++ b/lib/tasks/projects.rake
@@ -30,6 +30,7 @@ namespace :projects do
raise "User id must be specified" if uid.blank?
user = User.find_by(uid:)
raise "User #{uid} not found" if user.nil?
+ user.mediaflux_from_session({}) # make sure we have the system login
project_prefix = args[:prefix]
raise "Project prefix must be specified" if project_prefix.nil?
number = rand(10_000)
diff --git a/spec/channels/mediaflux_channel_spec.rb b/spec/channels/mediaflux_channel_spec.rb
index 6dcd5f664..a1851743a 100644
--- a/spec/channels/mediaflux_channel_spec.rb
+++ b/spec/channels/mediaflux_channel_spec.rb
@@ -12,7 +12,7 @@
identifier
]
end
- let(:superuser) { FactoryBot.create(:superuser) }
+ let(:superuser) { FactoryBot.create(:superuser, mediaflux_session: SystemUser.mediaflux_session) }
before do
superuser
diff --git a/spec/controllers/mediaflux_info_controller_spec.rb b/spec/controllers/mediaflux_info_controller_spec.rb
index d922e4f4e..2f738d24f 100644
--- a/spec/controllers/mediaflux_info_controller_spec.rb
+++ b/spec/controllers/mediaflux_info_controller_spec.rb
@@ -2,9 +2,9 @@
require "rails_helper"
RSpec.describe MediafluxInfoController, connect_to_mediaflux: true do
- let(:user) { FactoryBot.create :user }
+ let(:user) { FactoryBot.create :user, mediaflux_session: SystemUser.mediaflux_session }
let(:docker_response) { "{\"vendor\":\"Arcitecta Pty. Ltd.\",\"version\":\"4.16.071\"}" }
- let(:ansible_response) { "{\"vendor\":\"Arcitecta Pty. Ltd.\",\"version\":\"4.16.047\"}" }
+ let(:ansible_response) { "{\"vendor\":\"Arcitecta Pty. Ltd.\",\"version\":\"4.16.082\"}" }
before do
sign_in user
@@ -24,7 +24,7 @@
Rails.configuration.mediaflux["api_password"] = "badpass"
- expect { get :index }.to raise_error(Mediaflux::SessionExpired)
+ expect { get :index }.to raise_error(Mediaflux::SessionError)
Rails.configuration.mediaflux["api_password"] = original_pass
end
diff --git a/spec/controllers/omniauth_callbacks_controller_spec.rb b/spec/controllers/omniauth_callbacks_controller_spec.rb
index c70ab3170..72080d160 100644
--- a/spec/controllers/omniauth_callbacks_controller_spec.rb
+++ b/spec/controllers/omniauth_callbacks_controller_spec.rb
@@ -9,7 +9,7 @@
it "redirects to home page with notice" do
allow(User).to receive(:from_cas) { project_sponsor }
get :cas
- expect(response).to redirect_to(root_path)
+ expect(response).to redirect_to(mediaflux_passthru_path)
end
end
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index 6f8746312..4957cead2 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -101,6 +101,93 @@
end
end
+ describe "#content" do
+ it "renders an error when requesting json" do
+ get :show, params: { id: project.id, format: :json }
+ expect(response.content_type).to eq("application/json; charset=utf-8")
+ expect(response.body).to eq("{\"error\":\"You need to sign in or sign up before continuing.\"}")
+ end
+
+ context "a signed in user" do
+ let(:user) { FactoryBot.create :user }
+ before do
+ sign_in user
+ end
+
+ it "does not contact mediaflux" do
+ allow(Mediaflux::QueryRequest).to receive(:new).and_call_original
+
+ get :show, params: { id: project.id }
+
+ expect(Mediaflux::QueryRequest).not_to have_received(:new)
+ expect(response.body).to eq("")
+ end
+
+ context "the project is saved to mediaflux", connect_to_mediaflux: true do
+ let(:user) { FactoryBot.create :user, mediaflux_session: SystemUser.mediaflux_session }
+ let(:project) { FactoryBot.create :project_with_doi }
+ before do
+ project.save_in_mediaflux(user: user)
+ end
+ it "runs a query" do
+ allow(Mediaflux::QueryRequest).to receive(:new).and_call_original
+
+ get :show, params: { id: project.id }
+
+ expect(Mediaflux::QueryRequest).to have_received(:new)
+ end
+ context "the session expires for an active web user" do
+ let(:original_session) { SystemUser.mediaflux_session }
+
+ before do
+ allow_any_instance_of(ActionController::TestSession).to receive(:[]).and_call_original
+ allow_any_instance_of(ActionController::TestSession).to receive(:[]).with(:mediaflux_session).and_return(original_session)
+ allow_any_instance_of(ActionController::TestSession).to receive(:[]).with(:active_web_user).and_return(true)
+ end
+ it "gets a new session if the session expires" do
+ Mediaflux::LogoutRequest.new(session_token: original_session).resolve
+
+ get :show, params: { id: project.id }
+
+ expect(response).to redirect_to "http://test.host/mediaflux_passthru?path=%2Fprojects%2F#{project.id}"
+ end
+ end
+
+ context "the session expires for the system user" do
+ let(:original_session) { SystemUser.mediaflux_session }
+
+ before do
+ allow_any_instance_of(ActionController::TestSession).to receive(:[]).and_call_original
+ allow_any_instance_of(ActionController::TestSession).to receive(:[]).with(:mediaflux_session).and_return(original_session)
+ allow_any_instance_of(ActionController::TestSession).to receive(:[]).with(:active_web_user).and_return(false)
+ end
+ it "gets a new session if the session expires" do
+ Mediaflux::LogoutRequest.new(session_token: original_session).resolve
+
+ expect { get :show, params: { id: project.id } }.to raise_error(Mediaflux::SessionExpired)
+ end
+ end
+
+ context "the system user password is bad" do
+ before do
+ @original_pass = Rails.configuration.mediaflux["api_password"]
+ end
+
+ after do
+ Rails.configuration.mediaflux["api_password"] = @original_pass
+ end
+
+ it "gets a new session if the session expires" do
+ Rails.configuration.mediaflux["api_password"] = "badpass"
+ expect do
+ get :show, params: { id: project.id }
+ end.to raise_error(Mediaflux::SessionError)
+ end
+ end
+ end
+ end
+ end
+
context "when the project show views are rendered for an existing project" do
# Views are stubbed by default for rspec-rails
# https://rspec.info/features/6-0/rspec-rails/controller-specs/isolation-from-views/
diff --git a/spec/controllers/welcome_controller_spec.rb b/spec/controllers/welcome_controller_spec.rb
index 7ca8c7b49..d13bb97ba 100644
--- a/spec/controllers/welcome_controller_spec.rb
+++ b/spec/controllers/welcome_controller_spec.rb
@@ -9,7 +9,7 @@
end
context "when a user is logged in", connect_to_mediaflux: true do
- let(:user) { FactoryBot.create :user }
+ let(:user) { FactoryBot.create :user, mediaflux_session: SystemUser.mediaflux_session }
before do
sign_in user
end
@@ -84,7 +84,7 @@
end
context "when a user is logged in", connect_to_mediaflux: true do
- let(:user) { FactoryBot.create :user }
+ let(:user) { FactoryBot.create :user, mediaflux_session: SystemUser.mediaflux_session }
before do
sign_in user
end
diff --git a/spec/factories/user.rb b/spec/factories/user.rb
index 1f2045d78..07ebb53e7 100644
--- a/spec/factories/user.rb
+++ b/spec/factories/user.rb
@@ -14,6 +14,9 @@
superuser { false }
trainer { false }
+ trait :with_mediaflux_session do
+ mediaflux_session { SystemUser.mediaflux_session }
+ end
##
# A user who is allowed to sponsor a project
factory :project_sponsor do
diff --git a/spec/jobs/activate_project_job_spec.rb b/spec/jobs/activate_project_job_spec.rb
index c7ec87e30..b44c3b496 100644
--- a/spec/jobs/activate_project_job_spec.rb
+++ b/spec/jobs/activate_project_job_spec.rb
@@ -2,7 +2,7 @@
require "rails_helper"
RSpec.describe ActivateProjectJob, connect_to_mediaflux: true, type: :job do
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:project_in_mediaflux) { FactoryBot.create(:project_with_doi, status: Project::APPROVED_STATUS) }
before do
diff --git a/spec/jobs/file_inventory_cleanup_job_spec.rb b/spec/jobs/file_inventory_cleanup_job_spec.rb
index 0cc1d63e8..746404f97 100644
--- a/spec/jobs/file_inventory_cleanup_job_spec.rb
+++ b/spec/jobs/file_inventory_cleanup_job_spec.rb
@@ -2,7 +2,7 @@
require "rails_helper"
RSpec.describe FileInventoryCleanupJob, connect_to_mediaflux: true, type: :job do
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:project_in_mediaflux) { FactoryBot.create(:project_with_doi) }
let(:eight_days_ago) { Time.current.in_time_zone("America/New_York") - 8.days }
diff --git a/spec/jobs/file_inventory_job_spec.rb b/spec/jobs/file_inventory_job_spec.rb
index 14dfb3bc0..e3fcc1885 100644
--- a/spec/jobs/file_inventory_job_spec.rb
+++ b/spec/jobs/file_inventory_job_spec.rb
@@ -4,7 +4,7 @@
RSpec.describe FileInventoryJob, connect_to_mediaflux: true do
include ActiveJob::TestHelper
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:project_in_mediaflux) { FactoryBot.create(:project_with_doi) }
before do
diff --git a/spec/models/mediaflux/accumulator_create_collection_request_spec.rb b/spec/models/mediaflux/accumulator_create_collection_request_spec.rb
index b608bbaa6..373c97840 100644
--- a/spec/models/mediaflux/accumulator_create_collection_request_spec.rb
+++ b/spec/models/mediaflux/accumulator_create_collection_request_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::AccumulatorCreateCollectionRequest, connect_to_mediaflux: true, type: :model do
let(:mediaflux_url) { Mediaflux::Request.uri.to_s }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:approved_project) { FactoryBot.create(:approved_project) }
let(:mediaflux_response) { "\n
" }
diff --git a/spec/models/mediaflux/asset_create_request_spec.rb b/spec/models/mediaflux/asset_create_request_spec.rb
index 66e539be8..76801155b 100644
--- a/spec/models/mediaflux/asset_create_request_spec.rb
+++ b/spec/models/mediaflux/asset_create_request_spec.rb
@@ -6,7 +6,7 @@
let(:session_token) { Mediaflux::LogonRequest.new.session_token }
let(:root_ns) { Rails.configuration.mediaflux["api_root_collection_namespace"] } # /td-test-001
let(:parent_collection) { Rails.configuration.mediaflux["api_root_collection_name"] } # tigerdata
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:approved_project) { FactoryBot.create(:approved_project) }
let(:approved_project2) { FactoryBot.create(:approved_project) }
@@ -18,12 +18,11 @@
describe "#id" do
it "creates a collection on the server" do
Mediaflux::RootCollectionAsset.new(session_token: session_token, root_ns: root_ns, parent_collection: parent_collection).create
- session_id = User.new.mediaflux_session
- create_request = described_class.new(session_token: session_id, name: "testasset", namespace: Rails.configuration.mediaflux[:api_root_ns])
+ create_request = described_class.new(session_token: session_token, name: "testasset", namespace: Rails.configuration.mediaflux[:api_root_ns])
expect(create_request.response_error).to be_blank
expect(create_request.id).not_to be_blank
- req = Mediaflux::AssetMetadataRequest.new(session_token: session_id, id: create_request.id)
+ req = Mediaflux::AssetMetadataRequest.new(session_token: session_token, id: create_request.id)
metadata = req.metadata
expect(metadata[:name]).to eq("testasset")
end
diff --git a/spec/models/mediaflux/asset_destroy_request_spec.rb b/spec/models/mediaflux/asset_destroy_request_spec.rb
index c4fe838c5..b912eb53b 100644
--- a/spec/models/mediaflux/asset_destroy_request_spec.rb
+++ b/spec/models/mediaflux/asset_destroy_request_spec.rb
@@ -2,7 +2,7 @@
require "rails_helper"
RSpec.describe Mediaflux::AssetDestroyRequest, connect_to_mediaflux: true, type: :model do
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:approved_project) { FactoryBot.create(:approved_project) }
let(:mediaflux_response) { "\n
" }
diff --git a/spec/models/mediaflux/asset_exist_request_headers_spec.rb b/spec/models/mediaflux/asset_exist_request_headers_spec.rb
index 0d3dd8f0b..3d72ca50e 100644
--- a/spec/models/mediaflux/asset_exist_request_headers_spec.rb
+++ b/spec/models/mediaflux/asset_exist_request_headers_spec.rb
@@ -2,7 +2,7 @@
require "rails_helper"
RSpec.describe Mediaflux::AssetExistRequest, type: :model, connect_to_mediaflux: true do
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:namespace_root) { Rails.configuration.mediaflux["api_root_collection_namespace"] }
context "when we give a user to the class" do
diff --git a/spec/models/mediaflux/asset_metadata_request_spec.rb b/spec/models/mediaflux/asset_metadata_request_spec.rb
index fada1f606..e0c4f2de7 100644
--- a/spec/models/mediaflux/asset_metadata_request_spec.rb
+++ b/spec/models/mediaflux/asset_metadata_request_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::AssetMetadataRequest, connect_to_mediaflux: true, type: :model do
let(:mediaflux_url) { "http://0.0.0.0:8888/__mflux_svc__" }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:approved_project) { FactoryBot.create(:approved_project) }
let(:mediaflux_response) { "\n" }
@@ -51,7 +51,7 @@
end
context "actual mediaflux connection" do
- let(:current_user) { FactoryBot.create(:user, uid: "hc1234") }
+ let(:current_user) { FactoryBot.create(:user, uid: "hc1234", mediaflux_session: SystemUser.mediaflux_session) }
let(:valid_project) { FactoryBot.create(:project_with_dynamic_directory, project_id: "10.34770/tbd") }
let(:session_token) { current_user.mediaflux_session }
diff --git a/spec/models/mediaflux/collection_list_request_spec.rb b/spec/models/mediaflux/collection_list_request_spec.rb
index bb7b998de..8495053ae 100644
--- a/spec/models/mediaflux/collection_list_request_spec.rb
+++ b/spec/models/mediaflux/collection_list_request_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::CollectionListRequest, connect_to_mediaflux: true, type: :model do
subject(:request) { described_class.new(session_token: user.mediaflux_session) }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
describe "#resolve" do
it "retrieves the listing of collections within the default namespace" do
diff --git a/spec/models/mediaflux/iterator_destroy_request.rb b/spec/models/mediaflux/iterator_destroy_request.rb
index a53bcc952..42e0ecb8c 100644
--- a/spec/models/mediaflux/iterator_destroy_request.rb
+++ b/spec/models/mediaflux/iterator_destroy_request.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::IteratorDestroyRequest, connect_to_mediaflux: true, type: :model do
let(:mediaflux_url) { "http://0.0.0.0:8888/__mflux_svc__" }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:approved_project) { FactoryBot.create(:approved_project) }
describe "#result" do
diff --git a/spec/models/mediaflux/iterator_request_spec.rb b/spec/models/mediaflux/iterator_request_spec.rb
index 4be76a433..b5d4de192 100644
--- a/spec/models/mediaflux/iterator_request_spec.rb
+++ b/spec/models/mediaflux/iterator_request_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::IteratorRequest, connect_to_mediaflux: true, type: :model do
let(:mediaflux_url) { Mediaflux::Request.uri.to_s }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:approved_project) { FactoryBot.create(:approved_project) }
describe "#result" do
diff --git a/spec/models/mediaflux/logoff_request_spec.rb b/spec/models/mediaflux/logoff_request_spec.rb
index fe35dcca6..9f45fe0cb 100644
--- a/spec/models/mediaflux/logoff_request_spec.rb
+++ b/spec/models/mediaflux/logoff_request_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::LogoutRequest, connect_to_mediaflux: true, type: :model do
subject(:request) { described_class.new(session_token: session_token) }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:session_token) { user.mediaflux_session }
let(:mediaflux_url) { Mediaflux::Request.uri.to_s }
diff --git a/spec/models/mediaflux/logon_request_spec.rb b/spec/models/mediaflux/logon_request_spec.rb
index 3901b1399..de6964b94 100644
--- a/spec/models/mediaflux/logon_request_spec.rb
+++ b/spec/models/mediaflux/logon_request_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::LogonRequest, connect_to_mediaflux: true, type: :model do
subject(:request) { described_class.new }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:session_token) { user.mediaflux_session }
let(:mediaflux_url) { Mediaflux::Request.uri.to_s }
diff --git a/spec/models/mediaflux/namespace_create_request_spec.rb b/spec/models/mediaflux/namespace_create_request_spec.rb
index e61a2d4e4..3847d0d97 100644
--- a/spec/models/mediaflux/namespace_create_request_spec.rb
+++ b/spec/models/mediaflux/namespace_create_request_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::NamespaceCreateRequest, connect_to_mediaflux: true, type: :model do
# let(:mediaflux_url) { "http://0.0.0.0:8888/__mflux_svc__" }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:mediaflux_response) { "\n
" }
describe "#resolve" do
diff --git a/spec/models/mediaflux/namespace_describe_request_spec.rb b/spec/models/mediaflux/namespace_describe_request_spec.rb
index 73d19f3c9..d44037c26 100644
--- a/spec/models/mediaflux/namespace_describe_request_spec.rb
+++ b/spec/models/mediaflux/namespace_describe_request_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::NamespaceDescribeRequest, connect_to_mediaflux: true, type: :model do
let(:mediaflux_url) { "http://0.0.0.0:8888/__mflux_svc__" }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:mediaflux_response) { "\n" }
describe "#metadata" do
diff --git a/spec/models/mediaflux/namespace_destroy_request_spec.rb b/spec/models/mediaflux/namespace_destroy_request_spec.rb
index b5f39865d..1ee1fd695 100644
--- a/spec/models/mediaflux/namespace_destroy_request_spec.rb
+++ b/spec/models/mediaflux/namespace_destroy_request_spec.rb
@@ -4,7 +4,7 @@
RSpec.describe Mediaflux::NamespaceDestroyRequest, type: :model, connect_to_mediaflux: true do
let(:valid_project) { FactoryBot.create(:project_with_dynamic_directory, project_id: "10.34770/tbd") }
let(:namespace) { "#{valid_project.project_directory_short}NS".strip.gsub(/[^A-Za-z\d]/, "-") }
- let(:sponsor_user) { FactoryBot.create(:project_sponsor) }
+ let(:sponsor_user) { FactoryBot.create(:project_sponsor, mediaflux_session: SystemUser.mediaflux_session) }
let(:session_id) { sponsor_user.mediaflux_session }
context "when a namespace exists" do
it "deletes a namespace and everything inside of it" do
diff --git a/spec/models/mediaflux/namespace_list_request_spec.rb b/spec/models/mediaflux/namespace_list_request_spec.rb
index c781a84ef..203abb003 100644
--- a/spec/models/mediaflux/namespace_list_request_spec.rb
+++ b/spec/models/mediaflux/namespace_list_request_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::NamespaceListRequest, connect_to_mediaflux: true, type: :model do
let(:mediaflux_url) { "http://0.0.0.0:8888/__mflux_svc__" }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:mediaflux_response) { "\n" }
describe "#metadata" do
diff --git a/spec/models/mediaflux/project_approve_request_spec.rb b/spec/models/mediaflux/project_approve_request_spec.rb
index da7f3efd4..e61347717 100644
--- a/spec/models/mediaflux/project_approve_request_spec.rb
+++ b/spec/models/mediaflux/project_approve_request_spec.rb
@@ -2,7 +2,7 @@
require "rails_helper"
RSpec.describe Mediaflux::ProjectApproveRequest, type: :model, connect_to_mediaflux: true do
- let(:approver) { FactoryBot.create :sysadmin }
+ let(:approver) { FactoryBot.create :sysadmin, mediaflux_session: SystemUser.mediaflux_session }
let(:session_id) { approver.mediaflux_session }
let(:approved_project) do
project = FactoryBot.create :approved_project
diff --git a/spec/models/mediaflux/project_create_request_spec.rb b/spec/models/mediaflux/project_create_request_spec.rb
index 60a0dcbe7..f9d84b1cf 100644
--- a/spec/models/mediaflux/project_create_request_spec.rb
+++ b/spec/models/mediaflux/project_create_request_spec.rb
@@ -10,8 +10,8 @@
describe "#id" do
it "sends the metadata to the server" do
- data_user_ro = FactoryBot.create :user
- data_user_rw = FactoryBot.create :user
+ data_user_ro = FactoryBot.create :user, mediaflux_session: SystemUser.mediaflux_session
+ data_user_rw = FactoryBot.create :user, mediaflux_session: SystemUser.mediaflux_session
session_id = data_user_ro.mediaflux_session
created_on = Time.current.in_time_zone("America/New_York").iso8601
diff --git a/spec/models/mediaflux/project_update_request_spec.rb b/spec/models/mediaflux/project_update_request_spec.rb
index e663cbf1a..2213761cf 100644
--- a/spec/models/mediaflux/project_update_request_spec.rb
+++ b/spec/models/mediaflux/project_update_request_spec.rb
@@ -3,7 +3,8 @@
RSpec.describe Mediaflux::ProjectUpdateRequest, connect_to_mediaflux: true, type: :model do
let(:mediaflux_url) { "http://0.0.0.0:8888/__mflux_svc__" }
- let(:user) { FactoryBot.create(:user) }
+ let(:session_token) { SystemUser.mediaflux_session }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: session_token) }
let(:approved_project) { FactoryBot.create(:approved_project) }
let(:mediaflux_response) { "\n" }
@@ -14,7 +15,7 @@
end
it "passes the metadata values in the request" do
- update_request = described_class.new(session_token: user.mediaflux_session, project: approved_project)
+ update_request = described_class.new(session_token: session_token, project: approved_project)
update_request.resolve
expect(update_request.error?).to be false
expect(update_request.response_body).to include(mediaflux_response)
@@ -24,7 +25,7 @@
it "sends the metadata to the server", connect_to_mediaflux: true do
data_user_ro = FactoryBot.create :user
data_user_rw = FactoryBot.create :user
- session_id = data_user_ro.mediaflux_session
+ session_id = session_token
updated_on = Time.current.in_time_zone("America/New_York").iso8601.to_s
created_on = Time.current.in_time_zone("America/New_York").advance(days: -1).iso8601.to_s
project = FactoryBot.create :project, data_user_read_only: [data_user_ro.uid], data_user_read_write: [data_user_rw.uid], created_on: created_on,
diff --git a/spec/models/mediaflux/query_request_spec.rb b/spec/models/mediaflux/query_request_spec.rb
index c0258ffe3..fc6248017 100644
--- a/spec/models/mediaflux/query_request_spec.rb
+++ b/spec/models/mediaflux/query_request_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::QueryRequest, connect_to_mediaflux: true, type: :model do
let(:mediaflux_url) { Mediaflux::Request.uri.to_s }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:approved_project) { FactoryBot.create(:approved_project) }
describe "#result" do
diff --git a/spec/models/mediaflux/range_query_request_spec.rb b/spec/models/mediaflux/range_query_request_spec.rb
index 0f9a045c4..b5d3b80a5 100644
--- a/spec/models/mediaflux/range_query_request_spec.rb
+++ b/spec/models/mediaflux/range_query_request_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::RangeQueryRequest, connect_to_mediaflux: true, type: :model do
let(:mediaflux_url) { "http://0.0.0.0:8888/__mflux_svc__" }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:approved_project) { FactoryBot.create(:approved_project) }
let(:mediaflux_response) { "\n
" }
diff --git a/spec/models/mediaflux/schema_create_request_spec.rb b/spec/models/mediaflux/schema_create_request_spec.rb
index dda567a33..496868b58 100644
--- a/spec/models/mediaflux/schema_create_request_spec.rb
+++ b/spec/models/mediaflux/schema_create_request_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::SchemaCreateRequest, connect_to_mediaflux: true, type: :model do
let(:mediaflux_url) { "http://0.0.0.0:8888/__mflux_svc__" }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:approved_project) { FactoryBot.create(:approved_project) }
let(:mediaflux_response) { "\n
" }
diff --git a/spec/models/mediaflux/schema_fields_create_request_spec.rb b/spec/models/mediaflux/schema_fields_create_request_spec.rb
index 417e46d25..840728ed6 100644
--- a/spec/models/mediaflux/schema_fields_create_request_spec.rb
+++ b/spec/models/mediaflux/schema_fields_create_request_spec.rb
@@ -2,7 +2,7 @@
require "rails_helper"
RSpec.describe Mediaflux::SchemaFieldsCreateRequest, type: :model, connect_to_mediaflux: true do
- let(:user) { FactoryBot.create :user }
+ let(:user) { FactoryBot.create :user, mediaflux_session: SystemUser.mediaflux_session }
let(:required_indexed_field) { { name: "code", type: "string", index: true, "min-occurs" => 1, "max-occurs" => 1, label: "desc" } }
let(:required_not_indexed_field) { { name: "title", type: "string", index: false, "min-occurs" => 1, "max-occurs" => 1, label: "desc" } }
let(:optional_field) do
diff --git a/spec/models/mediaflux/service_execute_request_spec.rb b/spec/models/mediaflux/service_execute_request_spec.rb
index 468365d45..0efdd64f9 100644
--- a/spec/models/mediaflux/service_execute_request_spec.rb
+++ b/spec/models/mediaflux/service_execute_request_spec.rb
@@ -4,7 +4,7 @@
RSpec.describe Mediaflux::ServiceExecuteRequest, connect_to_mediaflux: true, type: :model do
subject(:request) { described_class.new(session_token: user.mediaflux_session, service_name: "asset.namespace.list") }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:approved_project) { FactoryBot.create(:approved_project) }
let(:session_token) { "test-session-token" }
let(:identity_token) { "test-identity-token" }
diff --git a/spec/models/mediaflux/store_list_request_spec.rb b/spec/models/mediaflux/store_list_request_spec.rb
index f0cf9c148..91546dc4f 100644
--- a/spec/models/mediaflux/store_list_request_spec.rb
+++ b/spec/models/mediaflux/store_list_request_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::StoreListRequest, connect_to_mediaflux: true, type: :model do
let(:mediaflux_url) { Mediaflux::Request.uri.to_s }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:approved_project) { FactoryBot.create(:approved_project) }
let(:mediaflux_response) { "\n
" }
# Docker and Ansible responses are the same, but may be different in the future
diff --git a/spec/models/mediaflux/test_asset_create_request_spec.rb b/spec/models/mediaflux/test_asset_create_request_spec.rb
index 1278fb89c..37fb69ec8 100644
--- a/spec/models/mediaflux/test_asset_create_request_spec.rb
+++ b/spec/models/mediaflux/test_asset_create_request_spec.rb
@@ -2,7 +2,7 @@
require "rails_helper"
RSpec.describe Mediaflux::TestAssetCreateRequest, connect_to_mediaflux: true, type: :model do
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:approved_project) { FactoryBot.create(:approved_project) }
let(:mediaflux_response) { "\n
" }
# let(:mediaflux_url) { "http://0.0.0.0:8888/__mflux_svc__" }
diff --git a/spec/models/mediaflux/time_spec.rb b/spec/models/mediaflux/time_spec.rb
index 30789a930..368f8e315 100644
--- a/spec/models/mediaflux/time_spec.rb
+++ b/spec/models/mediaflux/time_spec.rb
@@ -4,7 +4,7 @@
RSpec.describe Mediaflux::Time do
let(:project) { FactoryBot.build :project_with_doi }
- let(:current_user) { FactoryBot.create(:user, uid: "jh1234") }
+ let(:current_user) { FactoryBot.create(:user, uid: "jh1234", mediaflux_session: SystemUser.mediaflux_session) }
let(:docker_response) { "Etc/UTC" }
let(:ansible_response) { "America/Chicago" }
subject(:instance) { described_class.new }
diff --git a/spec/models/mediaflux/token_create_request_spec.rb b/spec/models/mediaflux/token_create_request_spec.rb
index 8b52fb02f..1357421c0 100644
--- a/spec/models/mediaflux/token_create_request_spec.rb
+++ b/spec/models/mediaflux/token_create_request_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Mediaflux::TokenCreateRequest, connect_to_mediaflux: true, type: :model do
subject(:request) { described_class.new(session_token: session_token, domain: Mediaflux::LogonRequest.mediaflux_domain, user: Mediaflux::LogonRequest.mediaflux_user) }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:session_token) { user.mediaflux_session }
let(:mediaflux_url) { Mediaflux::Request.uri.to_s }
diff --git a/spec/models/mediaflux/version_request_spec.rb b/spec/models/mediaflux/version_request_spec.rb
index 70666c522..437c97b72 100644
--- a/spec/models/mediaflux/version_request_spec.rb
+++ b/spec/models/mediaflux/version_request_spec.rb
@@ -4,7 +4,7 @@
RSpec.describe Mediaflux::VersionRequest, connect_to_mediaflux: true, type: :model do
subject(:request) { described_class.new(session_token: session_token) }
let(:session_token) { user.mediaflux_session }
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:expected_mflux_version) { "4.16" }
describe "#resolve" do
diff --git a/spec/models/project_accumulator_spec.rb b/spec/models/project_accumulator_spec.rb
index 81ca928e0..54c53b16a 100644
--- a/spec/models/project_accumulator_spec.rb
+++ b/spec/models/project_accumulator_spec.rb
@@ -2,7 +2,7 @@
require "rails_helper"
RSpec.describe ProjectAccumulator, connect_to_mediaflux: true do
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:session_id) { user.mediaflux_session }
let(:project_in_mediaflux) { FactoryBot.create(:project_with_doi, status: Project::APPROVED_STATUS) }
diff --git a/spec/models/project_mediaflux_spec.rb b/spec/models/project_mediaflux_spec.rb
index 55460416a..ca33c16b7 100644
--- a/spec/models/project_mediaflux_spec.rb
+++ b/spec/models/project_mediaflux_spec.rb
@@ -4,7 +4,7 @@
RSpec.describe ProjectMediaflux, type: :model do
let(:collection_metadata) { { id: "abc", name: "test", path: "/td-demo-001/rc/test-ns/test", description: "description", namespace: "/td-demo-001/rc/test-ns" } }
let(:project) { FactoryBot.build :project_with_doi }
- let(:current_user) { FactoryBot.create(:user, uid: "jh1234") }
+ let(:current_user) { FactoryBot.create(:user, uid: "jh1234", mediaflux_session: SystemUser.mediaflux_session) }
describe "#create!", connect_to_mediaflux: true do
context "Using test data" do
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index a052be789..c44de9fda 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -2,7 +2,7 @@
require "rails_helper"
RSpec.describe Project, type: :model, connect_to_mediaflux: true do
- let(:user) { FactoryBot.create(:user, uid: "abc123") }
+ let(:user) { FactoryBot.create(:user, uid: "abc123", mediaflux_session: SystemUser.mediaflux_session) }
describe "#sponsored_projects" do
let(:sponsor) { FactoryBot.create(:user, uid: "hc1234") }
@@ -166,7 +166,7 @@
end
describe "#file_list" do
- let(:manager) { FactoryBot.create(:user, uid: "hc1234") }
+ let(:manager) { FactoryBot.create(:user, uid: "hc1234", mediaflux_session: SystemUser.mediaflux_session) }
let(:project) do
project = FactoryBot.create(:approved_project, title: "project 111", data_manager: manager.uid)
project.mediaflux_id = nil
@@ -209,7 +209,7 @@
end
describe "#save_in_mediaflux" do
- let(:user) { FactoryBot.create(:user) }
+ let(:user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:project) { FactoryBot.create(:project_with_doi) }
it "calls ProjectMediaflux to create the project and save the id" do
expect(project.mediaflux_id).to be nil
@@ -282,7 +282,7 @@
describe "#create!" do
let(:datacite_stub) { instance_double(PULDatacite, draft_doi: "aaabbb123") }
- let(:current_user) { FactoryBot.create(:user) }
+ let(:current_user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:project) { FactoryBot.create(:project) }
before do
@@ -331,7 +331,7 @@
describe "#approve!" do
let(:datacite_stub) { instance_double(PULDatacite, draft_doi: "aaabbb123") }
- let(:current_user) { FactoryBot.create(:user) }
+ let(:current_user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:project) { FactoryBot.create(:project) }
before do
@@ -370,7 +370,7 @@
describe "#activate!" do
let(:project) { FactoryBot.create(:project_with_dynamic_directory, project_id: "10.34770/tbd")}
- let(:current_user) { FactoryBot.create(:user) }
+ let(:current_user) { FactoryBot.create(:user, mediaflux_session: SystemUser.mediaflux_session) }
let(:project_metadata) {project.metadata_model}
after do
Mediaflux::AssetDestroyRequest.new(session_token: current_user.mediaflux_session, collection: project.mediaflux_id, members: true).resolve
diff --git a/spec/models/system_user_spec.rb b/spec/models/system_user_spec.rb
new file mode 100644
index 000000000..74e7eda46
--- /dev/null
+++ b/spec/models/system_user_spec.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+require "rails_helper"
+
+RSpec.describe SystemUser, type: :model do
+ let(:mediaflux_logon) { instance_double Mediaflux::LogonRequest, error?: false, session_token: "111222333" }
+ let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
+
+ before do
+ allow(Mediaflux::LogonRequest).to receive(:new).and_return(mediaflux_logon)
+ allow(Rails).to receive(:cache).and_return(memory_store)
+ Rails.cache.clear
+ end
+
+ describe "#mediaflux_session" do
+ it "calls out to Mediaflux to login" do
+ expect(SystemUser.mediaflux_session).to eq("111222333")
+ # calling a second time to text the cache
+ expect(SystemUser.mediaflux_session).to eq("111222333")
+ expect(mediaflux_logon).to have_received(:session_token).once
+ end
+ end
+end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index d84be2448..c903cb7b3 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -214,4 +214,20 @@
expect(user).to be_eligible_sysadmin
end
end
+
+ describe "#mediaflux_from_session" do
+ let(:user) { described_class.new }
+ before do
+ allow(SystemUser).to receive(:mediaflux_session).and_return("111system")
+ end
+ it "loads the mediaflux session from the system user" do
+ expect(user.mediaflux_from_session({})).to eq("111system")
+ expect(user.mediaflux_session).to eq("111system")
+ end
+
+ it "loads the mediaflux session from the session when present" do
+ expect(user.mediaflux_from_session({ mediaflux_session: "222session" })).to eq("222session")
+ expect(user.mediaflux_session).to eq("222session")
+ end
+ end
end
diff --git a/spec/requests/mediaflux_info_spec.rb b/spec/requests/mediaflux_info_spec.rb
index 619f2e2e7..12cfd0b7a 100644
--- a/spec/requests/mediaflux_info_spec.rb
+++ b/spec/requests/mediaflux_info_spec.rb
@@ -21,10 +21,10 @@
end
context "logged in user" do
- let(:user) { FactoryBot.create(:user, uid: "pul123") }
+ let(:user) { FactoryBot.create(:user, uid: "pul123", mediaflux_session: SystemUser.mediaflux_session) }
let(:mediaflux_url) { Mediaflux::Request.uri.to_s }
- let(:docker_response) { "4.16.071" }
- let(:ansible_response) { "4.16.047" }
+ let(:docker_response) { "4.16.082" }
+ let(:ansible_response) { "4.16.071" }
before do
sign_in user
diff --git a/spec/requests/projects_spec.rb b/spec/requests/projects_spec.rb
index d6672a58e..bf30c369c 100644
--- a/spec/requests/projects_spec.rb
+++ b/spec/requests/projects_spec.rb
@@ -32,7 +32,7 @@
end
context "when the client is authenticated" do
- let(:user) { FactoryBot.create(:user, uid: "pul123") }
+ let(:user) { FactoryBot.create(:user, uid: "pul123", mediaflux_session: SystemUser.mediaflux_session) }
let(:title) { "a title" }
let(:project_directory) { "/test-project" }
diff --git a/spec/services/test_project_generator_spec.rb b/spec/services/test_project_generator_spec.rb
index 8ec8eed3e..9d2df91f8 100644
--- a/spec/services/test_project_generator_spec.rb
+++ b/spec/services/test_project_generator_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe TestProjectGenerator, connect_to_mediaflux: true do
let(:subject) { described_class.new(user:, number: 1, project_prefix: 'test-project') }
- let(:user) { FactoryBot.create :user }
+ let(:user) { FactoryBot.create :user, mediaflux_session: SystemUser.mediaflux_session}
describe "#generate" do
it "creates a project in mediaflux" do
diff --git a/spec/support/connect_to_mediaflux.rb b/spec/support/connect_to_mediaflux.rb
index 6a4a68879..7c8dcb87a 100644
--- a/spec/support/connect_to_mediaflux.rb
+++ b/spec/support/connect_to_mediaflux.rb
@@ -4,12 +4,15 @@
def reset_mediaflux_root
# Clean out the namespace before running tests to avoid collisions
- user = User.new
+ user = SystemUser
destroy_root_namespace(user)
# then create it and the project root collection and namespace so it exists for any tests
create_test_root_namespace(user)
ProjectMediaflux.create_root_tree(session_id: user.mediaflux_session)
+
+ # Clear the login cache
+ Rails.cache.clear
end
def destroy_root_namespace(user)
diff --git a/spec/system/mediaflux_info_spec.rb b/spec/system/mediaflux_info_spec.rb
index 4672ce0b2..231d432a0 100644
--- a/spec/system/mediaflux_info_spec.rb
+++ b/spec/system/mediaflux_info_spec.rb
@@ -3,7 +3,7 @@
require "rails_helper"
describe "mediaflux_info", type: :system, js: true, connect_to_mediaflux: true do
- let(:current_user) { FactoryBot.create(:user, uid: "pul123") }
+ let(:current_user) { FactoryBot.create(:user, uid: "pul123", mediaflux_session: SystemUser.mediaflux_session) }
let(:mflux_port) { Rails.configuration.mediaflux["api_port"] }
it "shows the mediaflux version" do
diff --git a/spec/system/mediaflux_session_spec.rb b/spec/system/mediaflux_session_spec.rb
index 78c3daef7..95402cc15 100644
--- a/spec/system/mediaflux_session_spec.rb
+++ b/spec/system/mediaflux_session_spec.rb
@@ -8,20 +8,25 @@
let(:sponsor_user) { FactoryBot.create(:project_sponsor, uid: "pul123") }
let(:project) { FactoryBot.create(:project, mediaflux_id: "abc123") }
- before do
- sign_in sponsor_user
- end
+ context "user is signed in" do
+ let(:original_session) { SystemUser.mediaflux_session }
+ let(:new_session) { SystemUser.mediaflux_session }
+ let(:mediaflux_logon) { instance_double Mediaflux::LogonRequest, error?: false, session_token: new_session }
- it "reconnects to mediaflux after the session ends", connect_to_mediaflux: true do
- original_session = sponsor_user.mediaflux_session
+ before do
+ sign_in sponsor_user
+ allow_any_instance_of(ActionDispatch::Request::Session).to receive(:[]).and_call_original
+ allow_any_instance_of(ActionDispatch::Request::Session).to receive(:[]).with(:mediaflux_session).and_return(original_session)
+ allow_any_instance_of(ActionDispatch::Request::Session).to receive(:[]).with(:active_web_user).and_return(true)
+ end
- # logout the session so we get an error and need to reset the session
- Mediaflux::LogoutRequest.new(session_token: original_session).resolve
+ it "connects to mediaflux once", connect_to_mediaflux: true do
+ visit root_path
- expect { visit project_path(project) }.not_to raise_error
- expect(page).to have_content("Total Files: 0")
+ expect { visit project_path(project) }.not_to raise_error
+ expect(page).to have_content("Total Files: 0")
- # a new session got automatically connected for the user in the application controller
- expect(sponsor_user.mediaflux_session).not_to eq(original_session)
+ expect(sponsor_user.mediaflux_session).to eq(original_session)
+ end
end
end
diff --git a/spec/system/project_details_spec.rb b/spec/system/project_details_spec.rb
index 0184158df..905546085 100644
--- a/spec/system/project_details_spec.rb
+++ b/spec/system/project_details_spec.rb
@@ -3,9 +3,9 @@
require "rails_helper"
RSpec.describe "Project Details Page", type: :system, connect_to_mediaflux: true, js: true do
- let(:sponsor_user) { FactoryBot.create(:project_sponsor, uid: "pul123") }
- let(:sysadmin_user) { FactoryBot.create(:sysadmin, uid: "puladmin") }
- let(:data_manager) { FactoryBot.create(:user, uid: "pul987") }
+ let(:sponsor_user) { FactoryBot.create(:project_sponsor, uid: "pul123", mediaflux_session: SystemUser.mediaflux_session) }
+ let(:sysadmin_user) { FactoryBot.create(:sysadmin, uid: "puladmin", mediaflux_session: SystemUser.mediaflux_session) }
+ let(:data_manager) { FactoryBot.create(:user, uid: "pul987", mediaflux_session: SystemUser.mediaflux_session) }
let(:read_only) { FactoryBot.create :user }
let(:read_write) { FactoryBot.create :user }
let(:pending_text) do
diff --git a/spec/system/project_roles_spec.rb b/spec/system/project_roles_spec.rb
index a748eda9d..d0d2c17be 100644
--- a/spec/system/project_roles_spec.rb
+++ b/spec/system/project_roles_spec.rb
@@ -3,10 +3,10 @@
require "rails_helper"
RSpec.describe "Project Edit Page Roles Validation", type: :system, connect_to_mediaflux: true, js: true do
- let(:sponsor_user) { FactoryBot.create(:project_sponsor, uid: "pul123") }
- let(:data_manager) { FactoryBot.create(:data_manager, uid: "pul987") }
- let(:system_admin) { FactoryBot.create(:sysadmin, uid: "pul777") }
- let(:superuser) { FactoryBot.create(:superuser, uid: "pul999") }
+ let(:sponsor_user) { FactoryBot.create(:project_sponsor, uid: "pul123", mediaflux_session: SystemUser.mediaflux_session) }
+ let(:data_manager) { FactoryBot.create(:data_manager, uid: "pul987", mediaflux_session: SystemUser.mediaflux_session) }
+ let(:system_admin) { FactoryBot.create(:sysadmin, uid: "pul777", mediaflux_session: SystemUser.mediaflux_session) }
+ let(:superuser) { FactoryBot.create(:superuser, uid: "pul999", mediaflux_session: SystemUser.mediaflux_session) }
let(:read_only) { FactoryBot.create :user }
let(:read_write) { FactoryBot.create :user }
before do
@@ -81,7 +81,7 @@
end
context "Data Sponsors and superusers are the only ones who can request a new project" do
- let(:superuser) { FactoryBot.create(:superuser) }
+ let(:superuser) { FactoryBot.create(:superuser, mediaflux_session: SystemUser.mediaflux_session) }
it "allows Data Sponsors to request a new project" do
sign_in sponsor_user
visit "/"
diff --git a/spec/system/project_spec.rb b/spec/system/project_spec.rb
index b8e9fa6ce..a0faf80e4 100644
--- a/spec/system/project_spec.rb
+++ b/spec/system/project_spec.rb
@@ -3,9 +3,9 @@
require "rails_helper"
RSpec.describe "Project Page", connect_to_mediaflux: true, type: :system do
- let(:sponsor_user) { FactoryBot.create(:project_sponsor, uid: "pul123") }
- let(:sysadmin_user) { FactoryBot.create(:sysadmin, uid: "puladmin") }
- let!(:data_manager) { FactoryBot.create(:data_manager, uid: "pul987") }
+ let(:sponsor_user) { FactoryBot.create(:project_sponsor, uid: "pul123", mediaflux_session: SystemUser.mediaflux_session) }
+ let(:sysadmin_user) { FactoryBot.create(:sysadmin, uid: "puladmin", mediaflux_session: SystemUser.mediaflux_session) }
+ let!(:data_manager) { FactoryBot.create(:data_manager, uid: "pul987", mediaflux_session: SystemUser.mediaflux_session) }
let(:read_only) { FactoryBot.create :user }
let(:read_write) { FactoryBot.create :user }
let(:pending_text) do
diff --git a/spec/system/welcome_spec.rb b/spec/system/welcome_spec.rb
index 525c7890e..3f12042f0 100644
--- a/spec/system/welcome_spec.rb
+++ b/spec/system/welcome_spec.rb
@@ -19,12 +19,12 @@
end
context "authenticated user" do
- let(:current_user) { FactoryBot.create(:user, uid: "pul123") }
+ let(:current_user) { FactoryBot.create(:user, uid: "pul123", mediaflux_session: SystemUser.mediaflux_session) }
let(:other_user) { FactoryBot.create(:user, uid: "zz123") }
let(:no_projects_user) { FactoryBot.create(:user, uid: "qw999") }
let(:no_projects_sponsor) { FactoryBot.create(:project_sponsor, uid: "gg717") }
- let(:docker_response) { "Mediaflux: 4.16.071" }
- let(:ansible_response) { "Mediaflux: 4.16.047" }
+ let(:docker_response) { "Mediaflux: 4.16.082" }
+ let(:ansible_response) { "Mediaflux: 4.16.071" }
before do
FactoryBot.create(:project, data_sponsor: current_user.uid, data_manager: other_user.uid, title: "project 111")