Flaky test ee/spec/requests/api/vulnerabilities_spec.rb:166 # API::Vulnerabilities POST /projects/:id/vulnerabilities permissions is expected to be allowed for :admin
Job #1310650587 failed for 34a8568b:
1) API::Vulnerabilities POST /projects/:id/vulnerabilities permissions is expected to be allowed for :admin
Failure/Error:
if instance_variable_get(:@__#{USER_ACCESSOR_METHOD_NAME}_patched)
raise ArgumentError, 'An access matcher be_allowed_for/be_denied_for can be used only once per example (`it` block)'
end
instance_variable_set(:@__#{USER_ACCESSOR_METHOD_NAME}_patched, true)
def #{USER_ACCESSOR_METHOD_NAME}
@#{USER_ACCESSOR_METHOD_NAME} ||= User.find(#{user.id})
end
ArgumentError:
An access matcher be_allowed_for/be_denied_for can be used only once per example (`it` block)
# ./spec/support/helpers/access_matchers_helpers.rb:65:in `patch_example_group'
# ./spec/support/helpers/access_matchers_helpers.rb:63:in `instance_eval'
# ./spec/support/helpers/access_matchers_helpers.rb:63:in `patch_example_group'
# ./spec/support/helpers/access_matchers_helpers.rb:80:in `prepare_matcher_environment'
# ./spec/support/helpers/access_matchers_helpers.rb:87:in `run_matcher'
# ./spec/support/matchers/access_matchers_for_request.rb:22:in `block (2 levels) in <module:AccessMatchersForRequest>'
# ./ee/spec/requests/api/vulnerabilities_spec.rb:166:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:375:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:366:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:362:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:31:in `with_raw_context'
# ./spec/spec_helper.rb:362:in `block (2 levels) in <top (required)>'
Finished in 17 minutes 25 seconds (files took 44.79 seconds to load)
856 examples, 1 failure
Failed examples:
rspec ./ee/spec/requests/api/vulnerabilities_spec.rb:166 # API::Vulnerabilities POST /projects/:id/vulnerabilities permissions is expected to be allowed for :admin
POST /projects/:id/vulnerabilities
with an authorized user with proper permissions
creates a vulnerability from finding and attaches it to the vulnerability
when finding id is unknown
responds with expected error
when a vulnerability already exists for a specific finding
rejects creation of a new vulnerability from this finding
behaves like forbids access to vulnerability API endpoint in case of disabled features
when security dashboard feature is not available
responds with 403 Forbidden
permissions
is expected to be allowed for :admin (FAILED - 1)
1st Try error in ./ee/spec/requests/api/vulnerabilities_spec.rb:166:
expected this action to be allowed for admin role. Expected status code: any of 200, 201, 204, 302, 304 Got: 500
RSpec::Retry: 2nd try ./ee/spec/requests/api/vulnerabilities_spec.rb:166
2nd Try error in ./ee/spec/requests/api/vulnerabilities_spec.rb:166:
An access matcher be_allowed_for/be_denied_for can be used only once per example (`it` block)
RSpec::Retry: 3rd try ./ee/spec/requests/api/vulnerabilities_spec.rb:166
3rd Try error in ./ee/spec/requests/api/vulnerabilities_spec.rb:166:
An access matcher be_allowed_for/be_denied_for can be used only once per example (`it` block)
RSpec::Retry: 4th try ./ee/spec/requests/api/vulnerabilities_spec.rb:166
The first error is expected this action to be allowed for admin role. Expected status code: any of 200, 201, 204, 302, 304 Got: 500
but then the second error is due to rspec-retry
which doesn't unset :@__#{USER_ACCESSOR_METHOD_NAME}_patched
instance variable: https://gitlab.com/gitlab-org/gitlab/-/blob/6e7e449dba65077aca8faabc63848ebdcf662444/spec/support/helpers/access_matchers_helpers.rb#L64-66