Skip to content

Commit

Permalink
Fixes #5178 - Mail::AddressList can not parse error when S/MIME or PG…
Browse files Browse the repository at this point in the history
…P integration is active
  • Loading branch information
zammad-sync committed May 24, 2024
1 parent 125152c commit bf20565
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 25 deletions.
16 changes: 12 additions & 4 deletions app/assets/javascripts/app/controllers/agent_ticket_create.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,18 @@ class App.TicketCreate extends App.Controller
# to replace in text modules properly
params.customer = App.User.find(params.customer_id) || {}

# show selected user display name in customer attribute in UI
if _.isEmpty(@el.find('input[name=customer_id_completion]').val())
if params.customer && params.customer.displayName
@el.find('input[name=customer_id_completion]').val(params.customer.displayName())
# if customer is given in params (e. g. from CTI integration) show selected customer
# display name with email address (if exists) in customer attribute in UI
fillCompletionIfRequiredCallback = =>
return if !_.isEmpty(@el.find('input[name=customer_id_completion]').val())
return if !params.customer
return if !params.customer.displayName
completion = params.customer.displayName()
if params.customer.email
completion = App.Utils.buildEmailAddress(params.customer.displayName(), params.customer.email)
return if !completion
@el.find('input[name=customer_id_completion]').val(completion)
@delay(fillCompletionIfRequiredCallback, 10)

@sidebarWidget.render(params)
@textModule.reload(
Expand Down
1 change: 1 addition & 0 deletions spec/system/cti_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def authenticate
expect(page).to have_css('input[name="title"][value="Call from 0190333"]', visible: :all)
expect(page).to have_css('.tabsSidebar-tab[data-tab="customer"]', visible: :all)
expect(page).to have_css("input[name=customer_id][value='#{customer.id}']", visible: :hide)
expect(find('[name=customer_id_completion]').value).to eq "#{customer.fullname} <#{customer.email}>"
end
end
end
Expand Down
67 changes: 46 additions & 21 deletions spec/system/ticket/create/secure_mailing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,38 +374,63 @@ def authenticate
create(:smime_certificate, fixture: recipient_email_address)
end

it_behaves_like 'showing security type switcher'
shared_examples 'switching between security types' do
it 'switches between security types' do
within(:active_content) do

it 'switches between security types' do
visit 'ticket/create'
click '.btn', text: 'PGP'

within(:active_content) do
use_template(template)
# Wait until the security options check AJAX call is ready.
expect(page).to have_css('div.js-securityEncrypt.btn--active')
expect(page).to have_css('div.js-securitySign.btn--active')

click '.btn', text: 'PGP'
expect(page).to have_css('.btn.btn--active', text: 'PGP')
expect(page).to have_no_css('.btn.btn--active', text: 'S/MIME')

# Wait until the security options check AJAX call is ready.
expect(page).to have_css('div.js-securityEncrypt.btn--active')
expect(page).to have_css('div.js-securitySign.btn--active')
expect(find('.js-securityEncryptComment')['title']).to eq('The PGP keys for pgp+smime-recipient@example.com were found.')
expect(find('.js-securitySignComment')['title']).to eq('The PGP key for pgp+smime-sender@example.com was found.')

expect(page).to have_css('.btn.btn--active', text: 'PGP')
expect(page).to have_no_css('.btn.btn--active', text: 'S/MIME')
click '.btn', text: 'S/MIME'

expect(find('.js-securityEncryptComment')['title']).to eq('The PGP keys for pgp+smime-recipient@example.com were found.')
expect(find('.js-securitySignComment')['title']).to eq('The PGP key for pgp+smime-sender@example.com was found.')
# Wait until the security options check AJAX call is ready.
expect(page).to have_css('div.js-securityEncrypt.btn--active')
expect(page).to have_css('div.js-securitySign.btn--active')

click '.btn', text: 'S/MIME'
expect(page).to have_no_css('.btn.btn--active', text: 'PGP')
expect(page).to have_css('.btn.btn--active', text: 'S/MIME')

# Wait until the security options check AJAX call is ready.
expect(page).to have_css('div.js-securityEncrypt.btn--active')
expect(page).to have_css('div.js-securitySign.btn--active')
expect(find('.js-securityEncryptComment')['title']).to eq('The certificates for pgp+smime-recipient@example.com were found.')
expect(find('.js-securitySignComment')['title']).to eq('The certificate for pgp+smime-sender@example.com was found.')
end
end
end

it_behaves_like 'showing security type switcher'

expect(page).to have_no_css('.btn.btn--active', text: 'PGP')
expect(page).to have_css('.btn.btn--active', text: 'S/MIME')
context 'when customer selection is based on template' do
before do
visit 'ticket/create'

expect(find('.js-securityEncryptComment')['title']).to eq('The certificates for pgp+smime-recipient@example.com were found.')
expect(find('.js-securitySignComment')['title']).to eq('The certificate for pgp+smime-sender@example.com was found.')
within(:active_content) do
use_template(template)
end
end

it_behaves_like 'switching between security types'
end

context 'when customer selection is based on manual selection' do
before do
visit 'ticket/create'

within(:active_content) do
click '.tab', text: 'Send Email'
find('[name=customer_id_completion]').fill_in with: customer.firstname
find("li.recipientList-entry.js-object[data-object-id='#{customer.id}']").click
end
end

it_behaves_like 'switching between security types'
end
end
end
Expand Down

0 comments on commit bf20565

Please sign in to comment.