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 scramsha migration test failures on rails 7.1 #768

Open
jrafanie opened this issue Nov 15, 2024 · 1 comment · May be fixed by #776
Open

Fix scramsha migration test failures on rails 7.1 #768

jrafanie opened this issue Nov 15, 2024 · 1 comment · May be fixed by #776
Assignees

Comments

@jrafanie
Copy link
Member

jrafanie commented Nov 15, 2024

From #767
Seen in #766

1) ReencryptPasswordScramsha#up Ensures that the user password is stored as scram-sha-256
     Failure/Error: expect(ActiveRecord::Base.connection_db_config).to receive(:configuration_hash).exactly(10).times.and_call_original

       (#<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007f4cdb38ad18 @env_name="test", @name="primary", @configuration_hash={:adapter=>"postgresql", :encoding=>"utf8", :username=>"root", :***"smartvm", :pool=>3, :wait_timeout=>5, :min_messages=>"warning", :database=>"dummy_test"}>).configuration_hash(*(any args))
           expected: 10 times with any arguments
           received: 1 time with any arguments
     # ./spec/migrations/20241017013023_reencrypt_password_scramsha_spec.rb:12:in `block (3 levels) in <top (required)>'
     # ./spec/support/migration_helper.rb:77:in `clearing_caches'
     # ./spec/support/migration_helper.rb:13:in `block (2 levels) in migration_context'

  2) ReencryptPasswordScramsha#up Handles connections with no password
     Failure/Error: super

       (#<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0x00007f4cda51acb0 @transaction_manager=#<ActiveRecord::ConnectionAdapters::TransactionManager:0x00007f4cda920a80 @stack=[#<ActiveRecord::ConnectionAdapters::RealTransaction:0x00007f4cd3e9c[47](https://github.com/ManageIQ/manageiq-schema/actions/runs/11858845607/job/33050405714?pr=766#step:6:48)0 @connection=#<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0x00007f4cda51acb0 ...>, @state=#<ActiveRecord::ConnectionAdapters::TransactionState:0x00007f4cd3e9c420 @state=nil, @children=[#<ActiveRecord::ConnectionAdapters::TransactionState:0x00007f4cd395a930 @state=nil, @children=nil>]>, @records=nil, @isolation_level=nil, @materialized=true, @joinable=false, @run_commit_callbacks=true, @lazy_enrollment_records=nil, @dirty=true, @instrumenter=#<ActiveRecord::ConnectionAdapters::TransactionInstrumenter:0x00007f4cd3e9c290 @handle=#<ActiveSupport::Notifications::Fanout::Handle:0x00007f4cd3ea1718 @name="transaction.active_record", @id="4321fe7d6758014edd25", @payload={:connection=>#<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0x00007f4cda[51](https://github.com/ManageIQ/manageiq-schema/actions/runs/11858845607/job/33050405714?pr=766#step:6:52)acb0 ...>}, @groups=[],
@Fryguy
Copy link
Member

Fryguy commented Nov 15, 2024

cc @bdunne

jrafanie added a commit to jrafanie/manageiq-schema that referenced this issue Dec 12, 2024
In rails 7.0, it's called 10 times plus 1 more on the next line.  In rails 7.1+,
it's called only once.  From a test perspective, we don't care if it's even called.
We only care that the SQL query is executed with the scramsha password or not.

With this, I believe we can expect test success on rails 7.1 and 7.2.

It was added in 742841c but I think this change
emphasizes what we really care about testing and removes an assertion on internals
that we don't really have interest in testing.

Fixes ManageIQ#768
jrafanie added a commit to jrafanie/manageiq-schema that referenced this issue Dec 12, 2024
In rails 7.0, it's called 10 times plus 1 more on the next line.  In rails 7.1+,
it's called only once.  From a test perspective, we don't care if it's even called.
We only care that the SQL query is executed with the scramsha password or not.

To change the username/password only in calls from the migration itself and not from
rails, we hack around the caller_locations to make the change only for the migration callers

With this, I believe we can expect test success on rails 7.1 and 7.2.

It was added in 742841c but I think this change
emphasizes what we really care about testing and removes an assertion on internals
that we don't really have interest in testing.

Fixes ManageIQ#768
jrafanie added a commit to jrafanie/manageiq-schema that referenced this issue Dec 12, 2024
In rails 7.0, it's called 10 times plus 1 more on the next line.  In rails 7.1+,
it's called only once.  From a test perspective, we don't care if it's even called.
We only care that the SQL query is executed with the scramsha password or not.

To change the username/password only in calls from the migration itself and not from
rails, we hack around the caller_locations to make the change only for the migration callers.

With this, I believe we can expect test success on rails 7.1 and 7.2.

It was added in 742841c but I think this change
emphasizes what we really care about testing and removes an assertion on internals
that we don't really have interest in testing.

Fixes ManageIQ#768
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants