Skip to content

Commit

Permalink
Adjust keycloak_require_action test to not reference removed alias at…
Browse files Browse the repository at this point in the history
…tribute
  • Loading branch information
TuningYourCode committed Sep 26, 2024
1 parent aa59cf0 commit f6b26c4
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions spec/unit/puppet/provider/keycloak_required_action/kcadm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@

describe 'destroy' do
it 'deregisters a required action' do

Check failure on line 51 in spec/unit/puppet/provider/keycloak_required_action/kcadm_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 8 (Ruby 3.2.3 fixtures=.fixtures.yml)

Puppet::Type::Keycloak_required_action::ProviderKcadm destroy deregisters a required action Failure/Error: resource.provider.instance_variable_set(:@property_hash) ArgumentError: wrong number of arguments (given 1, expected 2)

Check failure on line 51 in spec/unit/puppet/provider/keycloak_required_action/kcadm_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 8 (Ruby 3.2.2 fixtures=.fixtures-latest.yml)

Puppet::Type::Keycloak_required_action::ProviderKcadm destroy deregisters a required action Failure/Error: resource.provider.instance_variable_set(:@property_hash) ArgumentError: wrong number of arguments (given 1, expected 2)

Check failure on line 51 in spec/unit/puppet/provider/keycloak_required_action/kcadm_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 7 (Ruby 2.7.7 fixtures=.fixtures-latest.yml)

Puppet::Type::Keycloak_required_action::ProviderKcadm destroy deregisters a required action Failure/Error: resource.provider.instance_variable_set(:@property_hash) ArgumentError: wrong number of arguments (given 1, expected 2)

Check failure on line 51 in spec/unit/puppet/provider/keycloak_required_action/kcadm_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 7 (Ruby 2.7.8 fixtures=.fixtures.yml)

Puppet::Type::Keycloak_required_action::ProviderKcadm destroy deregisters a required action Failure/Error: resource.provider.instance_variable_set(:@property_hash) ArgumentError: wrong number of arguments (given 1, expected 2)
# 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

Expand All @@ -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
Expand All @@ -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

Check failure on line 85 in spec/unit/puppet/provider/keycloak_required_action/kcadm_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 8 (Ruby 3.2.3 fixtures=.fixtures.yml)

Puppet::Type::Keycloak_required_action::ProviderKcadm flush uses display_name from current state if none specified explicitly Failure/Error: kcadm('update', "authentication/required-actions/#{@property_hash[:provider_id]}", resource[:realm], t.path) Keycloak_required_action[foo](provider=kcadm) received :kcadm with unexpected arguments expected: ("update", "authentication/required-actions/webauthn-register", "test", "/tmp/keycloak_required_action_configure20240926-1969-3dvqrc") got: ("update", "authentication/required-actions/", "test", "/tmp/keycloak_required_action_configure20240926-1969-3dvqrc")

Check failure on line 85 in spec/unit/puppet/provider/keycloak_required_action/kcadm_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 8 (Ruby 3.2.2 fixtures=.fixtures-latest.yml)

Puppet::Type::Keycloak_required_action::ProviderKcadm flush uses display_name from current state if none specified explicitly Failure/Error: kcadm('update', "authentication/required-actions/#{@property_hash[:provider_id]}", resource[:realm], t.path) Keycloak_required_action[foo](provider=kcadm) received :kcadm with unexpected arguments expected: ("update", "authentication/required-actions/webauthn-register", "test", "/tmp/keycloak_required_action_configure20240926-2051-ag1lxd") got: ("update", "authentication/required-actions/", "test", "/tmp/keycloak_required_action_configure20240926-2051-ag1lxd")

Check failure on line 85 in spec/unit/puppet/provider/keycloak_required_action/kcadm_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 7 (Ruby 2.7.7 fixtures=.fixtures-latest.yml)

Puppet::Type::Keycloak_required_action::ProviderKcadm flush uses display_name from current state if none specified explicitly Failure/Error: kcadm('update', "authentication/required-actions/#{@property_hash[:provider_id]}", resource[:realm], t.path) Keycloak_required_action[foo](provider=kcadm) received :kcadm with unexpected arguments expected: ("update", "authentication/required-actions/webauthn-register", "test", "/tmp/keycloak_required_action_configure20240926-2054-1kkyo4t") got: ("update", "authentication/required-actions/", "test", "/tmp/keycloak_required_action_configure20240926-2054-1kkyo4t")

Check failure on line 85 in spec/unit/puppet/provider/keycloak_required_action/kcadm_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 7 (Ruby 2.7.8 fixtures=.fixtures.yml)

Puppet::Type::Keycloak_required_action::ProviderKcadm flush uses display_name from current state if none specified explicitly Failure/Error: kcadm('update', "authentication/required-actions/#{@property_hash[:provider_id]}", resource[:realm], t.path) Keycloak_required_action[foo](provider=kcadm) received :kcadm with unexpected arguments expected: ("update", "authentication/required-actions/webauthn-register", "test", "/tmp/keycloak_required_action_configure20240926-1973-xhvfqr") got: ("update", "authentication/required-actions/", "test", "/tmp/keycloak_required_action_configure20240926-1973-xhvfqr")
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
Expand All @@ -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
Expand All @@ -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

0 comments on commit f6b26c4

Please sign in to comment.