From fa0e68720f3d5d2169a138b93661501b6631a99c Mon Sep 17 00:00:00 2001 From: "j.lundqvist" Date: Mon, 24 Jun 2024 12:16:14 +0200 Subject: [PATCH] Fix loading current value for nexus user passwords There's two issues solved by this commit: - The API calls to check if the new password works always failed; - The new password was given as the old password value when the call failed, making it impossible to update the password. --- resources/user.rb | 6 +++--- spec/unit/resources/user_spec.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/user.rb b/resources/user.rb index f1d97cc..4e24f32 100644 --- a/resources/user.rb +++ b/resources/user.rb @@ -19,10 +19,10 @@ # Check if we need to change the password. if self.class.properties[:password].is_set?(desired) begin - ::Nexus3::Api.new(api_client.endpoint, username, desired.password).request(:get, '/service/metrics/ping') - password 'Supercalifragilisticexpialidocious-that-does-not-exist-so-maybe-the-resource-will-need-to-converge' - rescue ::Nexus3::ApiError + ::Nexus3::Api.new(api_client.endpoint, username, desired.password).request(:get, '/service/rapture/session') password desired.password + rescue ::Nexus3::ApiError + password 'Supercalifragilisticexpialidocious-that-does-not-exist-so-maybe-the-resource-will-need-to-converge' end end rescue LoadError, ::Nexus3::ApiError => e diff --git a/spec/unit/resources/user_spec.rb b/spec/unit/resources/user_spec.rb index 5c21d50..f7832b7 100644 --- a/spec/unit/resources/user_spec.rb +++ b/spec/unit/resources/user_spec.rb @@ -43,7 +43,7 @@ user_response('user_with_role'), user_response('user_with_role')) - stub_request(:get, 'http://localhost:8081/service/metrics/ping') + stub_request(:get, 'http://localhost:8081/service/rapture/session') .to_return(api_response(200)) end