Developed by the the Alliance in collaboration with University of Alberta, DMP Assistant a data management planning tool, forking the DMP Roadmap codebase
MIT License
6
stars
1
forks
source link
Address Flaky Tests Due to Overriding of `OmniAuth.config.mock_auth[:openid_connect]` #921
Please complete the following fields as applicable:
What version of the DMPRoadmap code are you running? (e.g. v2.2.0)
4.1.1+portage-4.2.2
Expected behaviour:
The tests defined in spec/integration/openid_connect_sso_spec.rb largely rely on OmniAuth.config.mock_auth[:openid_connect], which is defined in spec/spec_helper.rb.
For example, expect(identifiable.firstname).to eql('John') relies on first_name: 'John', defined in spec/spec_helper.rb.
Actual behaviour:
The aforementioned tests sometimes fail. The following is an example of one such error:
3) Openid_connection SSO with correct credentials creates account from external credentials
Failure/Error: expect(identifiable.firstname).to eql('John')
expected: "John"
got: "Test"
(compared using eql?)
# ./spec/integration/openid_connect_sso_spec.rb:35:in `block (3 levels) in <top (required)>'
# /usr/share/rvm/gems/ruby-3.1.4@dmp/gems/webmock-3.23.1/lib/webmock/rspec.rb:39:in `block (2 levels) in <top (required)>'
Diagnosis:
The flaky nature of these tests seem to be due to the overriding of OmniAuth.config.mock_auth[:openid_connect] within spec/controllers/omniauth_callbacks_controller_spec.rb:
# Mock OmniAuth data for OpenID Connect with necessary info
OmniAuth.config.mock_auth[:openid_connect] = OmniAuth::AuthHash.new({
provider: 'openid_connect',
uid: '12345',
info: {
email: 'user@organization.ca',
first_name: 'Test',
last_name: 'User',
name: 'Test User'
}
})
# Assign the mocked authentication hash to the request environment
@request.env['omniauth.auth'] = OmniAuth.config.mock_auth[:openid_connect]
The flaky nature of these tests seems to be related to the combination of the re-assignment to OmniAuth.config.mock_auth[:openid_connect] and the random order of that the RSpec tests are executed. That is, if spec/integration/openid_connect_sso_spec.rb is executed before spec/controllers/omniauth_callbacks_controller_spec.rb, then the tests pass. Otherwise, they fail.
Please complete the following fields as applicable:
What version of the DMPRoadmap code are you running? (e.g. v2.2.0)
4.1.1+portage-4.2.2
Expected behaviour:
spec/integration/openid_connect_sso_spec.rb
largely rely onOmniAuth.config.mock_auth[:openid_connect]
, which is defined inspec/spec_helper.rb
.expect(identifiable.firstname).to eql('John')
relies onfirst_name: 'John',
defined inspec/spec_helper.rb
.Actual behaviour:
The aforementioned tests sometimes fail. The following is an example of one such error:
Diagnosis:
The flaky nature of these tests seem to be due to the overriding of
OmniAuth.config.mock_auth[:openid_connect]
withinspec/controllers/omniauth_callbacks_controller_spec.rb
:The flaky nature of these tests seems to be related to the combination of the re-assignment to
OmniAuth.config.mock_auth[:openid_connect]
and the random order of that the RSpec tests are executed. That is, ifspec/integration/openid_connect_sso_spec.rb
is executed beforespec/controllers/omniauth_callbacks_controller_spec.rb
, then the tests pass. Otherwise, they fail.