You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
5.8 KiB

Spelling (#17705) * spelling: account Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: affiliated Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: appearance Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: autosuggest Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: cacheable Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: component Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: conversations Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: domain.example Clarify what's distinct and use RFC friendly domain space. Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: environment Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: exceeds Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: functional Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: inefficiency Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: not Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: notifications Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: occurring Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: position Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: progress Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: promotable Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: reblogging Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: repetitive Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: resolve Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: saturated Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: similar Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: strategies Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: success Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: targeting Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: thumbnails Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: unauthorized Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: unsensitizes Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: validations Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: various Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2 years ago
Spelling (#17705) * spelling: account Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: affiliated Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: appearance Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: autosuggest Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: cacheable Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: component Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: conversations Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: domain.example Clarify what's distinct and use RFC friendly domain space. Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: environment Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: exceeds Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: functional Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: inefficiency Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: not Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: notifications Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: occurring Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: position Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: progress Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: promotable Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: reblogging Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: repetitive Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: resolve Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: saturated Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: similar Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: strategies Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: success Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: targeting Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: thumbnails Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: unauthorized Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: unsensitizes Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: validations Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: various Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2 years ago
Spelling (#17705) * spelling: account Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: affiliated Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: appearance Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: autosuggest Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: cacheable Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: component Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: conversations Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: domain.example Clarify what's distinct and use RFC friendly domain space. Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: environment Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: exceeds Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: functional Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: inefficiency Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: not Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: notifications Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: occurring Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: position Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: progress Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: promotable Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: reblogging Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: repetitive Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: resolve Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: saturated Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: similar Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: strategies Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: success Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: targeting Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: thumbnails Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: unauthorized Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: unsensitizes Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: validations Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: various Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2 years ago
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe ActivityPub::CollectionsController, type: :controller do
  4. let!(:account) { Fabricate(:account) }
  5. let!(:private_pinned) { Fabricate(:status, account: account, text: 'secret private stuff', visibility: :private) }
  6. let(:remote_account) { nil }
  7. shared_examples 'cacheable response' do
  8. it 'does not set cookies' do
  9. expect(response.cookies).to be_empty
  10. expect(response.headers['Set-Cookies']).to be nil
  11. end
  12. it 'does not set sessions' do
  13. response
  14. expect(session).to be_empty
  15. end
  16. it 'returns public Cache-Control header' do
  17. expect(response.headers['Cache-Control']).to include 'public'
  18. end
  19. end
  20. before do
  21. allow(controller).to receive(:signed_request_account).and_return(remote_account)
  22. Fabricate(:status_pin, account: account)
  23. Fabricate(:status_pin, account: account)
  24. Fabricate(:status_pin, account: account, status: private_pinned)
  25. Fabricate(:status, account: account, visibility: :private)
  26. end
  27. describe 'GET #show' do
  28. context 'when id is "featured"' do
  29. context 'without signature' do
  30. let(:remote_account) { nil }
  31. subject(:response) { get :show, params: { id: 'featured', account_username: account.username } }
  32. subject(:body) { body_as_json }
  33. it 'returns http success' do
  34. expect(response).to have_http_status(200)
  35. end
  36. it 'returns application/activity+json' do
  37. expect(response.media_type).to eq 'application/activity+json'
  38. end
  39. it_behaves_like 'cacheable response'
  40. it 'returns orderedItems with pinned statuses' do
  41. expect(body[:orderedItems]).to be_an Array
  42. expect(body[:orderedItems].size).to eq 3
  43. end
  44. it 'includes URI of private pinned status' do
  45. expect(body[:orderedItems]).to include(ActivityPub::TagManager.instance.uri_for(private_pinned))
  46. end
  47. it 'does not include contents of private pinned status' do
  48. expect(response.body).not_to include(private_pinned.text)
  49. end
  50. context 'when account is permanently suspended' do
  51. before do
  52. account.suspend!
  53. account.deletion_request.destroy
  54. end
  55. it 'returns http gone' do
  56. expect(response).to have_http_status(410)
  57. end
  58. end
  59. context 'when account is temporarily suspended' do
  60. before do
  61. account.suspend!
  62. end
  63. it 'returns http forbidden' do
  64. expect(response).to have_http_status(403)
  65. end
  66. end
  67. end
  68. context 'with signature' do
  69. let(:remote_account) { Fabricate(:account, domain: 'example.com') }
  70. context do
  71. before do
  72. get :show, params: { id: 'featured', account_username: account.username }
  73. end
  74. it 'returns http success' do
  75. expect(response).to have_http_status(200)
  76. end
  77. it 'returns application/activity+json' do
  78. expect(response.media_type).to eq 'application/activity+json'
  79. end
  80. it_behaves_like 'cacheable response'
  81. it 'returns orderedItems with pinned statuses' do
  82. json = body_as_json
  83. expect(json[:orderedItems]).to be_an Array
  84. expect(json[:orderedItems].size).to eq 3
  85. end
  86. it 'includes URI of private pinned status' do
  87. json = body_as_json
  88. expect(json[:orderedItems]).to include(ActivityPub::TagManager.instance.uri_for(private_pinned))
  89. end
  90. it 'does not include contents of private pinned status' do
  91. expect(response.body).not_to include(private_pinned.text)
  92. end
  93. end
  94. context 'in authorized fetch mode' do
  95. before do
  96. allow(controller).to receive(:authorized_fetch_mode?).and_return(true)
  97. end
  98. context 'when signed request account is blocked' do
  99. before do
  100. account.block!(remote_account)
  101. get :show, params: { id: 'featured', account_username: account.username }
  102. end
  103. it 'returns http success' do
  104. expect(response).to have_http_status(200)
  105. end
  106. it 'returns application/activity+json' do
  107. expect(response.media_type).to eq 'application/activity+json'
  108. end
  109. it 'returns private Cache-Control header' do
  110. expect(response.headers['Cache-Control']).to include 'private'
  111. end
  112. it 'returns empty orderedItems' do
  113. json = body_as_json
  114. expect(json[:orderedItems]).to be_an Array
  115. expect(json[:orderedItems].size).to eq 0
  116. end
  117. end
  118. context 'when signed request account is domain blocked' do
  119. before do
  120. account.block_domain!(remote_account.domain)
  121. get :show, params: { id: 'featured', account_username: account.username }
  122. end
  123. it 'returns http success' do
  124. expect(response).to have_http_status(200)
  125. end
  126. it 'returns application/activity+json' do
  127. expect(response.media_type).to eq 'application/activity+json'
  128. end
  129. it 'returns private Cache-Control header' do
  130. expect(response.headers['Cache-Control']).to include 'private'
  131. end
  132. it 'returns empty orderedItems' do
  133. json = body_as_json
  134. expect(json[:orderedItems]).to be_an Array
  135. expect(json[:orderedItems].size).to eq 0
  136. end
  137. end
  138. end
  139. end
  140. end
  141. context 'when id is not "featured"' do
  142. it 'returns http not found' do
  143. get :show, params: { id: 'hoge', account_username: account.username }
  144. expect(response).to have_http_status(404)
  145. end
  146. end
  147. end
  148. end