From f6b26c439e3a7a4bb4f945d7a1a7288fceeef04b Mon Sep 17 00:00:00 2001 From: Stephan Eicher Date: Thu, 26 Sep 2024 10:46:32 +0200 Subject: [PATCH] Adjust keycloak_require_action test to not reference removed alias attribute --- .../keycloak_required_action/kcadm_spec.rb | 27 +++++-------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/spec/unit/puppet/provider/keycloak_required_action/kcadm_spec.rb b/spec/unit/puppet/provider/keycloak_required_action/kcadm_spec.rb index 5a672363..3c33f94d 100644 --- a/spec/unit/puppet/provider/keycloak_required_action/kcadm_spec.rb +++ b/spec/unit/puppet/provider/keycloak_required_action/kcadm_spec.rb @@ -49,11 +49,9 @@ describe 'destroy' do it 'deregisters a required action' do - # It suppoed to use whatever came from api and was matched by provider id - # But not what developer provided - resource.provider.instance_variable_set(:@property_hash, alias: 'otheralias') + resource.provider.instance_variable_set(:@property_hash) - expect(resource.provider).to receive(:kcadm).with('delete', 'authentication/required-actions/otheralias', 'test') + expect(resource.provider).to receive(:kcadm).with('delete', 'authentication/required-actions/webauthn-register', 'test') resource.provider.destroy @@ -76,7 +74,7 @@ temp = Tempfile.new('keycloak_required_action_configure') allow(Tempfile).to receive(:new).with('keycloak_required_action_configure').and_return(temp) - expect(resource.provider).to receive(:kcadm).with('update', 'authentication/required-actions/somealias', 'test', temp.path) + expect(resource.provider).to receive(:kcadm).with('update', 'authentication/required-actions/webauthn-register', 'test', temp.path) resource.provider.display_name = 'something' resource.provider.flush @@ -85,11 +83,11 @@ # If developer does not specify the display name, the api would use the name # that is initially returned from unregistered-required-actions it 'uses display_name from current state if none specified explicitly' do - resource.provider.instance_variable_set(:@property_hash, display_name: 'display name', alias: 'somealias') + resource.provider.instance_variable_set(:@property_hash, display_name: 'display name') temp = Tempfile.new('keycloak_required_action_configure') allow(Tempfile).to receive(:new).with('keycloak_required_action_configure').and_return(temp) - expect(resource.provider).to receive(:kcadm).with('update', 'authentication/required-actions/somealias', 'test', temp.path) + expect(resource.provider).to receive(:kcadm).with('update', 'authentication/required-actions/webauthn-register', 'test', temp.path) resource.provider.priority = 1000 resource.provider.flush @@ -105,7 +103,7 @@ temp = Tempfile.new('keycloak_required_action_configure') allow(Tempfile).to receive(:new).with('keycloak_required_action_configure').and_return(temp) - expect(resource.provider).to receive(:kcadm).with('update', 'authentication/required-actions/somealias', 'test', temp.path) + expect(resource.provider).to receive(:kcadm).with('update', 'authentication/required-actions/webauthn-register', 'test', temp.path) resource.provider.priority = 200 resource.provider.flush @@ -114,18 +112,5 @@ json = JSON.parse(data) expect(json['name']).to eq('something') end - - it 'always uses alias from the current state to make edits' do - resource[:display_name] = 'newalias' - resource.provider.instance_variable_set(:@property_hash, alias: 'current') - - temp = Tempfile.new('keycloak_required_action_configure') - allow(Tempfile).to receive(:new).with('keycloak_required_action_configure').and_return(temp) - - expect(resource.provider).to receive(:kcadm).with('update', 'authentication/required-actions/current', 'test', temp.path) - - resource.provider.priority = 200 - resource.provider.flush - end end end