Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into quinteros
Browse files Browse the repository at this point in the history
  • Loading branch information
Fryguy committed Dec 7, 2023
2 parents 04fdd2d + 9d874ff commit 4ce5563
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@
end

it 'loads object from yaml' do
expect(YAML.safe_load(svc_service.to_yaml, [MiqAeMethodService::MiqAeServiceService])).to eq(svc_service)
expect(YAML.safe_load(svc_service.to_yaml, :permitted_classes => [MiqAeMethodService::MiqAeServiceService])).to eq(svc_service)
end

it 'loads invalid svc_model for objects without related ar_model' do
yaml = svc_service.to_yaml
service.delete
model_from_yaml = YAML.safe_load(yaml, [MiqAeMethodService::MiqAeServiceService])
model_from_yaml = YAML.safe_load(yaml, :permitted_classes => [MiqAeMethodService::MiqAeServiceService])
expect(model_from_yaml.class).to eq(svc_service.class)
expect(model_from_yaml.record_exists?).to eq(false)
end
Expand Down
3 changes: 2 additions & 1 deletion spec/engine/miq_ae_state_machine_retry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def create_restart_model(script1, script2, script3)
end

it "check persistent hash" do
ActiveRecord::Base.yaml_column_permitted_classes << "MiqAeEngine::StateVarHash"
setup_model(method_script_state_var)
expected = MiqAeEngine::StateVarHash.new('three' => 3, 'one' => 1, 'two' => 2, 'gravy' => 'train')
send_ae_request_via_queue(@automate_args)
Expand Down Expand Up @@ -280,6 +281,6 @@ def create_restart_model(script1, script2, script3)
expect(MiqQueue.count).to eq(2)
q = MiqQueue.where(:state => 'ready').first
expect(q[:server_guid]).to be_nil
expect(YAML.safe_load(q.args.first[:ae_state_data], [MiqAeEngine::StateVarHash])).to eq(ae_state_data)
expect(YAML.safe_load(q.args.first[:ae_state_data], :permitted_classes => [MiqAeEngine::StateVarHash])).to eq(ae_state_data)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
it 'should return an empty hash struct without calling BinaryBlob find' do
expect(BinaryBlob).to_not receive(:find_by)

new_start_var_hash = YAML.safe_load(blank_yaml_string, [MiqAeEngine::StateVarHash])
new_start_var_hash = YAML.safe_load(blank_yaml_string, :permitted_classes => [MiqAeEngine::StateVarHash])

expect(new_start_var_hash).to be_a(MiqAeEngine::StateVarHash)
expect(new_start_var_hash).to be_blank
Expand All @@ -33,15 +33,15 @@
yaml_out = YAML.dump(state_var_hash)
expect(BinaryBlob.count).to be(1)

YAML.safe_load(yaml_out, [MiqAeEngine::StateVarHash])
YAML.safe_load(yaml_out, :permitted_classes => [MiqAeEngine::StateVarHash])
expect(BinaryBlob.count).to be_zero
end

it 'should create a new copy of the original hash object when reloaded' do
expect($miq_ae_logger).to receive(:info).with(/Reloading state var data/).and_call_original
expect($miq_ae_logger).to receive(:info).with(/\n---/).and_call_original

new_start_var_hash = YAML.safe_load(YAML.dump(state_var_hash), [MiqAeEngine::StateVarHash])
new_start_var_hash = YAML.safe_load(YAML.dump(state_var_hash), :permitted_classes => [MiqAeEngine::StateVarHash])

expect(new_start_var_hash).to eq(state_var_hash)
expect(new_start_var_hash.object_id).to_not eq(start_var_hash.object_id)
Expand All @@ -53,7 +53,7 @@
expect($miq_ae_logger).to receive(:info).with(/Reloading state var data/).and_call_original
expect($miq_ae_logger).to receive(:info).with(/\n---\nusername: foo\npassword: \[FILTERED\]/).and_call_original

new_start_var_hash = YAML.safe_load(YAML.dump(svh_with_user_pass), [MiqAeEngine::StateVarHash])
new_start_var_hash = YAML.safe_load(YAML.dump(svh_with_user_pass), :permitted_classes => [MiqAeEngine::StateVarHash])

expect(new_start_var_hash).to eq(svh_with_user_pass)
expect(new_start_var_hash.object_id).to_not eq(svh_with_user_pass.object_id)
Expand All @@ -65,7 +65,7 @@

expect($miq_ae_logger).to receive(:warn).with(/Failed to load BinaryBlob with ID/).and_call_original

restored_state_var = YAML.safe_load(yaml_out, [MiqAeEngine::StateVarHash])
restored_state_var = YAML.safe_load(yaml_out, :permitted_classes => [MiqAeEngine::StateVarHash])
expect(restored_state_var).to eq({})
end
end
Expand Down

0 comments on commit 4ce5563

Please sign in to comment.