Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix single use links for Valkyrie. #6226

Merged
merged 5 commits into from Aug 28, 2023
Merged

Conversation

tpendragon
Copy link
Contributor

Closes #6204

This also adds a shortcut to allow creating a work that has a file, including a FileSet, FileMetadata, and File Identifier. I'm not sure it's the best, but it works really well for this test!

Closes #6204

This also adds a shortcut to allow creating a work that has a file,
including a FileSet, FileMetadata, and File Identifier. I'm not sure
it's the best, but it works really well for this test!
no-reply
no-reply previously approved these changes Aug 28, 2023
evaluator.uploaded_files.each do |file|
allow(Hyrax.config.characterization_service).to receive(:run).and_return(true)
# I don't love this - we might want to just run background jobs so
# this is more real, but we'd have to stub some things.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we do

ActiveJob::Base.queue_adapter.filter += [ValkyrieIngestJob]

Hyrax already makes use of the ActiveJob test adapter. i guess the real implementation is probably a bit fussy, since we need to reach into config and then reset it to be really clean:

old_perform_enqueued_setting = ActiveJob::Base.queue_adapter.perform_enqueued_jobs
old_job_filter = ActiveJob::Base.queue_adapter.filter 
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true
ActiveJob::Base.queue_adapter.filter += [ValkyrieIngestJob]

allow(Hyrax.config.characterization_service).to receive(:run).and_return(true)
Hyrax::WorkUploadsHandler.new(work: work).add(files: evaluator.uploaded_files).attach

ActiveJob::Base.queue_adapter.perform_enqueued_jobs = old_perform_enqueued_setting
ActiveJob::Base.queue_adapter.filter = old_job_filter

maybe more than is worth messing with?


the stub on Hyrax.config.characterization_service feels like a code smell to me. currently, if i publish file.uploaded from any synchronous code, i'll trigger a long running characterization_service.run inline. since any app can publish that event from any code, that might not be the best.

this issue is probably out of scope here, but fixing it would let us rely on the ActiveJob adapter filter for the characterization behavior too, which would offer a lot of flexiblitiy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a version that did perform_enqueued jobs

The big problem is just fits tries to run and it's not installed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the stub not take effect through the adapter?

@@ -66,7 +80,7 @@ def not_found_exception
end

def asset
@asset ||= Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: single_use_link.item_id, use_valkyrie: false)
@asset ||= Hyrax.query_service.find_by(id: single_use_link.item_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏻

@@ -24,7 +25,7 @@
.assign_access_for(visibility: evaluator.visibility_setting)
end
file_set.file_ids = evaluator.files.map(&:id) if evaluator.files
file_set.original_file_id = evaluator.original_file.id if evaluator.original_file
file_set.original_file_id = evaluator&.original_file&.id || evaluator.files&.first&.id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure i'm following this. is it used somewhere i'm missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this might be left over from a previous try.

@no-reply
Copy link
Member

approved because all the suggestions are related to test setup. both the implementation and the test setup are clearly improved here, to me.

@no-reply no-reply merged commit 5ba61e4 into main Aug 28, 2023
3 checks passed
@no-reply no-reply deleted the 6204-generate-single-use-link branch August 28, 2023 21:48
@dlpierce dlpierce added the notes-valkyrie Release Notes: Valkyrie specific label Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notes-valkyrie Release Notes: Valkyrie specific
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using a single use link generates argument error in valkyrie
3 participants