mastodon/spec/helpers/self_destruct_helper_spec.rb
Matt Jankowski c0c34d35e2
Some checks failed
Bundler Audit / security (push) Waiting to run
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Haml Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
CSS Linting / lint (push) Has been cancelled
Move self destruct check to config_for and add constant for verifier string (#32943)
2024-11-18 09:57:16 +00:00

75 lines
2.1 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe SelfDestructHelper do
describe '#self_destruct?' do
before { Rails.configuration.x.mastodon.self_destruct_value = destruct_value }
after { Rails.configuration.x.mastodon.self_destruct_value = nil }
context 'when SELF_DESTRUCT is unset' do
let(:destruct_value) { nil }
it 'returns false' do
expect(helper.self_destruct?).to be false
end
end
context 'when SELF_DESTRUCT is set to an invalid value' do
let(:destruct_value) { 'true' }
it 'returns false' do
expect(helper.self_destruct?).to be false
end
end
context 'when SELF_DESTRUCT is set to value signed for the wrong purpose' do
let(:destruct_value) { Rails.configuration.x.mastodon.self_destruct_value = Rails.application.message_verifier('foo').generate('example.com') }
around do |example|
ClimateControl.modify(
LOCAL_DOMAIN: 'example.com'
) do
example.run
end
end
it 'returns false' do
expect(helper.self_destruct?).to be false
end
end
context 'when SELF_DESTRUCT is set to value signed for the wrong domain' do
let(:destruct_value) { Rails.configuration.x.mastodon.self_destruct_value = Rails.application.message_verifier(described_class::VERIFY_PURPOSE).generate('foo.com') }
around do |example|
ClimateControl.modify(
LOCAL_DOMAIN: 'example.com'
) do
example.run
end
end
it 'returns false' do
expect(helper.self_destruct?).to be false
end
end
context 'when SELF_DESTRUCT is set to a correctly-signed value' do
let(:destruct_value) { Rails.configuration.x.mastodon.self_destruct_value = Rails.application.message_verifier(described_class::VERIFY_PURPOSE).generate('example.com') }
around do |example|
ClimateControl.modify(
LOCAL_DOMAIN: 'example.com'
) do
example.run
end
end
it 'returns true' do
expect(helper.self_destruct?).to be true
end
end
end
end