list_spec.rb 949 B

123456789101112131415161718192021222324252627282930313233
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Service::User::AccessToken::List do
  4. let(:user) { create(:user) }
  5. let(:token) { create(:token, user: user) }
  6. let(:token_second) { create(:token, user: user) }
  7. let(:token_non_persistent) { create(:token, user: user, persistent: false) }
  8. let(:token_non_api) { create(:token, user: user, action: :nonapi) }
  9. let(:token_another_user) { create(:token) }
  10. before do
  11. token
  12. token_second
  13. token_non_persistent
  14. token_non_api
  15. token_another_user
  16. end
  17. it 'returns persistent api tokens owned by given user' do
  18. result = described_class.new(user).execute
  19. expect(result).to contain_exactly(token, token_second)
  20. end
  21. it 'does not include sensitive columns' do
  22. result = described_class.new(user).execute
  23. expect(result.first).not_to respond_to(:token)
  24. end
  25. end