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
Do not consider an invalid enterprise token as expired
Christophe Bliard6426f17d8120
diff --git a/app/models/enterprise_token.rb b/app/models/enterprise_token.rbindex eaedf8f0a3a..4d415d98850 100644--- a/app/models/enterprise_token.rb+++ b/app/models/enterprise_token.rb@@ -168,7 +168,7 @@ class EnterpriseToken < ApplicationRecorddelegate :clear_current_tokens_cache, to: :EnterpriseTokendef expired?(reprieve: true)- token_object.expired?(reprieve:) || invalid_domain?+ token_object.expired?(reprieve:)end##diff --git a/app/services/authorization/enterprise_service.rb b/app/services/authorization/enterprise_service.rbindex 0c0d460a848..d06527ec48c 100644--- a/app/services/authorization/enterprise_service.rb+++ b/app/services/authorization/enterprise_service.rb@@ -37,7 +37,7 @@ class Authorization::EnterpriseService# Return a true ServiceResult if the token contains this particular action.def call(feature)- allowed = if token.nil? || token.token_object.nil? || token.expired?+ allowed = if token.nil? || token.token_object.nil? || token.expired? || token.invalid_domain?falseelsetoken.token_object.has_feature?(feature)diff --git a/spec/models/enterprise_token_spec.rb b/spec/models/enterprise_token_spec.rbindex 3d980c2267f..67db86692f9 100644--- a/spec/models/enterprise_token_spec.rb+++ b/spec/models/enterprise_token_spec.rb@@ -567,6 +567,14 @@ RSpec.describe EnterpriseToken doendend+ context "when token is invalid" do+ let(:token) { build_enterprise_token(domain: "wrong.domain") }++ it "is not expired" do+ expect(token).not_to be_expired+ end+ end+context "when token expiration date is in the past" dolet(:token) { build_enterprise_token(expires_at: Date.yesterday) }