Commit f1a0d64b authored by o@immerda.ch's avatar o@immerda.ch
Browse files

Merge branch 'fix-fwd-for-alias' into 'master'

fix an issue when trying to create a forward for an alias

See merge request !51
parents 9c7e6c6e 69dd292b
Pipeline #8130 passed with stage
in 3 minutes and 9 seconds
......@@ -88,7 +88,7 @@ class IApi < Sinatra::Base
address = EmailIaddress.where(local_part: local_part,
email_domain: domain).first
if address
unless MailManager.valid_target?(address)
unless MailManager.valid_target?(address.email)
return client_error("address is deleted")
end
else
......
......@@ -89,6 +89,21 @@ describe "iApi users admin route" do
expect(email).not_to be_nil
expect(email.email_forwards.first.target).to eql('user1@example.com')
end
it 'creates a forward additionnaly to an alias' do
ResourceManager.create!("mail_alias", 'user2@example.com',
{name: "alias", domain: "example.com", target: "user1@example.com"},
self_create: true)
post_as('admin', '/users_admin/create_new_forward',
with_admin_api_token(
email: 'alias@example.com',
target: 'user1@example.com',
)
)
expect(last_response).to be_ok
email = EmailIaddress.by_email('alias','example.com')
expect(email).not_to be_nil
expect(email.email_forwards.first.target).to eql('user1@example.com')
end
it 'fails on malformed target' do
post_as('admin', '/users_admin/create_new_forward',
with_admin_api_token(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment