chore: Rotate pubsub token on password change (#7194)

Fixes: https://linear.app/chatwoot/issue/CW-1350/
This commit is contained in:
Sojan Jose
2023-05-27 13:24:31 +05:30
committed by GitHub
parent 1d0930ef63
commit afc97faa8b
2 changed files with 26 additions and 0 deletions

View File

@@ -34,6 +34,22 @@ RSpec.describe User do
it { expect(user.pubsub_token).not_to be_nil }
it { expect(user.saved_changes.keys).not_to eq('pubsub_token') }
context 'rotates the pubsub_token' do
it 'changes the pubsub_token when password changes' do
pubsub_token = user.pubsub_token
user.password = Faker::Internet.password(special_characters: true)
user.save!
expect(user.pubsub_token).not_to eq(pubsub_token)
end
it 'will not change pubsub_token when other attributes change' do
pubsub_token = user.pubsub_token
user.name = Faker::Name.name
user.save!
expect(user.pubsub_token).to eq(pubsub_token)
end
end
end
describe 'hmac_identifier' do