credentials_controller_spec.rb 992 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. require 'rails_helper'
  2. describe Api::V1::Apps::CredentialsController do
  3. render_views
  4. let(:token) { Fabricate(:accessible_access_token, scopes: 'read', application: Fabricate(:application)) }
  5. context 'with an oauth token' do
  6. before do
  7. allow(controller).to receive(:doorkeeper_token) { token }
  8. end
  9. describe 'GET #show' do
  10. before do
  11. get :show
  12. end
  13. it 'returns http success' do
  14. expect(response).to have_http_status(200)
  15. end
  16. it 'does not contain client credentials' do
  17. json = body_as_json
  18. expect(json).to_not have_key(:client_secret)
  19. expect(json).to_not have_key(:client_id)
  20. end
  21. end
  22. end
  23. context 'without an oauth token' do
  24. before do
  25. allow(controller).to receive(:doorkeeper_token) { nil }
  26. end
  27. describe 'GET #show' do
  28. it 'returns http unauthorized' do
  29. get :show
  30. expect(response).to have_http_status(:unauthorized)
  31. end
  32. end
  33. end
  34. end