seek icon indicating copy to clipboard operation
seek copied to clipboard

Random `sharing_scope`-related test failure

Open fbacall opened this issue 1 year ago • 2 comments

I've seen this test fail a few times in the past, would be good to work out what is causing it.

https://github.com/seek4science/seek/actions/runs/3106803528/jobs/5034135515

--seed 41671
AuthLookupTableTest#test_deletes_records_when_assets_removed:
NoMethodError: undefined method `sharing_scope' for nil:NilClass
    lib/seek/permissions/authorization.rb:42:in `authorized_by_policy?'
    lib/seek/permissions/authorization.rb:20:in `is_authorized?'
    lib/seek/permissions/policy_based_authorization.rb:311:in `authorized_for_action'
    lib/seek/permissions/policy_based_authorization.rb:58:in `block (2 levels) in <module:PolicyBasedAuthorization>'
    lib/seek/permissions/policy_based_authorization.rb:46:in `block (2 levels) in <module:PolicyBasedAuthorization>'
    app/models/sop.rb:54:in `can_delete?'
    lib/seek/permissions/authorization_enforcement.rb:74:in `destroy_authorized?'
    test/unit/permissions/auth_lookup_table_test.rb:191:in `block in <class:AuthLookupTableTest>'

fbacall avatar Sep 23 '22 09:09 fbacall

https://github.com/seek4science/seek/actions/runs/4204796804/jobs/7295966496#step:16:22

fbacall avatar Feb 17 '23 15:02 fbacall

Still happening:

# Running tests with run options --seed 2304:

.....S..............................................................................................E
Error:
AuthLookupJobTest#test_user_auth_lookup_job_perform:
NoMethodError: undefined method `sharing_scope' for nil:NilClass

        if thing.policy.sharing_scope == Policy::ALL_USERS
                       ^^^^^^^^^^^^^^
    lib/seek/permissions/authorization.rb:42:in `authorized_by_policy?'
    lib/seek/permissions/authorization.rb:20:in `is_authorized?'
    lib/seek/permissions/policy_based_authorization.rb:307:in `authorized_for_action'
    lib/seek/permissions/policy_based_authorization.rb:196:in `block in update_lookup_table'
    lib/seek/permissions/policy_based_authorization.rb:196:in `each'
    lib/seek/permissions/policy_based_authorization.rb:196:in `update_lookup_table'
    app/jobs/user_auth_lookup_update_job.rb:8:in `block in perform'
    app/jobs/user_auth_lookup_update_job.rb:7:in `perform'
    test/unit/jobs/auth_lookup_job_test.rb:105:in `block (2 levels) in <class:AuthLookupJobTest>'
    test/test_helper.rb:76:in `with_config_value'
    test/unit/jobs/auth_lookup_job_test.rb:94:in `block in <class:AuthLookupJobTest>

https://github.com/seek4science/seek/actions/runs/7464205971/job/20310654586

fbacall avatar Jan 09 '24 17:01 fbacall