required_attributes_spec.rb 930 B

1234567891011121314151617181920212223242526
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Setting::Validation::Saml::RequiredAttributes do
  4. let(:setting_name) { 'auth_saml_credentials' }
  5. context 'with blank settings' do
  6. it 'does not raise an error' do
  7. expect { Setting.set(setting_name, {}) }.not_to raise_error
  8. end
  9. end
  10. context 'when changing only display_name' do
  11. it 'does not raise an error' do
  12. expect { Setting.set(setting_name, { display_name: 'Keycloak' }) }.not_to raise_error
  13. end
  14. end
  15. context 'with missing required settings' do
  16. it 'raises an error' do
  17. expect { Setting.set(setting_name, { display_name: 'Keycloak', security: 'on' }) }.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: One of the required attributes 'idp_sso_target_url', 'idp_slo_service_url', 'idp_cert', 'name_identifier_format' is missing.")
  18. end
  19. end
  20. end