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 for users messing with the database to ensure only valid tokens are used

Klaus Zandersdbfb7aff0941
diff --git a/spec/models/enterprise_token_spec.rb b/spec/models/enterprise_token_spec.rb
index 8c0cbbcfccc..de398ce5226 100644
--- a/spec/models/enterprise_token_spec.rb
+++ b/spec/models/enterprise_token_spec.rb
@@ -334,6 +334,18 @@ RSpec.describe EnterpriseToken do
expect(described_class.active_tokens).to be_empty
end
end
+
+ context "when the user messed with the database to 'extend' their validity" do
+ let!(:expired_token) { create_enterprise_token("an_active_token", expires_at: 1.day.ago) }
+
+ before do
+ expired_token.update(valid_until: 1.year.from_now)
+ end
+
+ it "returns an empty array" do
+ expect(described_class.active_tokens).to be_empty
+ end
+ end
end
describe ".active" do