diff --git a/resources/user.rb b/resources/user.rb index f1d97cc..d374952 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, 'status') 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..2f51779 100644 --- a/spec/unit/resources/user_spec.rb +++ b/spec/unit/resources/user_spec.rb @@ -43,8 +43,11 @@ user_response('user_with_role'), user_response('user_with_role')) - stub_request(:get, 'http://localhost:8081/service/metrics/ping') - .to_return(api_response(200)) + stub_request(:get, 'http://localhost:8081/service/rest/v1/status') + .to_return(api_response(200)) # Nominal case + stub_request(:get, 'http://localhost:8081/service/rest/v1/status') + .with(basic_auth: %w[test-with-pass newpassword]) + .to_return(api_response(401)) # When password is changed end it 'creates a user' do