Skip to content

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

Add a test to the discard of the cached token

Marcello Rocha8397b3f2883f
diff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_client_credentials_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_client_credentials_spec.rb
similarity index 90%
rename from modules/storages/spec/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_client_credentials_spec.rb
rename to modules/storages/spec/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_client_credentials_spec.rb
index 070d6669811..eb18533212f 100644
--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_client_credentials_spec.rb
+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_client_credentials_spec.rb
@@ -67,6 +67,18 @@ RSpec.describe Storages::Peripherals::StorageInteraction::AuthenticationStrategi
expect(result).to be_failure
expect(result.result).to eq("It failed")
end
+
+ it "clears an already existing token" do
+ Rails.cache.write("storage.#{storage.id}.httpx_access_token", "BORKED_TOKEN")
+
+ strategy.call(storage:) do |http|
+ http.get("https://graph.microsoft.com/v1.0/drives/#{storage.drive_id}/root").raise_for_status
+ rescue HTTPX::Error
+ ServiceResult.failure(result: :forbidden)
+ end
+
+ expect(Rails.cache.fetch("storage.#{storage.id}.httpx_access_token")).to be_nil
+ end
end
context "when the attempted request works" do