Merge commit from fork
* Streaming: Ensure disabled users cannot connect to streaming * Streaming: Disconnect when the user is disabled
This commit is contained in:
@@ -382,12 +382,15 @@ RSpec.describe User do
|
||||
|
||||
let(:current_sign_in_at) { Time.zone.now }
|
||||
|
||||
before do
|
||||
user.disable!
|
||||
end
|
||||
|
||||
it 'disables user' do
|
||||
allow(redis).to receive(:publish)
|
||||
|
||||
user.disable!
|
||||
|
||||
expect(user).to have_attributes(disabled: true)
|
||||
|
||||
expect(redis)
|
||||
.to have_received(:publish).with("timeline:system:#{user.account.id}", Oj.dump(event: :kill)).once
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -74,4 +74,28 @@ RSpec.describe 'Streaming', :inline_jobs, :streaming do
|
||||
expect(streaming_client.open?).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a disabled user account' do
|
||||
before do
|
||||
user.disable!
|
||||
end
|
||||
|
||||
it 'receives an 401 unauthorized error when trying to connect' do
|
||||
streaming_client.connect
|
||||
|
||||
expect(streaming_client.status).to eq(401)
|
||||
expect(streaming_client.open?).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the user account is disabled whilst connected' do
|
||||
it 'terminates the connection for the user' do
|
||||
streaming_client.connect
|
||||
|
||||
user.disable!
|
||||
|
||||
expect(streaming_client.wait_for(:closed).code).to be(1000)
|
||||
expect(streaming_client.open?).to be(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user