OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#54558] openDesk setup script fails
Eric Schubert0a64428b05d9
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_user_token.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_user_token.rbindex 5f5e2943c5e..9c6911fa093 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_user_token.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_user_token.rb@@ -44,7 +44,7 @@ module Storages# rubocop:disable Metrics/AbcSizedef call(storage:, http_options: {}, &)config = storage.oauth_configuration- current_token = OAuthClientToken.find_by(user_id: @user, oauth_client_id: config.oauth_client.id)+ current_token = OAuthClientToken.find_by(user: @user, oauth_client: config.oauth_client)if current_token.nil?data = ::Storages::StorageErrorData.new(source: self.class)return Failures::Builder.call(code: :unauthorized,diff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/authentication_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/authentication_spec.rbindex 4de1a79830f..9f72dd2cde7 100644--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/authentication_spec.rb+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/authentication_spec.rb@@ -32,19 +32,13 @@ require "spec_helper"require_module_spec_helperRSpec.describe Storages::Peripherals::StorageInteraction::Authentication, :webmock do- using Storages::Peripherals::ServiceResultRefinements-let(:user) { create(:user) }shared_examples_for "successful response" do |refreshed: false|it "must #{refreshed ? 'refresh token and ' : ''}return success" doresult = described_class[auth_strategy].call(storage:, http_options:) { |http| make_request(http) }expect(result).to be_success-- result.match(- on_failure: ->(error) { fail "Expected success, got #{error}" },- on_success: ->(r) { expect(r).to eq("EXPECTED_RESULT") }- )+ expect(result.result).to eq("EXPECTED_RESULT")endend@@ -72,13 +66,11 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Authentication, :webmoit "must return error" doresult = described_class[auth_strategy].call(storage:, http_options:) { |http| make_request(http) }expect(result).to be_failure- expect(result.error_source)- .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::BasicAuth)- result.match(- on_failure: ->(error) { expect(error.code).to eq(:error) },- on_success: ->(file_infos) { fail "Expected failure, got #{file_infos}" }- )+ error = result.errors+ expect(error.code).to eq(:error)+ expect(error.data.source)+ .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::BasicAuth)endend@@ -92,12 +84,10 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Authentication, :webmoit "must return unauthorized" doresult = described_class[auth_strategy].call(storage:, http_options:) { |http| make_request(http) }expect(result).to be_failure- expect(result.error_source).to eq("EXECUTING_QUERY")- result.match(- on_failure: ->(error) { expect(error.code).to eq(:unauthorized) },- on_success: ->(file_infos) { fail "Expected failure, got #{file_infos}" }- )+ error = result.errors+ expect(error.code).to eq(:unauthorized)+ expect(error.data.source).to be("EXECUTING_QUERY")endendend@@ -107,6 +97,20 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Authentication, :webmoStorages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken.strategy.with_user(user)end+ context "with incomplete storage configuration (missing oauth client)" do+ let(:storage) { create(:nextcloud_storage) }++ it "must return unauthorized" do+ result = described_class[auth_strategy].call(storage:, http_options:) { |http| make_request(http) }+ expect(result).to be_failure++ error = result.errors+ expect(error.code).to eq(:unauthorized)+ expect(error.data.source)+ .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken)+ end+ end+context "with not existent oauth token" dolet(:user_without_token) { create(:user) }let(:auth_strategy) do@@ -118,13 +122,11 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Authentication, :webmoit "must return unauthorized" doresult = described_class[auth_strategy].call(storage:, http_options:) { |http| make_request(http) }expect(result).to be_failure- expect(result.error_source)- .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken)- result.match(- on_failure: ->(error) { expect(error.code).to eq(:unauthorized) },- on_success: ->(file_infos) { fail "Expected failure, got #{file_infos}" }- )+ error = result.errors+ expect(error.code).to eq(:unauthorized)+ expect(error.data.source)+ .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken)endend@@ -132,13 +134,11 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Authentication, :webmoit "must return unauthorized" doresult = described_class[auth_strategy].call(storage:, http_options:) { |http| make_request(http) }expect(result).to be_failure- expect(result.error_source)- .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken)- result.match(- on_failure: ->(error) { expect(error.code).to eq(:unauthorized) },- on_success: ->(file_infos) { fail "Expected failure, got #{file_infos}" }- )+ error = result.errors+ expect(error.code).to eq(:unauthorized)+ expect(error.data.source)+ .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken)endend@@ -166,13 +166,11 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Authentication, :webmoit "must return unauthorized" doresult = described_class[auth_strategy].call(storage:) { |http| make_request(http) }expect(result).to be_failure- expect(result.error_source)- .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthClientCredentials)- result.match(- on_failure: ->(error) { expect(error.code).to eq(:unauthorized) },- on_success: ->(file_infos) { fail "Expected failure, got #{file_infos}" }- )+ error = result.errors+ expect(error.code).to eq(:unauthorized)+ expect(error.data.source)+ .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthClientCredentials)endend@@ -180,13 +178,11 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Authentication, :webmoit "must return unauthorized" doresult = described_class[auth_strategy].call(storage:) { |http| make_request(http) }expect(result).to be_failure- expect(result.error_source)- .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthClientCredentials)- result.match(- on_failure: ->(error) { expect(error.code).to eq(:unauthorized) },- on_success: ->(file_infos) { fail "Expected failure, got #{file_infos}" }- )+ error = result.errors+ expect(error.code).to eq(:unauthorized)+ expect(error.data.source)+ .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthClientCredentials)endendend@@ -201,6 +197,20 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Authentication, :webmoit_behaves_like "successful response"end+ context "with incomplete storage configuration (missing oauth client)" do+ let(:storage) { create(:one_drive_storage) }++ it "must return unauthorized" do+ result = described_class[auth_strategy].call(storage:) { |http| make_request(http) }+ expect(result).to be_failure++ error = result.errors+ expect(error.code).to eq(:unauthorized)+ expect(error.data.source)+ .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken)+ end+ end+context "with not existent oauth token" dolet(:user_without_token) { create(:user) }let(:auth_strategy) do@@ -212,13 +222,11 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Authentication, :webmoit "must return unauthorized" doresult = described_class[auth_strategy].call(storage:) { |http| make_request(http) }expect(result).to be_failure- expect(result.error_source)- .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken)- result.match(- on_failure: ->(error) { expect(error.code).to eq(:unauthorized) },- on_success: ->(file_infos) { fail "Expected failure, got #{file_infos}" }- )+ error = result.errors+ expect(error.code).to eq(:unauthorized)+ expect(error.data.source)+ .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken)endend@@ -226,13 +234,11 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Authentication, :webmoit "must return unauthorized" doresult = described_class[auth_strategy].call(storage:) { |http| make_request(http) }expect(result).to be_failure- expect(result.error_source)- .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken)- result.match(- on_failure: ->(error) { expect(error.code).to eq(:unauthorized) },- on_success: ->(file_infos) { fail "Expected failure, got #{file_infos}" }- )+ error = result.errors+ expect(error.code).to eq(:unauthorized)+ expect(error.data.source)+ .to be(Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken)endend