monitoring_spec.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Monitoring', type: :request do
  4. let(:token) { Setting.get('monitoring_token') }
  5. describe 'Health check API not working when logged in as non-admin #5029' do
  6. let(:admin) { create(:admin) }
  7. let(:customer) { create(:customer) }
  8. context 'when admin', authenticated_as: :admin do
  9. it 'does return results via token' do
  10. get "/api/v1/monitoring/health_check?token=#{token}", as: :json
  11. expect(response).to have_http_status(:ok)
  12. end
  13. it 'does return results without token' do
  14. get '/api/v1/monitoring/health_check', as: :json
  15. expect(response).to have_http_status(:ok)
  16. end
  17. end
  18. context 'when customer', authenticated_as: :customer do
  19. it 'does return results via token' do
  20. get "/api/v1/monitoring/health_check?token=#{token}", as: :json
  21. expect(response).to have_http_status(:ok)
  22. end
  23. it 'does not return results without token' do
  24. get '/api/v1/monitoring/health_check', as: :json
  25. expect(response).to have_http_status(:forbidden)
  26. end
  27. end
  28. end
  29. end